From a0ab87ace8769fc2320a22cf1bd2d259ede567ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 20:29:49 +0000 Subject: [PATCH 01/75] feat(api): api update (#9) --- .stats.yml | 4 ++-- buildSrc/src/main/kotlin/hanzo.publish.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index dbc44ca8..3eb47591 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-45310ce8b457cd9d29707322ab26acd87a4b64b286d9fe804bd7b23b89067b77.yml -openapi_spec_hash: fb26cd549e0fe94f333db686235564fd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-5c57937ada402c7e9b9d76d7423808ee1800c47672078e57120f39599df846eb.yml +openapi_spec_hash: 76a9eb704a94642f4546e6bf2ac8e40f config_hash: 830747463ff4d018b5633ce511e88558 diff --git a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts index 9e539251..657800f3 100644 --- a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts @@ -30,7 +30,7 @@ configure { pom { name.set("Hanzo API") - description.set("Call 100+ LLMs in the OpenAI format. [**Docs**](https://docs.hanzo.ai/)\n\n👉 [`Hanzo Console`](https://cloud.hanzo.ai). Create, Edit API Keys.\n\n💸 [`LLM Models`](https://models.hanzo.ai/).") + description.set("API documentation for Hanzo") url.set("https://docs.hanzo.ai") licenses { From de98db1b44faa09c886df238e507de9814d26a33 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 23:29:33 +0000 Subject: [PATCH 02/75] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3eb47591..53107a1b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-5c57937ada402c7e9b9d76d7423808ee1800c47672078e57120f39599df846eb.yml -openapi_spec_hash: 76a9eb704a94642f4546e6bf2ac8e40f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-ec4be99f95dc46e9442eb60f233b2bff271d6f5bf57d7c61a52bc4804f55bbd1.yml +openapi_spec_hash: 87bc62c36bb6028ffd1f3e54a2809099 config_hash: 830747463ff4d018b5633ce511e88558 From e5af84a40d2f50556adcb9b54d088ff4482c81c7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 29 Mar 2025 03:16:14 +0000 Subject: [PATCH 03/75] fix(client): don't call `validate()` during deserialization if we don't have to (#11) --- .../src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt index 6d563247..3fa98c82 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt @@ -1,5 +1,6 @@ package ai.hanzo.api.core +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.core.type.TypeReference @@ -29,6 +30,13 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T + protected fun ObjectCodec.deserialize(node: JsonNode, type: TypeReference): T = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + throw HanzoInvalidDataException("Error deserializing", e) + } + protected fun ObjectCodec.tryDeserialize( node: JsonNode, type: TypeReference, From a4762869b0ad34a0212ed4ea2fc00cce3a020487 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 07:49:08 +0000 Subject: [PATCH 04/75] fix(client): limit json deserialization coercion (#12) --- hanzo-java-core/build.gradle.kts | 1 + .../kotlin/ai/hanzo/api/core/ObjectMappers.kt | 57 +++++++++++ .../ai/hanzo/api/core/ObjectMappersTest.kt | 81 ++++++++++++++++ .../ai/hanzo/api/core/http/SerializerTest.kt | 97 ------------------- 4 files changed, 139 insertions(+), 97 deletions(-) create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/SerializerTest.kt diff --git a/hanzo-java-core/build.gradle.kts b/hanzo-java-core/build.gradle.kts index 18a11075..ba424864 100644 --- a/hanzo-java-core/build.gradle.kts +++ b/hanzo-java-core/build.gradle.kts @@ -34,6 +34,7 @@ dependencies { testImplementation("org.assertj:assertj-core:3.25.3") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") testImplementation("org.mockito:mockito-core:5.14.2") testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt index 6e6fc7e3..77c5157d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt @@ -8,8 +8,11 @@ import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.kotlinModule @@ -21,6 +24,60 @@ fun jsonMapper(): JsonMapper = .addModule(Jdk8Module()) .addModule(JavaTimeModule()) .addModule(SimpleModule().addSerializer(InputStreamJsonSerializer)) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } .serializationInclusion(JsonInclude.Include.NON_ABSENT) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt new file mode 100644 index 00000000..a57105de --- /dev/null +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt @@ -0,0 +1,81 @@ +package ai.hanzo.api.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } +} diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/SerializerTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/SerializerTest.kt deleted file mode 100644 index 1de620bf..00000000 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/SerializerTest.kt +++ /dev/null @@ -1,97 +0,0 @@ -package ai.hanzo.api.core.http - -import ai.hanzo.api.core.* -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SerializerTest { - @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) - class ClassWithBooleanFieldPrefixedWithIs - private constructor( - private val isActive: JsonField, - private val additionalProperties: Map, - ) { - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun isActive(): Boolean? = isActive.getNullable("is_active") - - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate() = apply { - if (!validated) { - isActive() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(isActive, additionalProperties) - } - return hashCode - } - - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" - - companion object { - fun builder() = Builder() - } - - class Builder internal constructor() { - - private var isActive: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - @JsonProperty("is_active") - @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs(isActive, additionalProperties.toImmutable()) - } - } - - @Test - fun serializeBooleanPrefixedWithIs() { - val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() - assertThat(jsonMapper().writeValueAsString(value)).isEqualTo("{\"is_active\":true}") - } -} From a7a0b4a6b847da6df6b459af2c149c7569ad9e0c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 10:14:30 +0000 Subject: [PATCH 05/75] fix: pluralize `list` response variables (#13) --- .../hanzo/api/services/async/AssistantServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/BatchServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt | 6 +++--- .../hanzo/api/services/async/CredentialServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/FileServiceAsyncTest.kt | 6 +++--- .../hanzo/api/services/async/GuardrailServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/KeyServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/RouteServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/TeamServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/async/UserServiceAsyncTest.kt | 6 +++--- .../api/services/async/finetuning/JobServiceAsyncTest.kt | 6 +++--- .../hanzo/api/services/async/model/InfoServiceAsyncTest.kt | 6 +++--- .../services/async/responses/InputItemServiceAsyncTest.kt | 6 +++--- .../api/services/async/threads/MessageServiceAsyncTest.kt | 6 +++--- .../ai/hanzo/api/services/blocking/AssistantServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/BatchServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/BudgetServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/CredentialServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/FileServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/GuardrailServiceTest.kt | 4 ++-- .../kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/RouteServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/TeamServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/UserServiceTest.kt | 4 ++-- .../api/services/blocking/finetuning/JobServiceTest.kt | 4 ++-- .../ai/hanzo/api/services/blocking/model/InfoServiceTest.kt | 4 ++-- .../api/services/blocking/responses/InputItemServiceTest.kt | 4 ++-- .../api/services/blocking/threads/MessageServiceTest.kt | 5 +++-- 28 files changed, 71 insertions(+), 70 deletions(-) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt index ee9b40b5..91cd4c4d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt @@ -38,10 +38,10 @@ internal class AssistantServiceAsyncTest { .build() val assistantServiceAsync = client.assistants() - val assistantFuture = assistantServiceAsync.list() + val assistantsFuture = assistantServiceAsync.list() - val assistant = assistantFuture.get() - assistant.validate() + val assistants = assistantsFuture.get() + assistants.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt index 8a2da113..c4da6505 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt @@ -64,13 +64,13 @@ internal class BatchServiceAsyncTest { .build() val batchServiceAsync = client.batches() - val batchFuture = + val batchesFuture = batchServiceAsync.list( BatchListParams.builder().after("after").limit(0L).provider("provider").build() ) - val batch = batchFuture.get() - batch.validate() + val batches = batchesFuture.get() + batches.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt index 5d6e5b8e..0a5f7848 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt @@ -120,10 +120,10 @@ internal class BudgetServiceAsyncTest { .build() val budgetServiceAsync = client.budget() - val budgetFuture = budgetServiceAsync.list() + val budgetsFuture = budgetServiceAsync.list() - val budget = budgetFuture.get() - budget.validate() + val budgets = budgetsFuture.get() + budgets.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt index c60b291c..1fcbea52 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt @@ -48,10 +48,10 @@ internal class CredentialServiceAsyncTest { .build() val credentialServiceAsync = client.credentials() - val credentialFuture = credentialServiceAsync.list() + val credentialsFuture = credentialServiceAsync.list() - val credential = credentialFuture.get() - credential.validate() + val credentials = credentialsFuture.get() + credentials.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt index df6ca52e..cf775af2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt @@ -68,13 +68,13 @@ internal class FileServiceAsyncTest { .build() val fileServiceAsync = client.files() - val fileFuture = + val filesFuture = fileServiceAsync.list( FileListParams.builder().provider("provider").purpose("purpose").build() ) - val file = fileFuture.get() - file.validate() + val files = filesFuture.get() + files.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt index 0e698846..886effd0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt @@ -21,9 +21,9 @@ internal class GuardrailServiceAsyncTest { .build() val guardrailServiceAsync = client.guardrails() - val guardrailFuture = guardrailServiceAsync.list() + val guardrailsFuture = guardrailServiceAsync.list() - val guardrail = guardrailFuture.get() - guardrail.validate() + val guardrails = guardrailsFuture.get() + guardrails.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt index 9041de80..202fb183 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt @@ -82,7 +82,7 @@ internal class KeyServiceAsyncTest { .build() val keyServiceAsync = client.key() - val keyFuture = + val keysFuture = keyServiceAsync.list( KeyListParams.builder() .includeTeamKeys(true) @@ -96,8 +96,8 @@ internal class KeyServiceAsyncTest { .build() ) - val key = keyFuture.get() - key.validate() + val keys = keysFuture.get() + keys.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt index 838fefa9..5612f100 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt @@ -21,9 +21,9 @@ internal class RouteServiceAsyncTest { .build() val routeServiceAsync = client.routes() - val routeFuture = routeServiceAsync.list() + val routesFuture = routeServiceAsync.list() - val route = routeFuture.get() - route.validate() + val routes = routesFuture.get() + routes.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt index a82c1c25..4e4c4a1e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt @@ -113,13 +113,13 @@ internal class TeamServiceAsyncTest { .build() val teamServiceAsync = client.team() - val teamFuture = + val teamsFuture = teamServiceAsync.list( TeamListParams.builder().organizationId("organization_id").userId("user_id").build() ) - val team = teamFuture.get() - team.validate() + val teams = teamsFuture.get() + teams.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt index 13570267..76e3e3fe 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt @@ -118,7 +118,7 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.user() - val userFuture = + val usersFuture = userServiceAsync.list( UserListParams.builder() .page(1L) @@ -128,8 +128,8 @@ internal class UserServiceAsyncTest { .build() ) - val user = userFuture.get() - user.validate() + val users = usersFuture.get() + users.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt index b120ff84..12c6dc59 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt @@ -80,7 +80,7 @@ internal class JobServiceAsyncTest { .build() val jobServiceAsync = client.fineTuning().jobs() - val jobFuture = + val jobsFuture = jobServiceAsync.list( JobListParams.builder() .customLlmProvider(JobListParams.CustomLlmProvider.OPENAI) @@ -89,7 +89,7 @@ internal class JobServiceAsyncTest { .build() ) - val job = jobFuture.get() - job.validate() + val jobs = jobsFuture.get() + jobs.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt index c5327a2c..0ad09f74 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt @@ -22,10 +22,10 @@ internal class InfoServiceAsyncTest { .build() val infoServiceAsync = client.model().info() - val infoFuture = + val infosFuture = infoServiceAsync.list(InfoListParams.builder().llmModelId("llm_model_id").build()) - val info = infoFuture.get() - info.validate() + val infos = infosFuture.get() + infos.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt index 1f3948b2..4b7f56b0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt @@ -22,12 +22,12 @@ internal class InputItemServiceAsyncTest { .build() val inputItemServiceAsync = client.responses().inputItems() - val inputItemFuture = + val inputItemsFuture = inputItemServiceAsync.list( InputItemListParams.builder().responseId("response_id").build() ) - val inputItem = inputItemFuture.get() - inputItem.validate() + val inputItems = inputItemsFuture.get() + inputItems.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt index d19f8d60..6d496c56 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt @@ -40,10 +40,10 @@ internal class MessageServiceAsyncTest { .build() val messageServiceAsync = client.threads().messages() - val messageFuture = + val messagesFuture = messageServiceAsync.list(MessageListParams.builder().threadId("thread_id").build()) - val message = messageFuture.get() - message.validate() + val messages = messagesFuture.get() + messages.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt index 6ad15e74..4a78f01c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt @@ -37,9 +37,9 @@ internal class AssistantServiceTest { .build() val assistantService = client.assistants() - val assistant = assistantService.list() + val assistants = assistantService.list() - assistant.validate() + assistants.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt index bd505476..edfadf6b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt @@ -61,12 +61,12 @@ internal class BatchServiceTest { .build() val batchService = client.batches() - val batch = + val batches = batchService.list( BatchListParams.builder().after("after").limit(0L).provider("provider").build() ) - batch.validate() + batches.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt index 1fc3e41b..45aee1e2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt @@ -118,9 +118,9 @@ internal class BudgetServiceTest { .build() val budgetService = client.budget() - val budget = budgetService.list() + val budgets = budgetService.list() - budget.validate() + budgets.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt index 14bdb1b8..9e7e3289 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt @@ -47,9 +47,9 @@ internal class CredentialServiceTest { .build() val credentialService = client.credentials() - val credential = credentialService.list() + val credentials = credentialService.list() - credential.validate() + credentials.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt index 81a899e4..e6513cf0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt @@ -66,12 +66,12 @@ internal class FileServiceTest { .build() val fileService = client.files() - val file = + val files = fileService.list( FileListParams.builder().provider("provider").purpose("purpose").build() ) - file.validate() + files.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt index 27567cdd..9ea0a3a3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt @@ -21,8 +21,8 @@ internal class GuardrailServiceTest { .build() val guardrailService = client.guardrails() - val guardrail = guardrailService.list() + val guardrails = guardrailService.list() - guardrail.validate() + guardrails.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt index ab48f811..057af0da 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt @@ -81,7 +81,7 @@ internal class KeyServiceTest { .build() val keyService = client.key() - val key = + val keys = keyService.list( KeyListParams.builder() .includeTeamKeys(true) @@ -95,7 +95,7 @@ internal class KeyServiceTest { .build() ) - key.validate() + keys.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt index 45d0aadc..b69fe357 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt @@ -21,8 +21,8 @@ internal class RouteServiceTest { .build() val routeService = client.routes() - val route = routeService.list() + val routes = routeService.list() - route.validate() + routes.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt index 6651467d..246a3fab 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt @@ -111,12 +111,12 @@ internal class TeamServiceTest { .build() val teamService = client.team() - val team = + val teams = teamService.list( TeamListParams.builder().organizationId("organization_id").userId("user_id").build() ) - team.validate() + teams.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt index 704609fc..9d31c8c6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt @@ -116,7 +116,7 @@ internal class UserServiceTest { .build() val userService = client.user() - val user = + val users = userService.list( UserListParams.builder() .page(1L) @@ -126,7 +126,7 @@ internal class UserServiceTest { .build() ) - user.validate() + users.validate() } @Disabled("skipped: tests are disabled for the time being") diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt index d41ac1f7..7daf2174 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt @@ -78,7 +78,7 @@ internal class JobServiceTest { .build() val jobService = client.fineTuning().jobs() - val job = + val jobs = jobService.list( JobListParams.builder() .customLlmProvider(JobListParams.CustomLlmProvider.OPENAI) @@ -87,6 +87,6 @@ internal class JobServiceTest { .build() ) - job.validate() + jobs.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt index 09000a04..b356114e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt @@ -22,8 +22,8 @@ internal class InfoServiceTest { .build() val infoService = client.model().info() - val info = infoService.list(InfoListParams.builder().llmModelId("llm_model_id").build()) + val infos = infoService.list(InfoListParams.builder().llmModelId("llm_model_id").build()) - info.validate() + infos.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt index 01947be9..53698fa2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt @@ -22,9 +22,9 @@ internal class InputItemServiceTest { .build() val inputItemService = client.responses().inputItems() - val inputItem = + val inputItems = inputItemService.list(InputItemListParams.builder().responseId("response_id").build()) - inputItem.validate() + inputItems.validate() } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt index f73e9d9e..92888adb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt @@ -39,8 +39,9 @@ internal class MessageServiceTest { .build() val messageService = client.threads().messages() - val message = messageService.list(MessageListParams.builder().threadId("thread_id").build()) + val messages = + messageService.list(MessageListParams.builder().threadId("thread_id").build()) - message.validate() + messages.validate() } } From ebf7b9734d07621d28d394281160823dea9c8de3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 10:50:05 +0000 Subject: [PATCH 06/75] feat(client): make union deserialization more robust (#14) feat(client): add enum validation method chore(client): remove unnecessary json state from some query param classes chore(internal): add json roundtripping tests chore(internal): add invalid json deserialization tests --- .../ai/hanzo/api/core/BaseDeserializer.kt | 33 +- .../main/kotlin/ai/hanzo/api/core/Utils.kt | 28 ++ .../hanzo/api/models/ClientGetHomeResponse.kt | 16 + .../active/ActiveListCallbacksResponse.kt | 16 + .../api/models/add/AddAddAllowedIpResponse.kt | 16 + .../ai/hanzo/api/models/add/IpAddress.kt | 15 + .../anthropic/AnthropicCreateResponse.kt | 16 + .../anthropic/AnthropicDeleteResponse.kt | 16 + .../anthropic/AnthropicModifyResponse.kt | 16 + .../anthropic/AnthropicRetrieveResponse.kt | 16 + .../anthropic/AnthropicUpdateResponse.kt | 16 + .../assemblyai/AssemblyaiCreateResponse.kt | 16 + .../assemblyai/AssemblyaiDeleteResponse.kt | 16 + .../assemblyai/AssemblyaiPatchResponse.kt | 16 + .../assemblyai/AssemblyaiRetrieveResponse.kt | 16 + .../assemblyai/AssemblyaiUpdateResponse.kt | 16 + .../assistants/AssistantCreateResponse.kt | 16 + .../assistants/AssistantDeleteResponse.kt | 16 + .../assistants/AssistantListResponse.kt | 16 + .../audio/speech/SpeechCreateResponse.kt | 16 + .../TranscriptionCreateParams.kt | 8 + .../TranscriptionCreateResponse.kt | 16 + .../api/models/azure/AzureCallResponse.kt | 16 + .../api/models/azure/AzureCreateResponse.kt | 16 + .../api/models/azure/AzureDeleteResponse.kt | 16 + .../api/models/azure/AzurePatchResponse.kt | 16 + .../api/models/azure/AzureUpdateResponse.kt | 16 + .../BatchCancelWithProviderResponse.kt | 16 + .../api/models/batches/BatchCreateResponse.kt | 16 + .../BatchCreateWithProviderResponse.kt | 16 + .../api/models/batches/BatchListResponse.kt | 16 + .../batches/BatchListWithProviderResponse.kt | 16 + .../models/batches/BatchRetrieveResponse.kt | 16 + .../BatchRetrieveWithProviderResponse.kt | 16 + .../batches/cancel/CancelCancelResponse.kt | 16 + .../models/bedrock/BedrockCreateResponse.kt | 16 + .../models/bedrock/BedrockDeleteResponse.kt | 16 + .../models/bedrock/BedrockPatchResponse.kt | 16 + .../models/bedrock/BedrockRetrieveResponse.kt | 16 + .../models/bedrock/BedrockUpdateResponse.kt | 16 + .../api/models/budget/BudgetCreateResponse.kt | 16 + .../api/models/budget/BudgetDeleteParams.kt | 16 + .../api/models/budget/BudgetDeleteResponse.kt | 16 + .../api/models/budget/BudgetInfoParams.kt | 17 + .../api/models/budget/BudgetInfoResponse.kt | 16 + .../api/models/budget/BudgetListResponse.kt | 16 + .../ai/hanzo/api/models/budget/BudgetNew.kt | 42 +++ .../models/budget/BudgetSettingsResponse.kt | 16 + .../api/models/budget/BudgetUpdateResponse.kt | 16 + .../api/models/cache/CacheDeleteResponse.kt | 16 + .../api/models/cache/CacheFlushAllResponse.kt | 16 + .../api/models/cache/CachePingResponse.kt | 21 ++ .../cache/redis/RediRetrieveInfoResponse.kt | 16 + .../completions/CompletionCreateResponse.kt | 16 + .../api/models/cohere/CohereCreateResponse.kt | 16 + .../api/models/cohere/CohereDeleteResponse.kt | 16 + .../api/models/cohere/CohereModifyResponse.kt | 16 + .../models/cohere/CohereRetrieveResponse.kt | 16 + .../api/models/cohere/CohereUpdateResponse.kt | 16 + .../completions/CompletionCreateResponse.kt | 16 + .../PassThroughEndpointCreateResponse.kt | 16 + .../PassThroughEndpointResponse.kt | 18 + .../PassThroughEndpointUpdateResponse.kt | 16 + .../PassThroughGenericEndpoint.kt | 17 + .../credentials/CredentialCreateParams.kt | 19 ++ .../credentials/CredentialCreateResponse.kt | 16 + .../credentials/CredentialDeleteResponse.kt | 16 + .../api/models/credentials/CredentialItem.kt | 15 + .../credentials/CredentialListResponse.kt | 16 + .../hanzo/api/models/customer/BlockUsers.kt | 16 + .../models/customer/CustomerBlockResponse.kt | 16 + .../models/customer/CustomerCreateParams.kt | 77 ++++- .../models/customer/CustomerCreateResponse.kt | 16 + .../models/customer/CustomerDeleteParams.kt | 17 + .../models/customer/CustomerDeleteResponse.kt | 16 + .../models/customer/CustomerListResponse.kt | 75 +++- .../customer/CustomerRetrieveInfoResponse.kt | 75 +++- .../customer/CustomerUnblockResponse.kt | 16 + .../models/customer/CustomerUpdateParams.kt | 53 ++- .../models/customer/CustomerUpdateResponse.kt | 16 + .../delete/DeleteCreateAllowedIpResponse.kt | 16 + .../embeddings/EmbeddingCreateResponse.kt | 16 + .../models/engines/EngineCompleteResponse.kt | 16 + .../api/models/engines/EngineEmbedResponse.kt | 16 + .../engines/chat/ChatCompleteResponse.kt | 16 + .../EuAssemblyaiCreateResponse.kt | 16 + .../EuAssemblyaiDeleteResponse.kt | 16 + .../euassemblyai/EuAssemblyaiPatchResponse.kt | 16 + .../EuAssemblyaiRetrieveResponse.kt | 16 + .../EuAssemblyaiUpdateResponse.kt | 16 + .../api/models/files/FileCreateParams.kt | 8 + .../api/models/files/FileCreateResponse.kt | 16 + .../api/models/files/FileDeleteResponse.kt | 16 + .../api/models/files/FileListResponse.kt | 16 + .../api/models/files/FileRetrieveResponse.kt | 16 + .../files/content/ContentRetrieveResponse.kt | 16 + .../models/finetuning/jobs/JobCreateParams.kt | 252 ++++++++++++-- .../finetuning/jobs/JobCreateResponse.kt | 16 + .../models/finetuning/jobs/JobListParams.kt | 27 ++ .../models/finetuning/jobs/JobListResponse.kt | 16 + .../finetuning/jobs/JobRetrieveParams.kt | 27 ++ .../finetuning/jobs/JobRetrieveResponse.kt | 16 + .../jobs/cancel/CancelCreateResponse.kt | 16 + .../api/models/gemini/GeminiCreateResponse.kt | 16 + .../api/models/gemini/GeminiDeleteResponse.kt | 16 + .../api/models/gemini/GeminiPatchResponse.kt | 16 + .../models/gemini/GeminiRetrieveResponse.kt | 16 + .../api/models/gemini/GeminiUpdateResponse.kt | 16 + .../global/spend/SpendListTagsResponse.kt | 286 +++++++++++++--- .../models/global/spend/SpendResetResponse.kt | 16 + .../global/spend/SpendRetrieveReportParams.kt | 27 ++ .../spend/SpendRetrieveReportResponse.kt | 286 +++++++++++++--- .../guardrails/GuardrailListResponse.kt | 118 ++++++- .../models/health/HealthCheckAllResponse.kt | 16 + .../health/HealthCheckLivelinessResponse.kt | 16 + .../health/HealthCheckLivenessResponse.kt | 16 + .../health/HealthCheckReadinessResponse.kt | 16 + .../health/HealthCheckServicesParams.kt | 27 ++ .../health/HealthCheckServicesResponse.kt | 16 + .../generations/GenerationCreateResponse.kt | 16 + .../hanzo/api/models/key/BlockKeyRequest.kt | 15 + .../api/models/key/GenerateKeyResponse.kt | 40 +++ .../hanzo/api/models/key/KeyBlockResponse.kt | 98 +++++- .../api/models/key/KeyCheckHealthResponse.kt | 96 +++++- .../hanzo/api/models/key/KeyDeleteParams.kt | 18 + .../hanzo/api/models/key/KeyDeleteResponse.kt | 16 + .../hanzo/api/models/key/KeyGenerateParams.kt | 37 ++ .../hanzo/api/models/key/KeyListResponse.kt | 302 ++++++++++++++-- .../api/models/key/KeyRetrieveInfoResponse.kt | 16 + .../api/models/key/KeyUnblockResponse.kt | 16 + .../hanzo/api/models/key/KeyUpdateParams.kt | 37 ++ .../hanzo/api/models/key/KeyUpdateResponse.kt | 16 + .../key/regenerate/RegenerateKeyRequest.kt | 37 ++ .../models/langfuse/LangfuseCreateResponse.kt | 16 + .../models/langfuse/LangfuseDeleteResponse.kt | 16 + .../models/langfuse/LangfusePatchResponse.kt | 16 + .../langfuse/LangfuseRetrieveResponse.kt | 16 + .../models/langfuse/LangfuseUpdateResponse.kt | 16 + .../ConfigurableClientsideParamsCustomAuth.kt | 15 + .../api/models/model/ModelCreateParams.kt | 321 +++++++++++++++--- .../api/models/model/ModelCreateResponse.kt | 16 + .../api/models/model/ModelDeleteParams.kt | 16 + .../api/models/model/ModelDeleteResponse.kt | 16 + .../ai/hanzo/api/models/model/ModelInfo.kt | 55 ++- .../api/models/model/info/InfoListResponse.kt | 16 + .../models/model/update/UpdateDeployment.kt | 320 ++++++++++++++--- .../models/model/update/UpdateFullResponse.kt | 16 + .../model/update/UpdatePartialResponse.kt | 16 + .../ModelGroupRetrieveInfoResponse.kt | 16 + .../api/models/models/ModelListResponse.kt | 16 + .../moderations/ModerationCreateResponse.kt | 16 + .../api/models/openai/OpenAICreateResponse.kt | 16 + .../api/models/openai/OpenAIDeleteResponse.kt | 16 + .../api/models/openai/OpenAIPatchResponse.kt | 16 + .../models/openai/OpenAIRetrieveResponse.kt | 16 + .../api/models/openai/OpenAIUpdateResponse.kt | 16 + .../deployments/DeploymentCompleteResponse.kt | 16 + .../deployments/DeploymentEmbedResponse.kt | 16 + .../deployments/chat/ChatCompleteResponse.kt | 16 + .../api/models/organization/OrgMember.kt | 48 ++- .../OrganizationAddMemberParams.kt | 87 ++++- .../OrganizationAddMemberResponse.kt | 147 ++++++++ .../organization/OrganizationCreateParams.kt | 27 ++ .../OrganizationCreateResponse.kt | 25 ++ .../OrganizationDeleteMemberParams.kt | 20 ++ .../OrganizationDeleteMemberResponse.kt | 16 + .../organization/OrganizationDeleteParams.kt | 18 + .../OrganizationDeleteResponse.kt | 214 +++++++++++- .../organization/OrganizationListResponse.kt | 214 +++++++++++- .../OrganizationUpdateMemberParams.kt | 51 ++- .../OrganizationUpdateMemberResponse.kt | 47 +++ .../organization/OrganizationUpdateParams.kt | 23 ++ .../OrganizationUpdateResponse.kt | 214 +++++++++++- .../organization/info/InfoDeprecatedParams.kt | 18 + .../info/InfoDeprecatedResponse.kt | 16 + .../organization/info/InfoRetrieveResponse.kt | 214 +++++++++++- .../provider/ProviderListBudgetsResponse.kt | 34 ++ .../api/models/rerank/RerankCreateResponse.kt | 16 + .../models/rerank/RerankCreateV1Response.kt | 16 + .../models/rerank/RerankCreateV2Response.kt | 16 + .../responses/ResponseCreateResponse.kt | 16 + .../responses/ResponseDeleteResponse.kt | 16 + .../responses/ResponseRetrieveResponse.kt | 16 + .../inputitems/InputItemListResponse.kt | 16 + .../api/models/routes/RouteListResponse.kt | 16 + .../settings/SettingRetrieveResponse.kt | 16 + .../models/spend/SpendCalculateSpendParams.kt | 18 + .../spend/SpendCalculateSpendResponse.kt | 16 + .../api/models/spend/SpendListLogsResponse.kt | 286 +++++++++++++--- .../api/models/spend/SpendListTagsResponse.kt | 286 +++++++++++++--- .../hanzo/api/models/team/BlockTeamRequest.kt | 15 + .../kotlin/ai/hanzo/api/models/team/Member.kt | 48 ++- .../api/models/team/TeamAddMemberParams.kt | 87 ++++- .../api/models/team/TeamAddMemberResponse.kt | 239 ++++++++++++- .../api/models/team/TeamBlockResponse.kt | 16 + .../hanzo/api/models/team/TeamCreateParams.kt | 31 ++ .../api/models/team/TeamCreateResponse.kt | 114 ++++++- .../hanzo/api/models/team/TeamDeleteParams.kt | 16 + .../api/models/team/TeamDeleteResponse.kt | 16 + .../models/team/TeamDisableLoggingResponse.kt | 16 + .../models/team/TeamListAvailableResponse.kt | 16 + .../hanzo/api/models/team/TeamListResponse.kt | 16 + .../api/models/team/TeamRemoveMemberParams.kt | 20 ++ .../models/team/TeamRemoveMemberResponse.kt | 16 + .../models/team/TeamRetrieveInfoResponse.kt | 16 + .../api/models/team/TeamUnblockResponse.kt | 16 + .../api/models/team/TeamUpdateMemberParams.kt | 51 ++- .../models/team/TeamUpdateMemberResponse.kt | 20 ++ .../hanzo/api/models/team/TeamUpdateParams.kt | 28 ++ .../api/models/team/TeamUpdateResponse.kt | 16 + .../models/team/callback/CallbackAddParams.kt | 67 +++- .../team/callback/CallbackAddResponse.kt | 16 + .../team/callback/CallbackRetrieveResponse.kt | 16 + .../api/models/team/model/ModelAddParams.kt | 19 ++ .../api/models/team/model/ModelAddResponse.kt | 16 + .../models/team/model/ModelRemoveParams.kt | 19 ++ .../models/team/model/ModelRemoveResponse.kt | 16 + .../hanzo/api/models/test/TestPingResponse.kt | 16 + .../models/threads/ThreadCreateResponse.kt | 16 + .../models/threads/ThreadRetrieveResponse.kt | 16 + .../threads/messages/MessageCreateResponse.kt | 16 + .../threads/messages/MessageListResponse.kt | 16 + .../models/threads/runs/RunCreateResponse.kt | 16 + .../hanzo/api/models/user/UserCreateParams.kt | 66 +++- .../api/models/user/UserCreateResponse.kt | 73 +++- .../hanzo/api/models/user/UserDeleteParams.kt | 16 + .../api/models/user/UserDeleteResponse.kt | 16 + .../hanzo/api/models/user/UserListResponse.kt | 16 + .../models/user/UserRetrieveInfoResponse.kt | 16 + .../hanzo/api/models/user/UserUpdateParams.kt | 63 +++- .../api/models/user/UserUpdateResponse.kt | 16 + .../UtilGetSupportedOpenAIParamsResponse.kt | 16 + .../models/utils/UtilTokenCounterParams.kt | 20 ++ .../models/utils/UtilTokenCounterResponse.kt | 20 ++ .../utils/UtilTransformRequestParams.kt | 47 ++- .../utils/UtilTransformRequestResponse.kt | 18 + .../models/vertexai/VertexAiCreateResponse.kt | 16 + .../models/vertexai/VertexAiDeleteResponse.kt | 16 + .../models/vertexai/VertexAiPatchResponse.kt | 16 + .../vertexai/VertexAiRetrieveResponse.kt | 16 + .../models/vertexai/VertexAiUpdateResponse.kt | 16 + .../api/models/ClientGetHomeResponseTest.kt | 18 + .../active/ActiveListCallbacksResponseTest.kt | 18 + .../models/add/AddAddAllowedIpResponseTest.kt | 18 + .../ai/hanzo/api/models/add/IpAddressTest.kt | 17 + .../anthropic/AnthropicCreateResponseTest.kt | 18 + .../anthropic/AnthropicDeleteResponseTest.kt | 18 + .../anthropic/AnthropicModifyResponseTest.kt | 18 + .../AnthropicRetrieveResponseTest.kt | 18 + .../anthropic/AnthropicUpdateResponseTest.kt | 18 + .../AssemblyaiCreateResponseTest.kt | 18 + .../AssemblyaiDeleteResponseTest.kt | 18 + .../assemblyai/AssemblyaiPatchResponseTest.kt | 18 + .../AssemblyaiRetrieveResponseTest.kt | 18 + .../AssemblyaiUpdateResponseTest.kt | 18 + .../assistants/AssistantCreateResponseTest.kt | 18 + .../assistants/AssistantDeleteResponseTest.kt | 18 + .../assistants/AssistantListResponseTest.kt | 18 + .../audio/speech/SpeechCreateResponseTest.kt | 18 + .../TranscriptionCreateResponseTest.kt | 18 + .../api/models/azure/AzureCallResponseTest.kt | 18 + .../models/azure/AzureCreateResponseTest.kt | 18 + .../models/azure/AzureDeleteResponseTest.kt | 18 + .../models/azure/AzurePatchResponseTest.kt | 18 + .../models/azure/AzureUpdateResponseTest.kt | 18 + .../BatchCancelWithProviderResponseTest.kt | 19 ++ .../models/batches/BatchCreateResponseTest.kt | 18 + .../BatchCreateWithProviderResponseTest.kt | 19 ++ .../models/batches/BatchListResponseTest.kt | 18 + .../BatchListWithProviderResponseTest.kt | 19 ++ .../batches/BatchRetrieveResponseTest.kt | 18 + .../BatchRetrieveWithProviderResponseTest.kt | 19 ++ .../cancel/CancelCancelResponseTest.kt | 18 + .../bedrock/BedrockCreateResponseTest.kt | 18 + .../bedrock/BedrockDeleteResponseTest.kt | 18 + .../bedrock/BedrockPatchResponseTest.kt | 18 + .../bedrock/BedrockRetrieveResponseTest.kt | 18 + .../bedrock/BedrockUpdateResponseTest.kt | 18 + .../models/budget/BudgetCreateResponseTest.kt | 18 + .../models/budget/BudgetDeleteResponseTest.kt | 18 + .../models/budget/BudgetInfoResponseTest.kt | 18 + .../models/budget/BudgetListResponseTest.kt | 18 + .../hanzo/api/models/budget/BudgetNewTest.kt | 41 +++ .../budget/BudgetSettingsResponseTest.kt | 18 + .../models/budget/BudgetUpdateResponseTest.kt | 18 + .../models/cache/CacheDeleteResponseTest.kt | 18 + .../models/cache/CacheFlushAllResponseTest.kt | 18 + .../api/models/cache/CachePingResponseTest.kt | 25 ++ .../redis/RediRetrieveInfoResponseTest.kt | 18 + .../CompletionCreateResponseTest.kt | 18 + .../models/cohere/CohereCreateResponseTest.kt | 18 + .../models/cohere/CohereDeleteResponseTest.kt | 18 + .../models/cohere/CohereModifyResponseTest.kt | 18 + .../cohere/CohereRetrieveResponseTest.kt | 18 + .../models/cohere/CohereUpdateResponseTest.kt | 18 + .../CompletionCreateResponseTest.kt | 18 + .../PassThroughEndpointCreateResponseTest.kt | 19 ++ .../PassThroughEndpointResponseTest.kt | 26 ++ .../PassThroughEndpointUpdateResponseTest.kt | 19 ++ .../PassThroughGenericEndpointTest.kt | 22 ++ .../CredentialCreateResponseTest.kt | 18 + .../CredentialDeleteResponseTest.kt | 18 + .../models/credentials/CredentialItemTest.kt | 22 ++ .../credentials/CredentialListResponseTest.kt | 18 + .../api/models/customer/BlockUsersTest.kt | 17 + .../customer/CustomerBlockResponseTest.kt | 18 + .../customer/CustomerCreateResponseTest.kt | 18 + .../customer/CustomerDeleteResponseTest.kt | 18 + .../customer/CustomerListResponseTest.kt | 36 ++ .../CustomerRetrieveInfoResponseTest.kt | 36 ++ .../customer/CustomerUnblockResponseTest.kt | 18 + .../customer/CustomerUpdateResponseTest.kt | 18 + .../DeleteCreateAllowedIpResponseTest.kt | 19 ++ .../embeddings/EmbeddingCreateResponseTest.kt | 18 + .../engines/EngineCompleteResponseTest.kt | 18 + .../models/engines/EngineEmbedResponseTest.kt | 18 + .../engines/chat/ChatCompleteResponseTest.kt | 18 + .../EuAssemblyaiCreateResponseTest.kt | 18 + .../EuAssemblyaiDeleteResponseTest.kt | 18 + .../EuAssemblyaiPatchResponseTest.kt | 18 + .../EuAssemblyaiRetrieveResponseTest.kt | 18 + .../EuAssemblyaiUpdateResponseTest.kt | 18 + .../models/files/FileCreateResponseTest.kt | 18 + .../models/files/FileDeleteResponseTest.kt | 18 + .../api/models/files/FileListResponseTest.kt | 18 + .../models/files/FileRetrieveResponseTest.kt | 18 + .../content/ContentRetrieveResponseTest.kt | 18 + .../finetuning/jobs/JobCreateResponseTest.kt | 18 + .../finetuning/jobs/JobListResponseTest.kt | 18 + .../jobs/JobRetrieveResponseTest.kt | 18 + .../jobs/cancel/CancelCreateResponseTest.kt | 18 + .../models/gemini/GeminiCreateResponseTest.kt | 18 + .../models/gemini/GeminiDeleteResponseTest.kt | 18 + .../models/gemini/GeminiPatchResponseTest.kt | 18 + .../gemini/GeminiRetrieveResponseTest.kt | 18 + .../models/gemini/GeminiUpdateResponseTest.kt | 18 + .../global/spend/SpendListTagsResponseTest.kt | 38 +++ .../global/spend/SpendResetResponseTest.kt | 18 + .../spend/SpendRetrieveReportResponseTest.kt | 38 +++ .../guardrails/GuardrailListResponseTest.kt | 32 ++ .../health/HealthCheckAllResponseTest.kt | 18 + .../HealthCheckLivelinessResponseTest.kt | 19 ++ .../health/HealthCheckLivenessResponseTest.kt | 18 + .../HealthCheckReadinessResponseTest.kt | 18 + .../health/HealthCheckServicesResponseTest.kt | 18 + .../GenerationCreateResponseTest.kt | 18 + .../api/models/key/BlockKeyRequestTest.kt | 17 + .../api/models/key/GenerateKeyResponseTest.kt | 51 +++ .../api/models/key/KeyBlockResponseTest.kt | 48 +++ .../models/key/KeyCheckHealthResponseTest.kt | 27 ++ .../api/models/key/KeyDeleteResponseTest.kt | 18 + .../api/models/key/KeyListResponseTest.kt | 23 ++ .../models/key/KeyRetrieveInfoResponseTest.kt | 18 + .../api/models/key/KeyUnblockResponseTest.kt | 18 + .../api/models/key/KeyUpdateResponseTest.kt | 18 + .../regenerate/RegenerateKeyRequestTest.kt | 47 +++ .../langfuse/LangfuseCreateResponseTest.kt | 18 + .../langfuse/LangfuseDeleteResponseTest.kt | 18 + .../langfuse/LangfusePatchResponseTest.kt | 18 + .../langfuse/LangfuseRetrieveResponseTest.kt | 18 + .../langfuse/LangfuseUpdateResponseTest.kt | 18 + ...figurableClientsideParamsCustomAuthTest.kt | 19 ++ .../models/model/ModelCreateResponseTest.kt | 18 + .../models/model/ModelDeleteResponseTest.kt | 18 + .../hanzo/api/models/model/ModelInfoTest.kt | 29 ++ .../models/model/info/InfoListResponseTest.kt | 18 + .../model/update/UpdateDeploymentTest.kt | 69 ++++ .../model/update/UpdateFullResponseTest.kt | 18 + .../model/update/UpdatePartialResponseTest.kt | 18 + .../ModelGroupRetrieveInfoResponseTest.kt | 19 ++ .../models/models/ModelListResponseTest.kt | 18 + .../ModerationCreateResponseTest.kt | 18 + .../models/openai/OpenAICreateResponseTest.kt | 18 + .../models/openai/OpenAIDeleteResponseTest.kt | 18 + .../models/openai/OpenAIPatchResponseTest.kt | 18 + .../openai/OpenAIRetrieveResponseTest.kt | 18 + .../models/openai/OpenAIUpdateResponseTest.kt | 18 + .../DeploymentCompleteResponseTest.kt | 18 + .../DeploymentEmbedResponseTest.kt | 18 + .../chat/ChatCompleteResponseTest.kt | 18 + .../api/models/organization/OrgMemberTest.kt | 22 ++ .../OrganizationAddMemberResponseTest.kt | 91 +++++ .../OrganizationCreateResponseTest.kt | 29 ++ .../OrganizationDeleteMemberResponseTest.kt | 19 ++ .../OrganizationDeleteResponseTest.kt | 98 ++++++ .../OrganizationListResponseTest.kt | 98 ++++++ .../OrganizationUpdateMemberResponseTest.kt | 39 +++ .../OrganizationUpdateResponseTest.kt | 98 ++++++ .../info/InfoDeprecatedResponseTest.kt | 18 + .../info/InfoRetrieveResponseTest.kt | 98 ++++++ .../ProviderListBudgetsResponseTest.kt | 34 ++ .../models/rerank/RerankCreateResponseTest.kt | 18 + .../rerank/RerankCreateV1ResponseTest.kt | 18 + .../rerank/RerankCreateV2ResponseTest.kt | 18 + .../responses/ResponseCreateResponseTest.kt | 18 + .../responses/ResponseDeleteResponseTest.kt | 18 + .../responses/ResponseRetrieveResponseTest.kt | 18 + .../inputitems/InputItemListResponseTest.kt | 18 + .../models/routes/RouteListResponseTest.kt | 18 + .../settings/SettingRetrieveResponseTest.kt | 18 + .../spend/SpendCalculateSpendResponseTest.kt | 18 + .../models/spend/SpendListLogsResponseTest.kt | 38 +++ .../models/spend/SpendListTagsResponseTest.kt | 38 +++ .../api/models/team/BlockTeamRequestTest.kt | 17 + .../ai/hanzo/api/models/team/MemberTest.kt | 19 ++ .../models/team/TeamAddMemberResponseTest.kt | 112 ++++++ .../api/models/team/TeamBlockResponseTest.kt | 18 + .../api/models/team/TeamCreateResponseTest.kt | 50 +++ .../api/models/team/TeamDeleteResponseTest.kt | 18 + .../team/TeamDisableLoggingResponseTest.kt | 18 + .../team/TeamListAvailableResponseTest.kt | 18 + .../api/models/team/TeamListResponseTest.kt | 18 + .../team/TeamRemoveMemberResponseTest.kt | 18 + .../team/TeamRetrieveInfoResponseTest.kt | 18 + .../models/team/TeamUnblockResponseTest.kt | 18 + .../team/TeamUpdateMemberResponseTest.kt | 23 ++ .../api/models/team/TeamUpdateResponseTest.kt | 18 + .../team/callback/CallbackAddResponseTest.kt | 18 + .../callback/CallbackRetrieveResponseTest.kt | 18 + .../models/team/model/ModelAddResponseTest.kt | 18 + .../team/model/ModelRemoveResponseTest.kt | 18 + .../api/models/test/TestPingResponseTest.kt | 18 + .../threads/ThreadCreateResponseTest.kt | 18 + .../threads/ThreadRetrieveResponseTest.kt | 18 + .../messages/MessageCreateResponseTest.kt | 18 + .../messages/MessageListResponseTest.kt | 18 + .../threads/runs/RunCreateResponseTest.kt | 18 + .../api/models/user/UserCreateResponseTest.kt | 55 +++ .../api/models/user/UserDeleteResponseTest.kt | 18 + .../api/models/user/UserListResponseTest.kt | 18 + .../user/UserRetrieveInfoResponseTest.kt | 18 + .../api/models/user/UserUpdateResponseTest.kt | 18 + ...tilGetSupportedOpenAIParamsResponseTest.kt | 20 ++ .../utils/UtilTokenCounterResponseTest.kt | 23 ++ .../utils/UtilTransformRequestResponseTest.kt | 23 ++ .../vertexai/VertexAiCreateResponseTest.kt | 18 + .../vertexai/VertexAiDeleteResponseTest.kt | 18 + .../vertexai/VertexAiPatchResponseTest.kt | 18 + .../vertexai/VertexAiRetrieveResponseTest.kt | 18 + .../vertexai/VertexAiUpdateResponseTest.kt | 18 + 440 files changed, 12734 insertions(+), 484 deletions(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt index 3fa98c82..e05d3136 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/BaseDeserializer.kt @@ -1,6 +1,5 @@ package ai.hanzo.api.core -import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.core.type.TypeReference @@ -8,7 +7,6 @@ import com.fasterxml.jackson.databind.BeanProperty import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer @@ -30,38 +28,17 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.deserialize(node: JsonNode, type: TypeReference): T = + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = try { readValue(treeAsTokens(node), type) } catch (e: Exception) { - throw HanzoInvalidDataException("Error deserializing", e) - } - - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {}, - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { null } - } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {}, - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt index 5348d056..57ae1e24 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt @@ -25,6 +25,34 @@ internal fun , V> SortedMap.toImmutable(): SortedMap> Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + /** * Returns whether [this] is equal to [other]. * diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt index e2bca59d..6816f8bc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt index b08c879e..2dab938a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt index 49f7b11a..5d50d7fd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap) : Enum { @@ -458,6 +481,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AllowedModelRegion = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -837,6 +887,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt index 9c02a8ea..54873e55 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt @@ -362,13 +362,36 @@ private constructor( blocked() userId() alias() - allowedModelRegion() + allowedModelRegion().ifPresent { it.validate() } defaultModel() llmBudgetTable().ifPresent { it.validate() } spend() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (alias.asKnown().isPresent) 1 else 0) + + (allowedModelRegion.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultModel.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + class AllowedModelRegion @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -458,6 +481,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AllowedModelRegion = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -837,6 +887,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt index 11cd2864..da1d884d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) integer != null -> visitor.visitInteger(integer) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1290,6 +1362,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1345,14 +1443,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): BatchSize { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return BatchSize(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return BatchSize(integer = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BatchSize(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BatchSize(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> BatchSize(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return BatchSize(_json = json) } } @@ -1396,13 +1508,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1421,6 +1532,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1477,14 +1614,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): LearningRateMultiplier { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return LearningRateMultiplier(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return LearningRateMultiplier(number = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + LearningRateMultiplier(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + LearningRateMultiplier(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> LearningRateMultiplier(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return LearningRateMultiplier(_json = json) } } @@ -1529,13 +1680,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) integer != null -> visitor.visitInteger(integer) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1554,6 +1704,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1609,14 +1785,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): NEpochs { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return NEpochs(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + NEpochs(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + NEpochs(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> NEpochs(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return NEpochs(integer = it, _json = json) - } - - return NEpochs(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt index 5a6c64de..0231974a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -852,6 +885,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -907,14 +966,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(offsetDate = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> EndTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndTime(_json = json) } } @@ -965,14 +1038,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -993,6 +1065,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1053,17 +1153,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Messages { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Messages(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Messages(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Messages(jsonValues = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(jsonValue = it, _json = json) - } - - return Messages(_json = json) } } @@ -1115,14 +1229,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1143,6 +1256,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1203,17 +1344,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Response { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Response(jsonValues = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Response(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Response(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Response(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Response(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(jsonValue = it, _json = json) - } - - return Response(_json = json) } } @@ -1258,13 +1413,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1283,6 +1437,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1338,14 +1518,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> StartTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(offsetDate = it, _json = json) - } - - return StartTime(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt index 6a68750f..ae399cac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.global.spend import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -852,6 +885,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -907,14 +966,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(offsetDate = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> EndTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndTime(_json = json) } } @@ -965,14 +1038,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -993,6 +1065,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1053,17 +1153,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Messages { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Messages(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Messages(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Messages(jsonValues = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(jsonValue = it, _json = json) - } - - return Messages(_json = json) } } @@ -1115,14 +1229,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1143,6 +1256,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1203,17 +1344,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Response { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Response(jsonValues = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Response(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Response(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Response(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Response(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(jsonValue = it, _json = json) - } - - return Response(_json = json) } } @@ -1258,13 +1413,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1283,6 +1437,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1338,14 +1518,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> StartTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(offsetDate = it, _json = json) - } - - return StartTime(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt index 2e29ea9b..98caef87 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt @@ -8,6 +8,7 @@ import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow @@ -27,6 +28,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull class GuardrailListResponse private constructor( @@ -167,6 +169,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (guardrails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Guardrail private constructor( private val guardrailInfo: JsonValue, @@ -351,6 +370,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (guardrailName.asKnown().isPresent) 1 else 0) + + (llmParams.asKnown().getOrNull()?.validity() ?: 0) + /** The returned LLM Params object for /guardrails/list */ class LlmParams private constructor( @@ -557,6 +595,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (guardrail.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultOn.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Mode.Deserializer::class) @JsonSerialize(using = Mode.Serializer::class) class Mode @@ -580,13 +638,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) strings != null -> visitor.visitStrings(strings) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -605,6 +662,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -660,14 +743,29 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Mode { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Mode(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Mode(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Mode(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Mode(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Mode(strings = it, _json = json) - } - - return Mode(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt index 122661e9..4826f08d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1099,6 +1137,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1155,14 +1219,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Expires { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Expires(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(offsetDateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Expires(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Expires(offsetDateTime = it, _json = json) - } - - return Expires(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt index 2528c31f..a482ec79 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt @@ -159,11 +159,29 @@ private constructor( return@apply } - key() + key().ifPresent { it.validate() } loggingCallbacks().ifPresent { it.validate() } validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (key.asKnown().getOrNull()?.validity() ?: 0) + + (loggingCallbacks.asKnown().getOrNull()?.validity() ?: 0) + class Key @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -248,6 +266,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Key = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -446,10 +491,30 @@ private constructor( callbacks() details() - status() + status().ifPresent { it.validate() } validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (callbacks.asKnown().getOrNull()?.size ?: 0) + + (if (details.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -539,6 +604,33 @@ private constructor( HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt index c78007c0..9bf6a088 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt @@ -483,6 +483,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (keyAliases.asKnown().getOrNull()?.size ?: 0) + (keys.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt index 32548cac..259a9ebf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) userApiKeyAuth != null -> visitor.visitUserApiKeyAuth(userApiKeyAuth) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -326,6 +346,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUserApiKeyAuth(userApiKeyAuth: UserApiKeyAuth) = + userApiKeyAuth.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -381,15 +428,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Key { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Key(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Key(userApiKeyAuth = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Key(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Key(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Key(userApiKeyAuth = it, _json = json) - } - - return Key(_json = json) } } @@ -2625,7 +2685,7 @@ private constructor( token() allowedCacheControls() - allowedModelRegion() + allowedModelRegion().ifPresent { it.validate() } apiKey() blocked() budgetDuration() @@ -2665,12 +2725,74 @@ private constructor( updatedBy() userEmail() userId() - userRole() + userRole().ifPresent { it.validate() } userRpmLimit() userTpmLimit() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedModelRegion.asKnown().getOrNull()?.validity() ?: 0) + + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (endUserId.asKnown().isPresent) 1 else 0) + + (if (endUserMaxBudget.asKnown().isPresent) 1 else 0) + + (if (endUserRpmLimit.asKnown().isPresent) 1 else 0) + + (if (endUserTpmLimit.asKnown().isPresent) 1 else 0) + + (expires.asKnown().getOrNull()?.validity() ?: 0) + + (if (keyAlias.asKnown().isPresent) 1 else 0) + + (if (keyName.asKnown().isPresent) 1 else 0) + + (if (lastRefreshedAt.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (orgId.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (rpmLimitPerModel.asKnown().getOrNull()?.validity() ?: 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (softBudgetCooldown.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (teamAlias.asKnown().isPresent) 1 else 0) + + (if (teamBlocked.asKnown().isPresent) 1 else 0) + + (if (teamId.asKnown().isPresent) 1 else 0) + + (if (teamMaxBudget.asKnown().isPresent) 1 else 0) + + (teamMember.asKnown().getOrNull()?.validity() ?: 0) + + (if (teamMemberSpend.asKnown().isPresent) 1 else 0) + + (teamModels.asKnown().getOrNull()?.size ?: 0) + + (if (teamRpmLimit.asKnown().isPresent) 1 else 0) + + (if (teamSpend.asKnown().isPresent) 1 else 0) + + (if (teamTpmLimit.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (tpmLimitPerModel.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (if (userEmail.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (userRole.asKnown().getOrNull()?.validity() ?: 0) + + (if (userRpmLimit.asKnown().isPresent) 1 else 0) + + (if (userTpmLimit.asKnown().isPresent) 1 else 0) + class AllowedModelRegion @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2766,6 +2888,33 @@ private constructor( HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): AllowedModelRegion = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2802,13 +2951,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2827,6 +2975,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2884,14 +3058,29 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Expires { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Expires(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(offsetDateTime = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Expires(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Expires(offsetDateTime = it, _json = json) - } - - return Expires(_json = json) } } @@ -2985,6 +3174,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3075,6 +3284,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3227,6 +3456,33 @@ private constructor( HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): UserRole = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt index 5f2f1511..a32c2fb4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) paramsCustomAuth != null -> visitor.visitParamsCustomAuth(paramsCustomAuth) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2085,6 +2154,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitParamsCustomAuth( + paramsCustomAuth: ConfigurableClientsideParamsCustomAuth + ) = paramsCustomAuth.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2154,20 +2251,35 @@ private constructor( ): ConfigurableClientsideAuthParam { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ConfigurableClientsideAuthParam(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ConfigurableClientsideAuthParam( - paramsCustomAuth = it, - _json = json, + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ConfigurableClientsideAuthParam( + paramsCustomAuth = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ConfigurableClientsideAuthParam(string = it, _json = json) + }, ) - } - - return ConfigurableClientsideAuthParam(_json = json) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from array). + 0 -> ConfigurableClientsideAuthParam(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } } @@ -2216,13 +2328,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { number != null -> visitor.visitNumber(number) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2241,6 +2352,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2296,14 +2433,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StreamTimeout { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StreamTimeout(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return StreamTimeout(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StreamTimeout(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StreamTimeout(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StreamTimeout(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return StreamTimeout(_json = json) } } @@ -2347,13 +2498,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { number != null -> visitor.visitNumber(number) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2372,6 +2522,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2427,14 +2603,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Timeout { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Timeout(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Timeout(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Timeout(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Timeout(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Timeout(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return Timeout(_json = json) } } @@ -2478,13 +2668,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2503,6 +2692,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2560,14 +2775,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): VertexCredentials { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return VertexCredentials(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return VertexCredentials(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + VertexCredentials(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VertexCredentials(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants. + 0 -> VertexCredentials(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return VertexCredentials(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt index 79d1c002..4491bf4f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.model import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap) : Enum { /** @@ -551,6 +577,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt index 44a77dfb..081c93c1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.model.info import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap, @@ -1711,6 +1731,55 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (apiBase.asKnown().isPresent) 1 else 0) + + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (apiVersion.asKnown().isPresent) 1 else 0) + + (if (awsAccessKeyId.asKnown().isPresent) 1 else 0) + + (if (awsRegionName.asKnown().isPresent) 1 else 0) + + (if (awsSecretAccessKey.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (configurableClientsideAuthParams.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (customLlmProvider.asKnown().isPresent) 1 else 0) + + (if (inputCostPerSecond.asKnown().isPresent) 1 else 0) + + (if (inputCostPerToken.asKnown().isPresent) 1 else 0) + + (if (llmTraceId.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxFileSizeMb.asKnown().isPresent) 1 else 0) + + (if (maxRetries.asKnown().isPresent) 1 else 0) + + (if (mergeReasoningContentInChoices.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (organization.asKnown().isPresent) 1 else 0) + + (if (outputCostPerSecond.asKnown().isPresent) 1 else 0) + + (if (outputCostPerToken.asKnown().isPresent) 1 else 0) + + (if (regionName.asKnown().isPresent) 1 else 0) + + (if (rpm.asKnown().isPresent) 1 else 0) + + (streamTimeout.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (if (tpm.asKnown().isPresent) 1 else 0) + + (if (useInPassThrough.asKnown().isPresent) 1 else 0) + + (vertexCredentials.asKnown().getOrNull()?.validity() ?: 0) + + (if (vertexLocation.asKnown().isPresent) 1 else 0) + + (if (vertexProject.asKnown().isPresent) 1 else 0) + + (if (watsonxRegionName.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = ConfigurableClientsideAuthParam.Deserializer::class) @JsonSerialize(using = ConfigurableClientsideAuthParam.Serializer::class) class ConfigurableClientsideAuthParam @@ -1736,13 +1805,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) paramsCustomAuth != null -> visitor.visitParamsCustomAuth(paramsCustomAuth) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1765,6 +1833,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitParamsCustomAuth( + paramsCustomAuth: ConfigurableClientsideParamsCustomAuth + ) = paramsCustomAuth.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1834,20 +1930,35 @@ private constructor( ): ConfigurableClientsideAuthParam { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ConfigurableClientsideAuthParam(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ConfigurableClientsideAuthParam( - paramsCustomAuth = it, - _json = json, + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ConfigurableClientsideAuthParam( + paramsCustomAuth = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ConfigurableClientsideAuthParam(string = it, _json = json) + }, ) - } - - return ConfigurableClientsideAuthParam(_json = json) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from array). + 0 -> ConfigurableClientsideAuthParam(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } } @@ -1896,13 +2007,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { number != null -> visitor.visitNumber(number) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1921,6 +2031,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1976,14 +2112,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StreamTimeout { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StreamTimeout(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return StreamTimeout(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StreamTimeout(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StreamTimeout(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> StreamTimeout(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return StreamTimeout(_json = json) } } @@ -2027,13 +2177,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { number != null -> visitor.visitNumber(number) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2052,6 +2201,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2107,14 +2282,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Timeout { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Timeout(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Timeout(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Timeout(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Timeout(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Timeout(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return Timeout(_json = json) } } @@ -2158,13 +2347,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2183,6 +2371,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2240,14 +2454,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): VertexCredentials { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return VertexCredentials(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return VertexCredentials(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + VertexCredentials(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VertexCredentials(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants. + 0 -> VertexCredentials(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return VertexCredentials(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt index 35fe30db..20277a56 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.model.update import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap) : Enum { /** @@ -293,6 +312,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt index fbca8453..4722c4ac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt @@ -9,6 +9,7 @@ import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers @@ -575,6 +576,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (member.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (maxBudgetInOrganization.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -616,13 +637,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { orgMembers != null -> visitor.visitOrgMembers(orgMembers) org != null -> visitor.visitOrg(org) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -645,6 +665,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitOrgMembers(orgMembers: List) = + orgMembers.sumOf { it.validity().toInt() } + + override fun visitOrg(org: OrgMember) = org.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -698,18 +745,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Member { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Member(orgMembers = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Member(org = it, _json = json) - } - - return Member(_json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Member(org = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Member(orgMembers = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Member(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt index b793015c..b74747cb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt @@ -266,6 +266,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (organizationId.asKnown().isPresent) 1 else 0) + + (updatedOrganizationMemberships.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (updatedUsers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** * This is the table that track what organizations a user belongs to and users spend within the * organization @@ -676,6 +696,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -1060,6 +1105,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1768,6 +1836,37 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (organizationMemberships.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (ssoUserId.asKnown().isPresent) 1 else 0) + + (teams.asKnown().getOrNull()?.size ?: 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (if (userEmail.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** * This is the table that track what organizations a user belongs to and users spend within * the organization @@ -2194,6 +2293,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -2591,6 +2715,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt index fdee9bfb..98388849 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt @@ -1156,6 +1156,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (organizationAlias.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt index aae8c497..11ef8d7d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt @@ -453,6 +453,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (if (organizationAlias.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt index da36281b..09cbf528 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt @@ -483,6 +483,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (userEmail.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt index bbf45834..b83e98ce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -86,6 +87,21 @@ private constructor(private val additionalProperties: MutableMap, @@ -2910,6 +3045,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (modelAliases.asKnown().getOrNull()?.validity() ?: 0) + @JsonDeserialize(using = ModelAliases.Deserializer::class) @JsonSerialize(using = ModelAliases.Serializer::class) class ModelAliases @@ -2933,13 +3088,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2958,6 +3112,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3014,14 +3194,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ModelAliases { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> ModelAliases(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return ModelAliases(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt index da525bcc..d39d56d1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt @@ -8,6 +8,7 @@ import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow @@ -605,6 +606,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (members.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (organizationAlias.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (teams.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -971,6 +1000,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1396,6 +1448,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -1780,6 +1857,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2692,6 +2792,41 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (teamId.asKnown().isPresent) 1 else 0) + + (admins.asKnown().getOrNull()?.size ?: 0) + + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (llmModelTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (members.asKnown().getOrNull()?.size ?: 0) + + (membersWithRoles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modelId.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (teamAlias.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + class LlmModelTable private constructor( private val createdBy: JsonField, @@ -2910,6 +3045,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (modelAliases.asKnown().getOrNull()?.validity() ?: 0) + @JsonDeserialize(using = ModelAliases.Deserializer::class) @JsonSerialize(using = ModelAliases.Serializer::class) class ModelAliases @@ -2933,13 +3088,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2958,6 +3112,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3014,14 +3194,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ModelAliases { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> ModelAliases(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return ModelAliases(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt index 22faddbf..06d23f14 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt @@ -682,12 +682,34 @@ private constructor( organizationId() maxBudgetInOrganization() - role() + role().ifPresent { it.validate() } userEmail() userId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (maxBudgetInOrganization.asKnown().isPresent) 1 else 0) + + (role.asKnown().getOrNull()?.validity() ?: 0) + + (if (userEmail.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -832,6 +854,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt index 9fcd1555..70b27716 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt @@ -413,6 +413,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -779,6 +803,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt index aa32a88d..c41de8f8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt @@ -725,6 +725,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetId.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (organizationAlias.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt index d1cff943..f1d3b100 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt @@ -8,6 +8,7 @@ import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow @@ -605,6 +606,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (members.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (organizationAlias.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (teams.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -971,6 +1000,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1396,6 +1448,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -1780,6 +1857,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2692,6 +2792,41 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (teamId.asKnown().isPresent) 1 else 0) + + (admins.asKnown().getOrNull()?.size ?: 0) + + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (llmModelTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (members.asKnown().getOrNull()?.size ?: 0) + + (membersWithRoles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modelId.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (teamAlias.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + class LlmModelTable private constructor( private val createdBy: JsonField, @@ -2910,6 +3045,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (modelAliases.asKnown().getOrNull()?.validity() ?: 0) + @JsonDeserialize(using = ModelAliases.Deserializer::class) @JsonSerialize(using = ModelAliases.Serializer::class) class ModelAliases @@ -2933,13 +3088,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2958,6 +3112,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3014,14 +3194,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ModelAliases { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> ModelAliases(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return ModelAliases(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt index ce491931..f3bcde2e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull /** DEPRECATED: Use GET /organization/info instead */ class InfoDeprecatedParams @@ -380,6 +381,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (organizations.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt index 3c3d274f..ef272831 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.organization.info import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap, @@ -2910,6 +3045,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (modelAliases.asKnown().getOrNull()?.validity() ?: 0) + @JsonDeserialize(using = ModelAliases.Deserializer::class) @JsonSerialize(using = ModelAliases.Serializer::class) class ModelAliases @@ -2933,13 +3088,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2958,6 +3112,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3014,14 +3194,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ModelAliases { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> ModelAliases(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return ModelAliases(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt index ca20ceb6..a825c525 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Complete provider budget configuration and status. Maps provider names to their budget configs. @@ -127,6 +128,21 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (providers.asKnown().getOrNull()?.validity() ?: 0) + class Providers @JsonCreator private constructor( @@ -193,6 +209,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt index b4f28a90..0d112114 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.rerank import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -81,6 +82,21 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -852,6 +885,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -907,14 +966,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(offsetDate = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> EndTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndTime(_json = json) } } @@ -965,14 +1038,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -993,6 +1065,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1053,17 +1153,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Messages { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Messages(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Messages(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Messages(jsonValues = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(jsonValue = it, _json = json) - } - - return Messages(_json = json) } } @@ -1115,14 +1229,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1143,6 +1256,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1203,17 +1344,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Response { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Response(jsonValues = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Response(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Response(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Response(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Response(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(jsonValue = it, _json = json) - } - - return Response(_json = json) } } @@ -1258,13 +1413,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1283,6 +1437,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1338,14 +1518,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> StartTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(offsetDate = it, _json = json) - } - - return StartTime(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt index ab14b5ac..5a01976c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt @@ -8,6 +8,7 @@ import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.errors.HanzoInvalidDataException @@ -804,6 +805,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (callType.asKnown().isPresent) 1 else 0) + + (endTime.asKnown().getOrNull()?.validity() ?: 0) + + (messages.asKnown().getOrNull()?.validity() ?: 0) + + (if (requestId.asKnown().isPresent) 1 else 0) + + (response.asKnown().getOrNull()?.validity() ?: 0) + + (startTime.asKnown().getOrNull()?.validity() ?: 0) + + (if (apiBase.asKnown().isPresent) 1 else 0) + + (if (cacheHit.asKnown().isPresent) 1 else 0) + + (if (cacheKey.asKnown().isPresent) 1 else 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (requesterIpAddress.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (user.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = EndTime.Deserializer::class) @JsonSerialize(using = EndTime.Serializer::class) class EndTime @@ -827,13 +861,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -852,6 +885,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -907,14 +966,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): EndTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return EndTime(offsetDate = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> EndTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return EndTime(_json = json) } } @@ -965,14 +1038,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -993,6 +1065,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1053,17 +1153,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Messages { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Messages(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Messages(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Messages(jsonValues = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Messages(jsonValue = it, _json = json) - } - - return Messages(_json = json) } } @@ -1115,14 +1229,13 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) jsonValue != null -> visitor.visitJsonValue(jsonValue) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1143,6 +1256,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1203,17 +1344,31 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Response { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Response(jsonValues = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Response(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Response(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Response(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Response(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Response(jsonValue = it, _json = json) - } - - return Response(_json = json) } } @@ -1258,13 +1413,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { string != null -> visitor.visitString(string) offsetDate != null -> visitor.visitOffsetDate(offsetDate) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1283,6 +1437,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDate(offsetDate: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1338,14 +1518,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): StartTime { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(offsetDate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> StartTime(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return StartTime(offsetDate = it, _json = json) - } - - return StartTime(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt index 23ebe5be..81c214c3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt @@ -132,6 +132,21 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (teamId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt index 9a552bf2..b516b7b1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt @@ -197,12 +197,31 @@ private constructor( return@apply } - role() + role().validate() userEmail() userId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (role.asKnown().getOrNull()?.validity() ?: 0) + + (if (userEmail.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + class Role @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -287,6 +306,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt index 09c4246b..fda9ecf0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt @@ -9,6 +9,7 @@ import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers @@ -533,6 +534,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (member.asKnown().getOrNull()?.validity() ?: 0) + + (if (teamId.asKnown().isPresent) 1 else 0) + + (if (maxBudgetInTeam.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -574,13 +595,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { members != null -> visitor.visitMembers(members) member != null -> visitor.visitMember(member) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -603,6 +623,33 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMembers(members: List) = + members.sumOf { it.validity().toInt() } + + override fun visitMember(member: Member) = member.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -655,18 +702,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Member { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Member(members = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Member(member = it, _json = json) - } - - return Member(_json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Member(member = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Member(members = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Member(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt index 9410c6ad..b4a9c9ad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt @@ -8,6 +8,7 @@ import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow @@ -995,6 +996,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (teamId.asKnown().isPresent) 1 else 0) + + (updatedTeamMemberships.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (updatedUsers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (admins.asKnown().getOrNull()?.size ?: 0) + + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (llmModelTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (members.asKnown().getOrNull()?.size ?: 0) + + (membersWithRoles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modelId.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (teamAlias.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + class UpdatedTeamMembership private constructor( private val budgetId: JsonField, @@ -1230,6 +1267,27 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (teamId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -1614,6 +1672,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2322,6 +2403,37 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (organizationMemberships.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (ssoUserId.asKnown().isPresent) 1 else 0) + + (teams.asKnown().getOrNull()?.size ?: 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (if (userEmail.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** * This is the table that track what organizations a user belongs to and users spend within * the organization @@ -2748,6 +2860,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (budgetId.asKnown().isPresent) 1 else 0) + + (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (userRole.asKnown().isPresent) 1 else 0) + /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable private constructor( @@ -3145,6 +3282,29 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3406,6 +3566,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (modelAliases.asKnown().getOrNull()?.validity() ?: 0) + @JsonDeserialize(using = ModelAliases.Deserializer::class) @JsonSerialize(using = ModelAliases.Serializer::class) class ModelAliases @@ -3429,13 +3609,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -3454,6 +3633,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3510,14 +3715,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ModelAliases { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(jsonValue = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants. + 0 -> ModelAliases(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(string = it, _json = json) - } - - return ModelAliases(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt index 41053064..dddfb588 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap, @@ -1093,6 +1128,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (modelAliases.asKnown().getOrNull()?.validity() ?: 0) + @JsonDeserialize(using = ModelAliases.Deserializer::class) @JsonSerialize(using = ModelAliases.Serializer::class) class ModelAliases @@ -1116,13 +1171,12 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { jsonValue != null -> visitor.visitJsonValue(jsonValue) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -1141,6 +1195,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1197,14 +1277,28 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ModelAliases { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(jsonValue = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ModelAliases(string = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelAliases(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants. + 0 -> ModelAliases(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - - return ModelAliases(_json = json) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt index a636ae45..fc00a6f3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt @@ -412,6 +412,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (teamIds.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt index d36ff518..4b699ed0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -774,6 +812,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): CallbackType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt index 64e44d4c..f0c045ff 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.team.callback import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap) : Enum { /** @@ -1415,6 +1459,33 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): UserRole = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt index 510179f1..b18a6de7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt @@ -415,6 +415,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (userIds.asKnown().getOrNull()?.size ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt index f591ec57..1225b9b3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -80,6 +81,21 @@ private constructor(private val additionalProperties: MutableMap(), + ) + + assertThat(roundtrippedClientGetHomeResponse).isEqualTo(clientGetHomeResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt index 333bdb39..42ebf703 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.active +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ActiveListCallbacksResponseTest { fun create() { val activeListCallbacksResponse = ActiveListCallbacksResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val activeListCallbacksResponse = ActiveListCallbacksResponse.builder().build() + + val roundtrippedActiveListCallbacksResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(activeListCallbacksResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedActiveListCallbacksResponse).isEqualTo(activeListCallbacksResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt index 339d2161..16bcaa0f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.add +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AddAddAllowedIpResponseTest { fun create() { val addAddAllowedIpResponse = AddAddAllowedIpResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val addAddAllowedIpResponse = AddAddAllowedIpResponse.builder().build() + + val roundtrippedAddAddAllowedIpResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(addAddAllowedIpResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAddAddAllowedIpResponse).isEqualTo(addAddAllowedIpResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt index 74cfae0d..aa130f20 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.add +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -15,4 +17,19 @@ internal class IpAddressTest { assertThat(ipAddress.ip()).isEqualTo("ip") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ipAddress = IpAddress.builder().ip("ip").build() + + val roundtrippedIpAddress = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ipAddress), + jacksonTypeRef(), + ) + + assertThat(roundtrippedIpAddress).isEqualTo(ipAddress) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt index d9ee7669..62f8306c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.anthropic +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AnthropicCreateResponseTest { fun create() { val anthropicCreateResponse = AnthropicCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val anthropicCreateResponse = AnthropicCreateResponse.builder().build() + + val roundtrippedAnthropicCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(anthropicCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAnthropicCreateResponse).isEqualTo(anthropicCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt index 658ed7cf..e301e467 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.anthropic +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AnthropicDeleteResponseTest { fun create() { val anthropicDeleteResponse = AnthropicDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val anthropicDeleteResponse = AnthropicDeleteResponse.builder().build() + + val roundtrippedAnthropicDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(anthropicDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAnthropicDeleteResponse).isEqualTo(anthropicDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt index 22913de1..b26090b8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.anthropic +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AnthropicModifyResponseTest { fun create() { val anthropicModifyResponse = AnthropicModifyResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val anthropicModifyResponse = AnthropicModifyResponse.builder().build() + + val roundtrippedAnthropicModifyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(anthropicModifyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAnthropicModifyResponse).isEqualTo(anthropicModifyResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt index d18ce895..7566ec72 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.anthropic +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AnthropicRetrieveResponseTest { fun create() { val anthropicRetrieveResponse = AnthropicRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val anthropicRetrieveResponse = AnthropicRetrieveResponse.builder().build() + + val roundtrippedAnthropicRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(anthropicRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAnthropicRetrieveResponse).isEqualTo(anthropicRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt index 92d224a3..ede46b08 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.anthropic +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AnthropicUpdateResponseTest { fun create() { val anthropicUpdateResponse = AnthropicUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val anthropicUpdateResponse = AnthropicUpdateResponse.builder().build() + + val roundtrippedAnthropicUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(anthropicUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAnthropicUpdateResponse).isEqualTo(anthropicUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt index 22e561a8..7e66c463 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssemblyaiCreateResponseTest { fun create() { val assemblyaiCreateResponse = AssemblyaiCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assemblyaiCreateResponse = AssemblyaiCreateResponse.builder().build() + + val roundtrippedAssemblyaiCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assemblyaiCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssemblyaiCreateResponse).isEqualTo(assemblyaiCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt index 8298b4db..e89584cc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssemblyaiDeleteResponseTest { fun create() { val assemblyaiDeleteResponse = AssemblyaiDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assemblyaiDeleteResponse = AssemblyaiDeleteResponse.builder().build() + + val roundtrippedAssemblyaiDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assemblyaiDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssemblyaiDeleteResponse).isEqualTo(assemblyaiDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt index 3435bf4d..c2043910 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssemblyaiPatchResponseTest { fun create() { val assemblyaiPatchResponse = AssemblyaiPatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assemblyaiPatchResponse = AssemblyaiPatchResponse.builder().build() + + val roundtrippedAssemblyaiPatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assemblyaiPatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssemblyaiPatchResponse).isEqualTo(assemblyaiPatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt index 1895a392..5c54a76e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssemblyaiRetrieveResponseTest { fun create() { val assemblyaiRetrieveResponse = AssemblyaiRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assemblyaiRetrieveResponse = AssemblyaiRetrieveResponse.builder().build() + + val roundtrippedAssemblyaiRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assemblyaiRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssemblyaiRetrieveResponse).isEqualTo(assemblyaiRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt index 824fb2e0..c23c537b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssemblyaiUpdateResponseTest { fun create() { val assemblyaiUpdateResponse = AssemblyaiUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assemblyaiUpdateResponse = AssemblyaiUpdateResponse.builder().build() + + val roundtrippedAssemblyaiUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assemblyaiUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssemblyaiUpdateResponse).isEqualTo(assemblyaiUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt index 88a229a8..afbac60f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assistants +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssistantCreateResponseTest { fun create() { val assistantCreateResponse = AssistantCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assistantCreateResponse = AssistantCreateResponse.builder().build() + + val roundtrippedAssistantCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assistantCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssistantCreateResponse).isEqualTo(assistantCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt index 76d9d360..dbfa59fd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assistants +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssistantDeleteResponseTest { fun create() { val assistantDeleteResponse = AssistantDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assistantDeleteResponse = AssistantDeleteResponse.builder().build() + + val roundtrippedAssistantDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assistantDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssistantDeleteResponse).isEqualTo(assistantDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt index a6afa4a9..779c4ff2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.assistants +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AssistantListResponseTest { fun create() { val assistantListResponse = AssistantListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val assistantListResponse = AssistantListResponse.builder().build() + + val roundtrippedAssistantListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assistantListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssistantListResponse).isEqualTo(assistantListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt index 3071a804..39b554c0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.audio.speech +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class SpeechCreateResponseTest { fun create() { val speechCreateResponse = SpeechCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val speechCreateResponse = SpeechCreateResponse.builder().build() + + val roundtrippedSpeechCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(speechCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpeechCreateResponse).isEqualTo(speechCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt index 0ede1b29..95ec0c93 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.audio.transcriptions +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TranscriptionCreateResponseTest { fun create() { val transcriptionCreateResponse = TranscriptionCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val transcriptionCreateResponse = TranscriptionCreateResponse.builder().build() + + val roundtrippedTranscriptionCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(transcriptionCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTranscriptionCreateResponse).isEqualTo(transcriptionCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt index 09e9edc1..2618e945 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.azure +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AzureCallResponseTest { fun create() { val azureCallResponse = AzureCallResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val azureCallResponse = AzureCallResponse.builder().build() + + val roundtrippedAzureCallResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(azureCallResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAzureCallResponse).isEqualTo(azureCallResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt index 4de8f2a3..36f1acbe 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.azure +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AzureCreateResponseTest { fun create() { val azureCreateResponse = AzureCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val azureCreateResponse = AzureCreateResponse.builder().build() + + val roundtrippedAzureCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(azureCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAzureCreateResponse).isEqualTo(azureCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt index b277cd51..8dd48cc4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.azure +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AzureDeleteResponseTest { fun create() { val azureDeleteResponse = AzureDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val azureDeleteResponse = AzureDeleteResponse.builder().build() + + val roundtrippedAzureDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(azureDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAzureDeleteResponse).isEqualTo(azureDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt index 178fa42e..b8572149 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.azure +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AzurePatchResponseTest { fun create() { val azurePatchResponse = AzurePatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val azurePatchResponse = AzurePatchResponse.builder().build() + + val roundtrippedAzurePatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(azurePatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAzurePatchResponse).isEqualTo(azurePatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt index beda00f0..5ff8d738 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.azure +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class AzureUpdateResponseTest { fun create() { val azureUpdateResponse = AzureUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val azureUpdateResponse = AzureUpdateResponse.builder().build() + + val roundtrippedAzureUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(azureUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAzureUpdateResponse).isEqualTo(azureUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt index 6ab92a7e..dd5691a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class BatchCancelWithProviderResponseTest { fun create() { val batchCancelWithProviderResponse = BatchCancelWithProviderResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchCancelWithProviderResponse = BatchCancelWithProviderResponse.builder().build() + + val roundtrippedBatchCancelWithProviderResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchCancelWithProviderResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchCancelWithProviderResponse) + .isEqualTo(batchCancelWithProviderResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt index e0d9dd4c..b1a818dc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BatchCreateResponseTest { fun create() { val batchCreateResponse = BatchCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchCreateResponse = BatchCreateResponse.builder().build() + + val roundtrippedBatchCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchCreateResponse).isEqualTo(batchCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt index a16c7173..cf443fe0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class BatchCreateWithProviderResponseTest { fun create() { val batchCreateWithProviderResponse = BatchCreateWithProviderResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchCreateWithProviderResponse = BatchCreateWithProviderResponse.builder().build() + + val roundtrippedBatchCreateWithProviderResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchCreateWithProviderResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchCreateWithProviderResponse) + .isEqualTo(batchCreateWithProviderResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt index b56d5824..b51a6e80 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BatchListResponseTest { fun create() { val batchListResponse = BatchListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchListResponse = BatchListResponse.builder().build() + + val roundtrippedBatchListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchListResponse).isEqualTo(batchListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt index 461d67fe..3e4eac95 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class BatchListWithProviderResponseTest { fun create() { val batchListWithProviderResponse = BatchListWithProviderResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchListWithProviderResponse = BatchListWithProviderResponse.builder().build() + + val roundtrippedBatchListWithProviderResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchListWithProviderResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchListWithProviderResponse) + .isEqualTo(batchListWithProviderResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt index 85e745bc..6e47e188 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BatchRetrieveResponseTest { fun create() { val batchRetrieveResponse = BatchRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchRetrieveResponse = BatchRetrieveResponse.builder().build() + + val roundtrippedBatchRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchRetrieveResponse).isEqualTo(batchRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt index 5344988a..973a8c38 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class BatchRetrieveWithProviderResponseTest { fun create() { val batchRetrieveWithProviderResponse = BatchRetrieveWithProviderResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchRetrieveWithProviderResponse = BatchRetrieveWithProviderResponse.builder().build() + + val roundtrippedBatchRetrieveWithProviderResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchRetrieveWithProviderResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchRetrieveWithProviderResponse) + .isEqualTo(batchRetrieveWithProviderResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt index c3fa9a61..4b5cc4a4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.batches.cancel +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CancelCancelResponseTest { fun create() { val cancelCancelResponse = CancelCancelResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cancelCancelResponse = CancelCancelResponse.builder().build() + + val roundtrippedCancelCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cancelCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCancelCancelResponse).isEqualTo(cancelCancelResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt index e81f5152..fc6c68e7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.bedrock +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BedrockCreateResponseTest { fun create() { val bedrockCreateResponse = BedrockCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bedrockCreateResponse = BedrockCreateResponse.builder().build() + + val roundtrippedBedrockCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bedrockCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBedrockCreateResponse).isEqualTo(bedrockCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt index 8c924685..479b0e33 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.bedrock +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BedrockDeleteResponseTest { fun create() { val bedrockDeleteResponse = BedrockDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bedrockDeleteResponse = BedrockDeleteResponse.builder().build() + + val roundtrippedBedrockDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bedrockDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBedrockDeleteResponse).isEqualTo(bedrockDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt index 79ccaed4..7c168e1a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.bedrock +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BedrockPatchResponseTest { fun create() { val bedrockPatchResponse = BedrockPatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bedrockPatchResponse = BedrockPatchResponse.builder().build() + + val roundtrippedBedrockPatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bedrockPatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBedrockPatchResponse).isEqualTo(bedrockPatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt index 2e21588e..83670b3c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.bedrock +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BedrockRetrieveResponseTest { fun create() { val bedrockRetrieveResponse = BedrockRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bedrockRetrieveResponse = BedrockRetrieveResponse.builder().build() + + val roundtrippedBedrockRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bedrockRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBedrockRetrieveResponse).isEqualTo(bedrockRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt index 0a649b96..c3720ef7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.bedrock +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BedrockUpdateResponseTest { fun create() { val bedrockUpdateResponse = BedrockUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bedrockUpdateResponse = BedrockUpdateResponse.builder().build() + + val roundtrippedBedrockUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bedrockUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBedrockUpdateResponse).isEqualTo(bedrockUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt index 761edae1..c46f36ac 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.budget +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BudgetCreateResponseTest { fun create() { val budgetCreateResponse = BudgetCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetCreateResponse = BudgetCreateResponse.builder().build() + + val roundtrippedBudgetCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetCreateResponse).isEqualTo(budgetCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt index cde1cec9..f50f667e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.budget +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BudgetDeleteResponseTest { fun create() { val budgetDeleteResponse = BudgetDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetDeleteResponse = BudgetDeleteResponse.builder().build() + + val roundtrippedBudgetDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetDeleteResponse).isEqualTo(budgetDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt index 1a6a6341..1b71fe07 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.budget +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BudgetInfoResponseTest { fun create() { val budgetInfoResponse = BudgetInfoResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetInfoResponse = BudgetInfoResponse.builder().build() + + val roundtrippedBudgetInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetInfoResponse).isEqualTo(budgetInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt index 34206ddf..58eabbdd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.budget +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BudgetListResponseTest { fun create() { val budgetListResponse = BudgetListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetListResponse = BudgetListResponse.builder().build() + + val roundtrippedBudgetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetListResponse).isEqualTo(budgetListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt index f615cd0e..a59c2b99 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -62,4 +64,43 @@ internal class BudgetNewTest { assertThat(budgetNew.softBudget()).contains(0.0) assertThat(budgetNew.tpmLimit()).contains(0L) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetNew = + BudgetNew.builder() + .budgetDuration("budget_duration") + .budgetId("budget_id") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget( + BudgetNew.ModelMaxBudget.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "budget_duration" to "budget_duration", + "max_budget" to 0, + "rpm_limit" to 0, + "tpm_limit" to 0, + ) + ), + ) + .build() + ) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + + val roundtrippedBudgetNew = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetNew), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetNew).isEqualTo(budgetNew) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt index 049e8004..a5e9ec98 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.budget +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BudgetSettingsResponseTest { fun create() { val budgetSettingsResponse = BudgetSettingsResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetSettingsResponse = BudgetSettingsResponse.builder().build() + + val roundtrippedBudgetSettingsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetSettingsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetSettingsResponse).isEqualTo(budgetSettingsResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt index 6166f846..91c6e602 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.budget +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class BudgetUpdateResponseTest { fun create() { val budgetUpdateResponse = BudgetUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val budgetUpdateResponse = BudgetUpdateResponse.builder().build() + + val roundtrippedBudgetUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(budgetUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBudgetUpdateResponse).isEqualTo(budgetUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt index 4d14a952..24aae08d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cache +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CacheDeleteResponseTest { fun create() { val cacheDeleteResponse = CacheDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cacheDeleteResponse = CacheDeleteResponse.builder().build() + + val roundtrippedCacheDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cacheDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCacheDeleteResponse).isEqualTo(cacheDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt index b1e40c63..8bf8a6b8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cache +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CacheFlushAllResponseTest { fun create() { val cacheFlushAllResponse = CacheFlushAllResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cacheFlushAllResponse = CacheFlushAllResponse.builder().build() + + val roundtrippedCacheFlushAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cacheFlushAllResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCacheFlushAllResponse).isEqualTo(cacheFlushAllResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt index 77dc50eb..97c8c1f6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.cache import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -30,4 +32,27 @@ internal class CachePingResponseTest { assertThat(cachePingResponse.pingResponse()).contains(true) assertThat(cachePingResponse.setCacheResponse()).contains("set_cache_response") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cachePingResponse = + CachePingResponse.builder() + .cacheType("cache_type") + .status("status") + .healthCheckCacheParams(JsonValue.from(mapOf())) + .llmCacheParams("llm_cache_params") + .pingResponse(true) + .setCacheResponse("set_cache_response") + .build() + + val roundtrippedCachePingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cachePingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCachePingResponse).isEqualTo(cachePingResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt index fe0f1f10..5f96e196 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cache.redis +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class RediRetrieveInfoResponseTest { fun create() { val rediRetrieveInfoResponse = RediRetrieveInfoResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rediRetrieveInfoResponse = RediRetrieveInfoResponse.builder().build() + + val roundtrippedRediRetrieveInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rediRetrieveInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRediRetrieveInfoResponse).isEqualTo(rediRetrieveInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt index ee48b90e..5b85e8c7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.chat.completions +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CompletionCreateResponseTest { fun create() { val completionCreateResponse = CompletionCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val completionCreateResponse = CompletionCreateResponse.builder().build() + + val roundtrippedCompletionCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(completionCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCompletionCreateResponse).isEqualTo(completionCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt index 90847951..453d137d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cohere +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CohereCreateResponseTest { fun create() { val cohereCreateResponse = CohereCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cohereCreateResponse = CohereCreateResponse.builder().build() + + val roundtrippedCohereCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cohereCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCohereCreateResponse).isEqualTo(cohereCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt index 354064b8..4f61df80 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cohere +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CohereDeleteResponseTest { fun create() { val cohereDeleteResponse = CohereDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cohereDeleteResponse = CohereDeleteResponse.builder().build() + + val roundtrippedCohereDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cohereDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCohereDeleteResponse).isEqualTo(cohereDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt index 8c7d706d..ca4a579d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cohere +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CohereModifyResponseTest { fun create() { val cohereModifyResponse = CohereModifyResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cohereModifyResponse = CohereModifyResponse.builder().build() + + val roundtrippedCohereModifyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cohereModifyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCohereModifyResponse).isEqualTo(cohereModifyResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt index 8af98da1..744772f5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cohere +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CohereRetrieveResponseTest { fun create() { val cohereRetrieveResponse = CohereRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cohereRetrieveResponse = CohereRetrieveResponse.builder().build() + + val roundtrippedCohereRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cohereRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCohereRetrieveResponse).isEqualTo(cohereRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt index 8b37173c..1431d318 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.cohere +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CohereUpdateResponseTest { fun create() { val cohereUpdateResponse = CohereUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cohereUpdateResponse = CohereUpdateResponse.builder().build() + + val roundtrippedCohereUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cohereUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCohereUpdateResponse).isEqualTo(cohereUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt index f6ba31fc..6b78081d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.completions +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CompletionCreateResponseTest { fun create() { val completionCreateResponse = CompletionCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val completionCreateResponse = CompletionCreateResponse.builder().build() + + val roundtrippedCompletionCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(completionCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCompletionCreateResponse).isEqualTo(completionCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt index 34f910e5..7487f419 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.config.passthroughendpoint +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class PassThroughEndpointCreateResponseTest { fun create() { val passThroughEndpointCreateResponse = PassThroughEndpointCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val passThroughEndpointCreateResponse = PassThroughEndpointCreateResponse.builder().build() + + val roundtrippedPassThroughEndpointCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(passThroughEndpointCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPassThroughEndpointCreateResponse) + .isEqualTo(passThroughEndpointCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt index 223e3c12..7578e3b2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -32,4 +34,28 @@ internal class PassThroughEndpointResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val passThroughEndpointResponse = + PassThroughEndpointResponse.builder() + .addEndpoint( + PassThroughGenericEndpoint.builder() + .headers(JsonValue.from(mapOf())) + .path("path") + .target("target") + .build() + ) + .build() + + val roundtrippedPassThroughEndpointResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(passThroughEndpointResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPassThroughEndpointResponse).isEqualTo(passThroughEndpointResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt index dbf757c7..da1bdddd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.config.passthroughendpoint +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class PassThroughEndpointUpdateResponseTest { fun create() { val passThroughEndpointUpdateResponse = PassThroughEndpointUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val passThroughEndpointUpdateResponse = PassThroughEndpointUpdateResponse.builder().build() + + val roundtrippedPassThroughEndpointUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(passThroughEndpointUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPassThroughEndpointUpdateResponse) + .isEqualTo(passThroughEndpointUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt index 67906fc6..5dddd67e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -24,4 +26,24 @@ internal class PassThroughGenericEndpointTest { assertThat(passThroughGenericEndpoint.path()).isEqualTo("path") assertThat(passThroughGenericEndpoint.target()).isEqualTo("target") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val passThroughGenericEndpoint = + PassThroughGenericEndpoint.builder() + .headers(JsonValue.from(mapOf())) + .path("path") + .target("target") + .build() + + val roundtrippedPassThroughGenericEndpoint = + jsonMapper.readValue( + jsonMapper.writeValueAsString(passThroughGenericEndpoint), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPassThroughGenericEndpoint).isEqualTo(passThroughGenericEndpoint) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt index 6dac6474..17265439 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.credentials +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CredentialCreateResponseTest { fun create() { val credentialCreateResponse = CredentialCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val credentialCreateResponse = CredentialCreateResponse.builder().build() + + val roundtrippedCredentialCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(credentialCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCredentialCreateResponse).isEqualTo(credentialCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt index 75a545ca..bed7a397 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.credentials +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CredentialDeleteResponseTest { fun create() { val credentialDeleteResponse = CredentialDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val credentialDeleteResponse = CredentialDeleteResponse.builder().build() + + val roundtrippedCredentialDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(credentialDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCredentialDeleteResponse).isEqualTo(credentialDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt index 218a4b57..c068778f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.credentials import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -24,4 +26,24 @@ internal class CredentialItemTest { assertThat(credentialItem._credentialValues()) .isEqualTo(JsonValue.from(mapOf())) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val credentialItem = + CredentialItem.builder() + .credentialInfo(JsonValue.from(mapOf())) + .credentialName("credential_name") + .credentialValues(JsonValue.from(mapOf())) + .build() + + val roundtrippedCredentialItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(credentialItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCredentialItem).isEqualTo(credentialItem) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt index 836d5436..6556a577 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.credentials +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CredentialListResponseTest { fun create() { val credentialListResponse = CredentialListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val credentialListResponse = CredentialListResponse.builder().build() + + val roundtrippedCredentialListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(credentialListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCredentialListResponse).isEqualTo(credentialListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt index e2179257..2359d2cb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.customer +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -15,4 +17,19 @@ internal class BlockUsersTest { assertThat(blockUsers.userIds()).containsExactly("string") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val blockUsers = BlockUsers.builder().addUserId("string").build() + + val roundtrippedBlockUsers = + jsonMapper.readValue( + jsonMapper.writeValueAsString(blockUsers), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBlockUsers).isEqualTo(blockUsers) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt index 83283e86..25d82bfc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.customer +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CustomerBlockResponseTest { fun create() { val customerBlockResponse = CustomerBlockResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerBlockResponse = CustomerBlockResponse.builder().build() + + val roundtrippedCustomerBlockResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerBlockResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerBlockResponse).isEqualTo(customerBlockResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt index a7b1d57c..4f0f5c4f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.customer +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CustomerCreateResponseTest { fun create() { val customerCreateResponse = CustomerCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerCreateResponse = CustomerCreateResponse.builder().build() + + val roundtrippedCustomerCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerCreateResponse).isEqualTo(customerCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt index 11dfc94d..e5736ebe 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.customer +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CustomerDeleteResponseTest { fun create() { val customerDeleteResponse = CustomerDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerDeleteResponse = CustomerDeleteResponse.builder().build() + + val roundtrippedCustomerDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerDeleteResponse).isEqualTo(customerDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt index 5bc5b567..930395c1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -53,4 +55,38 @@ internal class CustomerListResponseTest { ) assertThat(customerListResponse.spend()).contains(0.0) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerListResponse = + CustomerListResponse.builder() + .blocked(true) + .userId("user_id") + .alias("alias") + .allowedModelRegion(CustomerListResponse.AllowedModelRegion.EU) + .defaultModel("default_model") + .llmBudgetTable( + CustomerListResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .build() + + val roundtrippedCustomerListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerListResponse).isEqualTo(customerListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt index ca16401c..ca139011 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -53,4 +55,38 @@ internal class CustomerRetrieveInfoResponseTest { ) assertThat(customerRetrieveInfoResponse.spend()).contains(0.0) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerRetrieveInfoResponse = + CustomerRetrieveInfoResponse.builder() + .blocked(true) + .userId("user_id") + .alias("alias") + .allowedModelRegion(CustomerRetrieveInfoResponse.AllowedModelRegion.EU) + .defaultModel("default_model") + .llmBudgetTable( + CustomerRetrieveInfoResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .build() + + val roundtrippedCustomerRetrieveInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerRetrieveInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerRetrieveInfoResponse).isEqualTo(customerRetrieveInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt index ec642358..63c5ba75 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.customer +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CustomerUnblockResponseTest { fun create() { val customerUnblockResponse = CustomerUnblockResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerUnblockResponse = CustomerUnblockResponse.builder().build() + + val roundtrippedCustomerUnblockResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerUnblockResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerUnblockResponse).isEqualTo(customerUnblockResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt index 0d86195a..73e990c6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.customer +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CustomerUpdateResponseTest { fun create() { val customerUpdateResponse = CustomerUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerUpdateResponse = CustomerUpdateResponse.builder().build() + + val roundtrippedCustomerUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomerUpdateResponse).isEqualTo(customerUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt index e0dedfe5..e167e620 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.delete +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class DeleteCreateAllowedIpResponseTest { fun create() { val deleteCreateAllowedIpResponse = DeleteCreateAllowedIpResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val deleteCreateAllowedIpResponse = DeleteCreateAllowedIpResponse.builder().build() + + val roundtrippedDeleteCreateAllowedIpResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(deleteCreateAllowedIpResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDeleteCreateAllowedIpResponse) + .isEqualTo(deleteCreateAllowedIpResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt index 50fce8e6..95f874da 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.embeddings +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EmbeddingCreateResponseTest { fun create() { val embeddingCreateResponse = EmbeddingCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val embeddingCreateResponse = EmbeddingCreateResponse.builder().build() + + val roundtrippedEmbeddingCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(embeddingCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEmbeddingCreateResponse).isEqualTo(embeddingCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt index d3571972..2c6e2455 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.engines +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EngineCompleteResponseTest { fun create() { val engineCompleteResponse = EngineCompleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val engineCompleteResponse = EngineCompleteResponse.builder().build() + + val roundtrippedEngineCompleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(engineCompleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEngineCompleteResponse).isEqualTo(engineCompleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt index 40d32a84..09c432a6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.engines +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EngineEmbedResponseTest { fun create() { val engineEmbedResponse = EngineEmbedResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val engineEmbedResponse = EngineEmbedResponse.builder().build() + + val roundtrippedEngineEmbedResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(engineEmbedResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEngineEmbedResponse).isEqualTo(engineEmbedResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt index 43898776..5ac02a2f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.engines.chat +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ChatCompleteResponseTest { fun create() { val chatCompleteResponse = ChatCompleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val chatCompleteResponse = ChatCompleteResponse.builder().build() + + val roundtrippedChatCompleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(chatCompleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedChatCompleteResponse).isEqualTo(chatCompleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt index 8351a8a2..8583101d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.euassemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EuAssemblyaiCreateResponseTest { fun create() { val euAssemblyaiCreateResponse = EuAssemblyaiCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val euAssemblyaiCreateResponse = EuAssemblyaiCreateResponse.builder().build() + + val roundtrippedEuAssemblyaiCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(euAssemblyaiCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEuAssemblyaiCreateResponse).isEqualTo(euAssemblyaiCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt index 0af9f031..a10f1ad7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.euassemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EuAssemblyaiDeleteResponseTest { fun create() { val euAssemblyaiDeleteResponse = EuAssemblyaiDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val euAssemblyaiDeleteResponse = EuAssemblyaiDeleteResponse.builder().build() + + val roundtrippedEuAssemblyaiDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(euAssemblyaiDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEuAssemblyaiDeleteResponse).isEqualTo(euAssemblyaiDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt index c32f0289..1add8f8e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.euassemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EuAssemblyaiPatchResponseTest { fun create() { val euAssemblyaiPatchResponse = EuAssemblyaiPatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val euAssemblyaiPatchResponse = EuAssemblyaiPatchResponse.builder().build() + + val roundtrippedEuAssemblyaiPatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(euAssemblyaiPatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEuAssemblyaiPatchResponse).isEqualTo(euAssemblyaiPatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt index 0b90b36e..d07eab1a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.euassemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EuAssemblyaiRetrieveResponseTest { fun create() { val euAssemblyaiRetrieveResponse = EuAssemblyaiRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val euAssemblyaiRetrieveResponse = EuAssemblyaiRetrieveResponse.builder().build() + + val roundtrippedEuAssemblyaiRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(euAssemblyaiRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEuAssemblyaiRetrieveResponse).isEqualTo(euAssemblyaiRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt index c3a36a81..4a85e1c0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.euassemblyai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class EuAssemblyaiUpdateResponseTest { fun create() { val euAssemblyaiUpdateResponse = EuAssemblyaiUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val euAssemblyaiUpdateResponse = EuAssemblyaiUpdateResponse.builder().build() + + val roundtrippedEuAssemblyaiUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(euAssemblyaiUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEuAssemblyaiUpdateResponse).isEqualTo(euAssemblyaiUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt index 2eca7573..eac21237 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.files +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class FileCreateResponseTest { fun create() { val fileCreateResponse = FileCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileCreateResponse = FileCreateResponse.builder().build() + + val roundtrippedFileCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileCreateResponse).isEqualTo(fileCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt index 402b5726..f366d8ed 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.files +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class FileDeleteResponseTest { fun create() { val fileDeleteResponse = FileDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileDeleteResponse = FileDeleteResponse.builder().build() + + val roundtrippedFileDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileDeleteResponse).isEqualTo(fileDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt index c1f88483..2095be7d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.files +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class FileListResponseTest { fun create() { val fileListResponse = FileListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileListResponse = FileListResponse.builder().build() + + val roundtrippedFileListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileListResponse).isEqualTo(fileListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt index 382db34b..f6f533ec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.files +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class FileRetrieveResponseTest { fun create() { val fileRetrieveResponse = FileRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileRetrieveResponse = FileRetrieveResponse.builder().build() + + val roundtrippedFileRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileRetrieveResponse).isEqualTo(fileRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt index 17610818..f29c0506 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.files.content +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ContentRetrieveResponseTest { fun create() { val contentRetrieveResponse = ContentRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val contentRetrieveResponse = ContentRetrieveResponse.builder().build() + + val roundtrippedContentRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(contentRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedContentRetrieveResponse).isEqualTo(contentRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt index e6670a4b..8c038f40 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.finetuning.jobs +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class JobCreateResponseTest { fun create() { val jobCreateResponse = JobCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobCreateResponse = JobCreateResponse.builder().build() + + val roundtrippedJobCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobCreateResponse).isEqualTo(jobCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt index dc17a6bc..40d3af61 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.finetuning.jobs +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class JobListResponseTest { fun create() { val jobListResponse = JobListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobListResponse = JobListResponse.builder().build() + + val roundtrippedJobListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobListResponse).isEqualTo(jobListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt index 20dbc247..2abe86c9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.finetuning.jobs +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class JobRetrieveResponseTest { fun create() { val jobRetrieveResponse = JobRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobRetrieveResponse = JobRetrieveResponse.builder().build() + + val roundtrippedJobRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobRetrieveResponse).isEqualTo(jobRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt index 939ddac5..6ee40c2b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.finetuning.jobs.cancel +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CancelCreateResponseTest { fun create() { val cancelCreateResponse = CancelCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cancelCreateResponse = CancelCreateResponse.builder().build() + + val roundtrippedCancelCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cancelCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCancelCreateResponse).isEqualTo(cancelCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt index 47011cf0..d82e1577 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.gemini +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class GeminiCreateResponseTest { fun create() { val geminiCreateResponse = GeminiCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val geminiCreateResponse = GeminiCreateResponse.builder().build() + + val roundtrippedGeminiCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(geminiCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGeminiCreateResponse).isEqualTo(geminiCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt index c703c00b..44d0cfc3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.gemini +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class GeminiDeleteResponseTest { fun create() { val geminiDeleteResponse = GeminiDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val geminiDeleteResponse = GeminiDeleteResponse.builder().build() + + val roundtrippedGeminiDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(geminiDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGeminiDeleteResponse).isEqualTo(geminiDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt index d02f4e39..12b4bd6d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.gemini +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class GeminiPatchResponseTest { fun create() { val geminiPatchResponse = GeminiPatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val geminiPatchResponse = GeminiPatchResponse.builder().build() + + val roundtrippedGeminiPatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(geminiPatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGeminiPatchResponse).isEqualTo(geminiPatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt index 26321008..65981f2b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.gemini +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class GeminiRetrieveResponseTest { fun create() { val geminiRetrieveResponse = GeminiRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val geminiRetrieveResponse = GeminiRetrieveResponse.builder().build() + + val roundtrippedGeminiRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(geminiRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGeminiRetrieveResponse).isEqualTo(geminiRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt index f8df2f69..56521159 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.gemini +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class GeminiUpdateResponseTest { fun create() { val geminiUpdateResponse = GeminiUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val geminiUpdateResponse = GeminiUpdateResponse.builder().build() + + val roundtrippedGeminiUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(geminiUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGeminiUpdateResponse).isEqualTo(geminiUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt index 6a8654a4..709c684d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.global.spend import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -61,4 +63,40 @@ internal class SpendListTagsResponseTest { assertThat(spendListTagsResponse.totalTokens()).contains(0L) assertThat(spendListTagsResponse.user()).contains("user") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val spendListTagsResponse = + SpendListTagsResponse.builder() + .apiKey("api_key") + .callType("call_type") + .endTime("string") + .messages("string") + .requestId("request_id") + .response("string") + .startTime("string") + .apiBase("api_base") + .cacheHit("cache_hit") + .cacheKey("cache_key") + .completionTokens(0L) + .metadata(JsonValue.from(mapOf())) + .model("model") + .promptTokens(0L) + .requestTags(JsonValue.from(mapOf())) + .requesterIpAddress("requester_ip_address") + .spend(0.0) + .totalTokens(0L) + .user("user") + .build() + + val roundtrippedSpendListTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(spendListTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpendListTagsResponse).isEqualTo(spendListTagsResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt index a8b20d2e..48df02db 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.global.spend +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class SpendResetResponseTest { fun create() { val spendResetResponse = SpendResetResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val spendResetResponse = SpendResetResponse.builder().build() + + val roundtrippedSpendResetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(spendResetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpendResetResponse).isEqualTo(spendResetResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt index 4fd2201e..bc9a1c26 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.global.spend import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -62,4 +64,40 @@ internal class SpendRetrieveReportResponseTest { assertThat(spendRetrieveReportResponse.totalTokens()).contains(0L) assertThat(spendRetrieveReportResponse.user()).contains("user") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val spendRetrieveReportResponse = + SpendRetrieveReportResponse.builder() + .apiKey("api_key") + .callType("call_type") + .endTime("string") + .messages("string") + .requestId("request_id") + .response("string") + .startTime("string") + .apiBase("api_base") + .cacheHit("cache_hit") + .cacheKey("cache_key") + .completionTokens(0L) + .metadata(JsonValue.from(mapOf())) + .model("model") + .promptTokens(0L) + .requestTags(JsonValue.from(mapOf())) + .requesterIpAddress("requester_ip_address") + .spend(0.0) + .totalTokens(0L) + .user("user") + .build() + + val roundtrippedSpendRetrieveReportResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(spendRetrieveReportResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpendRetrieveReportResponse).isEqualTo(spendRetrieveReportResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt index e82197bb..4d024411 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.guardrails import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -44,4 +46,34 @@ internal class GuardrailListResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val guardrailListResponse = + GuardrailListResponse.builder() + .addGuardrail( + GuardrailListResponse.Guardrail.builder() + .guardrailInfo(JsonValue.from(mapOf())) + .guardrailName("guardrail_name") + .llmParams( + GuardrailListResponse.Guardrail.LlmParams.builder() + .guardrail("guardrail") + .mode("string") + .defaultOn(true) + .build() + ) + .build() + ) + .build() + + val roundtrippedGuardrailListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(guardrailListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGuardrailListResponse).isEqualTo(guardrailListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt index 107c3f5e..d9b8f467 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.health +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class HealthCheckAllResponseTest { fun create() { val healthCheckAllResponse = HealthCheckAllResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val healthCheckAllResponse = HealthCheckAllResponse.builder().build() + + val roundtrippedHealthCheckAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(healthCheckAllResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHealthCheckAllResponse).isEqualTo(healthCheckAllResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt index 48a92683..0a875711 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.health +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class HealthCheckLivelinessResponseTest { fun create() { val healthCheckLivelinessResponse = HealthCheckLivelinessResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val healthCheckLivelinessResponse = HealthCheckLivelinessResponse.builder().build() + + val roundtrippedHealthCheckLivelinessResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(healthCheckLivelinessResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHealthCheckLivelinessResponse) + .isEqualTo(healthCheckLivelinessResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt index f7bd63bc..c0edb38a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.health +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class HealthCheckLivenessResponseTest { fun create() { val healthCheckLivenessResponse = HealthCheckLivenessResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val healthCheckLivenessResponse = HealthCheckLivenessResponse.builder().build() + + val roundtrippedHealthCheckLivenessResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(healthCheckLivenessResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHealthCheckLivenessResponse).isEqualTo(healthCheckLivenessResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt index 0b8da1a7..5e20b6eb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.health +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class HealthCheckReadinessResponseTest { fun create() { val healthCheckReadinessResponse = HealthCheckReadinessResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val healthCheckReadinessResponse = HealthCheckReadinessResponse.builder().build() + + val roundtrippedHealthCheckReadinessResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(healthCheckReadinessResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHealthCheckReadinessResponse).isEqualTo(healthCheckReadinessResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt index 195f1258..ab1cf8d9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.health +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class HealthCheckServicesResponseTest { fun create() { val healthCheckServicesResponse = HealthCheckServicesResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val healthCheckServicesResponse = HealthCheckServicesResponse.builder().build() + + val roundtrippedHealthCheckServicesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(healthCheckServicesResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHealthCheckServicesResponse).isEqualTo(healthCheckServicesResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt index ec5c2a86..7c3e77e6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.images.generations +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class GenerationCreateResponseTest { fun create() { val generationCreateResponse = GenerationCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val generationCreateResponse = GenerationCreateResponse.builder().build() + + val roundtrippedGenerationCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(generationCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGenerationCreateResponse).isEqualTo(generationCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt index bc24f11b..4bcd7116 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -15,4 +17,19 @@ internal class BlockKeyRequestTest { assertThat(blockKeyRequest.key()).isEqualTo("key") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val blockKeyRequest = BlockKeyRequest.builder().key("key").build() + + val roundtrippedBlockKeyRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(blockKeyRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBlockKeyRequest).isEqualTo(blockKeyRequest) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt index c827a705..9fedad3e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -91,4 +93,53 @@ internal class GenerateKeyResponseTest { assertThat(generateKeyResponse.updatedBy()).contains("updated_by") assertThat(generateKeyResponse.userId()).contains("user_id") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val generateKeyResponse = + GenerateKeyResponse.builder() + .expires(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("key") + .token("token") + .aliases(JsonValue.from(mapOf())) + .addAllowedCacheControl(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetId("budget_id") + .config(JsonValue.from(mapOf())) + .createdBy("created_by") + .duration("duration") + .addEnforcedParam("string") + .addGuardrail("string") + .keyAlias("key_alias") + .keyName("key_name") + .llmBudgetTable(JsonValue.from(mapOf())) + .maxBudget(0.0) + .maxParallelRequests(0L) + .metadata(JsonValue.from(mapOf())) + .modelMaxBudget(JsonValue.from(mapOf())) + .modelRpmLimit(JsonValue.from(mapOf())) + .modelTpmLimit(JsonValue.from(mapOf())) + .addModel(JsonValue.from(mapOf())) + .permissions(JsonValue.from(mapOf())) + .rpmLimit(0L) + .spend(0.0) + .addTag("string") + .teamId("team_id") + .tokenId("token_id") + .tpmLimit(0L) + .updatedBy("updated_by") + .userId("user_id") + .build() + + val roundtrippedGenerateKeyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(generateKeyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGenerateKeyResponse).isEqualTo(generateKeyResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt index 3d150ba7..680eb13e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -84,4 +86,50 @@ internal class KeyBlockResponseTest { assertThat(keyBlockResponse.updatedBy()).contains("updated_by") assertThat(keyBlockResponse.userId()).contains("user_id") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyBlockResponse = + KeyBlockResponse.builder() + .token("token") + .aliases(JsonValue.from(mapOf())) + .addAllowedCacheControl(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .config(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .expires("string") + .keyAlias("key_alias") + .keyName("key_name") + .llmBudgetTable(JsonValue.from(mapOf())) + .maxBudget(0.0) + .maxParallelRequests(0L) + .metadata(JsonValue.from(mapOf())) + .modelMaxBudget(JsonValue.from(mapOf())) + .modelSpend(JsonValue.from(mapOf())) + .addModel(JsonValue.from(mapOf())) + .orgId("org_id") + .permissions(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudgetCooldown(true) + .spend(0.0) + .teamId("team_id") + .tpmLimit(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .userId("user_id") + .build() + + val roundtrippedKeyBlockResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyBlockResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyBlockResponse).isEqualTo(keyBlockResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt index d65bbc77..961971ba 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -33,4 +35,29 @@ internal class KeyCheckHealthResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyCheckHealthResponse = + KeyCheckHealthResponse.builder() + .key(KeyCheckHealthResponse.Key.HEALTHY) + .loggingCallbacks( + KeyCheckHealthResponse.LoggingCallbacks.builder() + .addCallback("string") + .details("details") + .status(KeyCheckHealthResponse.LoggingCallbacks.Status.HEALTHY) + .build() + ) + .build() + + val roundtrippedKeyCheckHealthResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyCheckHealthResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyCheckHealthResponse).isEqualTo(keyCheckHealthResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt index 3a4068f2..cab85d86 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class KeyDeleteResponseTest { fun create() { val keyDeleteResponse = KeyDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyDeleteResponse = KeyDeleteResponse.builder().build() + + val roundtrippedKeyDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyDeleteResponse).isEqualTo(keyDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt index 21df2374..daaa409f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -26,4 +28,25 @@ internal class KeyListResponseTest { assertThat(keyListResponse.totalCount()).contains(0L) assertThat(keyListResponse.totalPages()).contains(0L) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyListResponse = + KeyListResponse.builder() + .currentPage(0L) + .addKey("string") + .totalCount(0L) + .totalPages(0L) + .build() + + val roundtrippedKeyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyListResponse).isEqualTo(keyListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt index d9afcbbf..ecc2d2c1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class KeyRetrieveInfoResponseTest { fun create() { val keyRetrieveInfoResponse = KeyRetrieveInfoResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyRetrieveInfoResponse = KeyRetrieveInfoResponse.builder().build() + + val roundtrippedKeyRetrieveInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyRetrieveInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyRetrieveInfoResponse).isEqualTo(keyRetrieveInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt index 3d757f7a..f3ee87f0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class KeyUnblockResponseTest { fun create() { val keyUnblockResponse = KeyUnblockResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyUnblockResponse = KeyUnblockResponse.builder().build() + + val roundtrippedKeyUnblockResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyUnblockResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyUnblockResponse).isEqualTo(keyUnblockResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt index 47fcb295..33969235 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class KeyUpdateResponseTest { fun create() { val keyUpdateResponse = KeyUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val keyUpdateResponse = KeyUpdateResponse.builder().build() + + val roundtrippedKeyUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(keyUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKeyUpdateResponse).isEqualTo(keyUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt index e3f5eef8..9ba8a4ff 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.key.regenerate import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -80,4 +82,49 @@ internal class RegenerateKeyRequestTest { assertThat(regenerateKeyRequest.tpmLimit()).contains(0L) assertThat(regenerateKeyRequest.userId()).contains("user_id") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val regenerateKeyRequest = + RegenerateKeyRequest.builder() + .aliases(JsonValue.from(mapOf())) + .addAllowedCacheControl(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetId("budget_id") + .config(JsonValue.from(mapOf())) + .duration("duration") + .addEnforcedParam("string") + .addGuardrail("string") + .key("key") + .keyAlias("key_alias") + .maxBudget(0.0) + .maxParallelRequests(0L) + .metadata(JsonValue.from(mapOf())) + .modelMaxBudget(JsonValue.from(mapOf())) + .modelRpmLimit(JsonValue.from(mapOf())) + .modelTpmLimit(JsonValue.from(mapOf())) + .addModel(JsonValue.from(mapOf())) + .newMasterKey("new_master_key") + .permissions(JsonValue.from(mapOf())) + .rpmLimit(0L) + .sendInviteEmail(true) + .softBudget(0.0) + .spend(0.0) + .addTag("string") + .teamId("team_id") + .tpmLimit(0L) + .userId("user_id") + .build() + + val roundtrippedRegenerateKeyRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(regenerateKeyRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRegenerateKeyRequest).isEqualTo(regenerateKeyRequest) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt index 090c927a..3e6565f6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.langfuse +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class LangfuseCreateResponseTest { fun create() { val langfuseCreateResponse = LangfuseCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val langfuseCreateResponse = LangfuseCreateResponse.builder().build() + + val roundtrippedLangfuseCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(langfuseCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLangfuseCreateResponse).isEqualTo(langfuseCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt index 4ad2fe03..aecd8456 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.langfuse +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class LangfuseDeleteResponseTest { fun create() { val langfuseDeleteResponse = LangfuseDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val langfuseDeleteResponse = LangfuseDeleteResponse.builder().build() + + val roundtrippedLangfuseDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(langfuseDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLangfuseDeleteResponse).isEqualTo(langfuseDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt index 5dadef25..24ee1155 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.langfuse +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class LangfusePatchResponseTest { fun create() { val langfusePatchResponse = LangfusePatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val langfusePatchResponse = LangfusePatchResponse.builder().build() + + val roundtrippedLangfusePatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(langfusePatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLangfusePatchResponse).isEqualTo(langfusePatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt index c0b3cb09..092efec9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.langfuse +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class LangfuseRetrieveResponseTest { fun create() { val langfuseRetrieveResponse = LangfuseRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val langfuseRetrieveResponse = LangfuseRetrieveResponse.builder().build() + + val roundtrippedLangfuseRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(langfuseRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLangfuseRetrieveResponse).isEqualTo(langfuseRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt index f9ff0e69..c3e41c27 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.langfuse +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class LangfuseUpdateResponseTest { fun create() { val langfuseUpdateResponse = LangfuseUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val langfuseUpdateResponse = LangfuseUpdateResponse.builder().build() + + val roundtrippedLangfuseUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(langfuseUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLangfuseUpdateResponse).isEqualTo(langfuseUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt index 314b0652..d1db4e0b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.model +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -16,4 +18,21 @@ internal class ConfigurableClientsideParamsCustomAuthTest { assertThat(configurableClientsideParamsCustomAuth.apiBase()).isEqualTo("api_base") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val configurableClientsideParamsCustomAuth = + ConfigurableClientsideParamsCustomAuth.builder().apiBase("api_base").build() + + val roundtrippedConfigurableClientsideParamsCustomAuth = + jsonMapper.readValue( + jsonMapper.writeValueAsString(configurableClientsideParamsCustomAuth), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConfigurableClientsideParamsCustomAuth) + .isEqualTo(configurableClientsideParamsCustomAuth) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt index c78a3b20..351ff857 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.model +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ModelCreateResponseTest { fun create() { val modelCreateResponse = ModelCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelCreateResponse = ModelCreateResponse.builder().build() + + val roundtrippedModelCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelCreateResponse).isEqualTo(modelCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt index e25d4aa3..d21c9883 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.model +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ModelDeleteResponseTest { fun create() { val modelDeleteResponse = ModelDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelDeleteResponse = ModelDeleteResponse.builder().build() + + val roundtrippedModelDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelDeleteResponse).isEqualTo(modelDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt index 7b31fef2..2f6103a2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.model +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -37,4 +39,31 @@ internal class ModelInfoTest { assertThat(modelInfo.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(modelInfo.updatedBy()).contains("updated_by") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelInfo = + ModelInfo.builder() + .id("id") + .baseModel("base_model") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .dbModel(true) + .teamId("team_id") + .teamPublicModelName("team_public_model_name") + .tier(ModelInfo.Tier.FREE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .build() + + val roundtrippedModelInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelInfo), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelInfo).isEqualTo(modelInfo) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt index b39dc5b1..e369e16b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.model.info +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class InfoListResponseTest { fun create() { val infoListResponse = InfoListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val infoListResponse = InfoListResponse.builder().build() + + val roundtrippedInfoListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(infoListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInfoListResponse).isEqualTo(infoListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt index 3c7f676f..c809c123 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt @@ -3,7 +3,9 @@ package ai.hanzo.api.models.model.update import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper import ai.hanzo.api.models.model.ModelInfo +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -121,4 +123,71 @@ internal class UpdateDeploymentTest { ) assertThat(updateDeployment.modelName()).contains("model_name") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val updateDeployment = + UpdateDeployment.builder() + .llmParams( + UpdateDeployment.LlmParams.builder() + .apiBase("api_base") + .apiKey("api_key") + .apiVersion("api_version") + .awsAccessKeyId("aws_access_key_id") + .awsRegionName("aws_region_name") + .awsSecretAccessKey("aws_secret_access_key") + .budgetDuration("budget_duration") + .addConfigurableClientsideAuthParam("string") + .customLlmProvider("custom_llm_provider") + .inputCostPerSecond(0.0) + .inputCostPerToken(0.0) + .llmTraceId("llm_trace_id") + .maxBudget(0.0) + .maxFileSizeMb(0.0) + .maxRetries(0L) + .mergeReasoningContentInChoices(true) + .model("model") + .modelInfo(JsonValue.from(mapOf())) + .organization("organization") + .outputCostPerSecond(0.0) + .outputCostPerToken(0.0) + .regionName("region_name") + .rpm(0L) + .streamTimeout(0.0) + .timeout(0.0) + .tpm(0L) + .useInPassThrough(true) + .vertexCredentials(JsonValue.from(mapOf())) + .vertexLocation("vertex_location") + .vertexProject("vertex_project") + .watsonxRegionName("watsonx_region_name") + .build() + ) + .modelInfo( + ModelInfo.builder() + .id("id") + .baseModel("base_model") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .dbModel(true) + .teamId("team_id") + .teamPublicModelName("team_public_model_name") + .tier(ModelInfo.Tier.FREE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .build() + ) + .modelName("model_name") + .build() + + val roundtrippedUpdateDeployment = + jsonMapper.readValue( + jsonMapper.writeValueAsString(updateDeployment), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUpdateDeployment).isEqualTo(updateDeployment) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt index fa4420a7..b70915b7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.model.update +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class UpdateFullResponseTest { fun create() { val updateFullResponse = UpdateFullResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val updateFullResponse = UpdateFullResponse.builder().build() + + val roundtrippedUpdateFullResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(updateFullResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUpdateFullResponse).isEqualTo(updateFullResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt index 8d15bed2..9d126c92 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.model.update +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class UpdatePartialResponseTest { fun create() { val updatePartialResponse = UpdatePartialResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val updatePartialResponse = UpdatePartialResponse.builder().build() + + val roundtrippedUpdatePartialResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(updatePartialResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUpdatePartialResponse).isEqualTo(updatePartialResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt index 12a1dbcb..cf78d3a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.modelgroup +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class ModelGroupRetrieveInfoResponseTest { fun create() { val modelGroupRetrieveInfoResponse = ModelGroupRetrieveInfoResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelGroupRetrieveInfoResponse = ModelGroupRetrieveInfoResponse.builder().build() + + val roundtrippedModelGroupRetrieveInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelGroupRetrieveInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelGroupRetrieveInfoResponse) + .isEqualTo(modelGroupRetrieveInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt index 5c8738cc..d381598c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.models +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ModelListResponseTest { fun create() { val modelListResponse = ModelListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelListResponse = ModelListResponse.builder().build() + + val roundtrippedModelListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelListResponse).isEqualTo(modelListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt index 47630331..cdd7b8be 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.moderations +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ModerationCreateResponseTest { fun create() { val moderationCreateResponse = ModerationCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val moderationCreateResponse = ModerationCreateResponse.builder().build() + + val roundtrippedModerationCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(moderationCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModerationCreateResponse).isEqualTo(moderationCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt index 63c18468..7106750e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class OpenAICreateResponseTest { fun create() { val openaiCreateResponse = OpenAICreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val openaiCreateResponse = OpenAICreateResponse.builder().build() + + val roundtrippedOpenAICreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(openaiCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOpenAICreateResponse).isEqualTo(openaiCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt index ad7f802a..412085d2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class OpenAIDeleteResponseTest { fun create() { val openaiDeleteResponse = OpenAIDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val openaiDeleteResponse = OpenAIDeleteResponse.builder().build() + + val roundtrippedOpenAIDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(openaiDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOpenAIDeleteResponse).isEqualTo(openaiDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt index 4c43ff69..3f6b376f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class OpenAIPatchResponseTest { fun create() { val openaiPatchResponse = OpenAIPatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val openaiPatchResponse = OpenAIPatchResponse.builder().build() + + val roundtrippedOpenAIPatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(openaiPatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOpenAIPatchResponse).isEqualTo(openaiPatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt index 4d3ca750..a0985d9c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class OpenAIRetrieveResponseTest { fun create() { val openaiRetrieveResponse = OpenAIRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val openaiRetrieveResponse = OpenAIRetrieveResponse.builder().build() + + val roundtrippedOpenAIRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(openaiRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOpenAIRetrieveResponse).isEqualTo(openaiRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt index bd755514..f66ce933 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class OpenAIUpdateResponseTest { fun create() { val openaiUpdateResponse = OpenAIUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val openaiUpdateResponse = OpenAIUpdateResponse.builder().build() + + val roundtrippedOpenAIUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(openaiUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOpenAIUpdateResponse).isEqualTo(openaiUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt index f963a27c..be0a8b66 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai.deployments +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class DeploymentCompleteResponseTest { fun create() { val deploymentCompleteResponse = DeploymentCompleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val deploymentCompleteResponse = DeploymentCompleteResponse.builder().build() + + val roundtrippedDeploymentCompleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(deploymentCompleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDeploymentCompleteResponse).isEqualTo(deploymentCompleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt index 41c6ea4d..21de9ab3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai.deployments +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class DeploymentEmbedResponseTest { fun create() { val deploymentEmbedResponse = DeploymentEmbedResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val deploymentEmbedResponse = DeploymentEmbedResponse.builder().build() + + val roundtrippedDeploymentEmbedResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(deploymentEmbedResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDeploymentEmbedResponse).isEqualTo(deploymentEmbedResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt index 7def5bb5..ef529d87 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.openai.deployments.chat +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ChatCompleteResponseTest { fun create() { val chatCompleteResponse = ChatCompleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val chatCompleteResponse = ChatCompleteResponse.builder().build() + + val roundtrippedChatCompleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(chatCompleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedChatCompleteResponse).isEqualTo(chatCompleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt index a53ce50d..ce92da23 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.organization +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -22,4 +24,24 @@ internal class OrgMemberTest { assertThat(orgMember.userEmail()).contains("user_email") assertThat(orgMember.userId()).contains("user_id") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val orgMember = + OrgMember.builder() + .role(OrgMember.Role.ORG_ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + + val roundtrippedOrgMember = + jsonMapper.readValue( + jsonMapper.writeValueAsString(orgMember), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrgMember).isEqualTo(orgMember) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt index fda57205..8d9ce674 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -160,4 +162,93 @@ internal class OrganizationAddMemberResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationAddMemberResponse = + OrganizationAddMemberResponse.builder() + .organizationId("organization_id") + .addUpdatedOrganizationMembership( + OrganizationAddMemberResponse.UpdatedOrganizationMembership.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + OrganizationAddMemberResponse.UpdatedOrganizationMembership + .LlmBudgetTable + .builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .addUpdatedUser( + OrganizationAddMemberResponse.UpdatedUser.builder() + .userId("user_id") + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maxBudget(0.0) + .metadata(JsonValue.from(mapOf())) + .modelMaxBudget(JsonValue.from(mapOf())) + .modelSpend(JsonValue.from(mapOf())) + .addModel(JsonValue.from(mapOf())) + .addOrganizationMembership( + OrganizationAddMemberResponse.UpdatedUser.OrganizationMembership + .builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + OrganizationAddMemberResponse.UpdatedUser.OrganizationMembership + .LlmBudgetTable + .builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .rpmLimit(0L) + .spend(0.0) + .ssoUserId("sso_user_id") + .addTeam("string") + .tpmLimit(0L) + .userEmail("user_email") + .userRole("user_role") + .build() + ) + .build() + + val roundtrippedOrganizationAddMemberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationAddMemberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationAddMemberResponse) + .isEqualTo(organizationAddMemberResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt index 0501ca16..a75fc243 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -41,4 +43,31 @@ internal class OrganizationCreateResponseTest { assertThat(organizationCreateResponse.organizationAlias()).contains("organization_alias") assertThat(organizationCreateResponse.spend()).contains(0.0) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationCreateResponse = + OrganizationCreateResponse.builder() + .budgetId("budget_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .addModel("string") + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .metadata(JsonValue.from(mapOf())) + .organizationAlias("organization_alias") + .spend(0.0) + .build() + + val roundtrippedOrganizationCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationCreateResponse).isEqualTo(organizationCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt index d74a3e2c..10f244f5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.organization +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,20 @@ internal class OrganizationDeleteMemberResponseTest { fun create() { val organizationDeleteMemberResponse = OrganizationDeleteMemberResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationDeleteMemberResponse = OrganizationDeleteMemberResponse.builder().build() + + val roundtrippedOrganizationDeleteMemberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationDeleteMemberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationDeleteMemberResponse) + .isEqualTo(organizationDeleteMemberResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt index c5a482bf..1ad1eee2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt @@ -3,7 +3,9 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper import ai.hanzo.api.models.team.Member +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -184,4 +186,100 @@ internal class OrganizationDeleteResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationDeleteResponse = + OrganizationDeleteResponse.builder() + .budgetId("budget_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .addModel("string") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .llmBudgetTable( + OrganizationDeleteResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .addMember( + OrganizationDeleteResponse.Member.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + OrganizationDeleteResponse.Member.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .organizationAlias("organization_alias") + .organizationId("organization_id") + .spend(0.0) + .addTeam( + OrganizationDeleteResponse.Team.builder() + .teamId("team_id") + .addAdmin(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .llmModelTable( + OrganizationDeleteResponse.Team.LlmModelTable.builder() + .createdBy("created_by") + .updatedBy("updated_by") + .modelAliases(JsonValue.from(mapOf())) + .build() + ) + .maxBudget(0.0) + .maxParallelRequests(0L) + .addMember(JsonValue.from(mapOf())) + .addMembersWithRole( + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .modelId(0L) + .addModel(JsonValue.from(mapOf())) + .organizationId("organization_id") + .rpmLimit(0L) + .spend(0.0) + .teamAlias("team_alias") + .tpmLimit(0L) + .build() + ) + .build() + + val roundtrippedOrganizationDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationDeleteResponse).isEqualTo(organizationDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt index 1f4f23e3..081b0658 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt @@ -3,7 +3,9 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper import ai.hanzo.api.models.team.Member +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -184,4 +186,100 @@ internal class OrganizationListResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationListResponse = + OrganizationListResponse.builder() + .budgetId("budget_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .addModel("string") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .llmBudgetTable( + OrganizationListResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .addMember( + OrganizationListResponse.Member.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + OrganizationListResponse.Member.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .organizationAlias("organization_alias") + .organizationId("organization_id") + .spend(0.0) + .addTeam( + OrganizationListResponse.Team.builder() + .teamId("team_id") + .addAdmin(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .llmModelTable( + OrganizationListResponse.Team.LlmModelTable.builder() + .createdBy("created_by") + .updatedBy("updated_by") + .modelAliases(JsonValue.from(mapOf())) + .build() + ) + .maxBudget(0.0) + .maxParallelRequests(0L) + .addMember(JsonValue.from(mapOf())) + .addMembersWithRole( + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .modelId(0L) + .addModel(JsonValue.from(mapOf())) + .organizationId("organization_id") + .rpmLimit(0L) + .spend(0.0) + .teamAlias("team_alias") + .tpmLimit(0L) + .build() + ) + .build() + + val roundtrippedOrganizationListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationListResponse).isEqualTo(organizationListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt index 2010a294..a1e38f65 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -60,4 +62,41 @@ internal class OrganizationUpdateMemberResponseTest { .isEqualTo(JsonValue.from(mapOf())) assertThat(organizationUpdateMemberResponse.userRole()).contains("user_role") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationUpdateMemberResponse = + OrganizationUpdateMemberResponse.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + OrganizationUpdateMemberResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + + val roundtrippedOrganizationUpdateMemberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationUpdateMemberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationUpdateMemberResponse) + .isEqualTo(organizationUpdateMemberResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt index e0c03a88..0ddea4fa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt @@ -3,7 +3,9 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper import ai.hanzo.api.models.team.Member +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -184,4 +186,100 @@ internal class OrganizationUpdateResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationUpdateResponse = + OrganizationUpdateResponse.builder() + .budgetId("budget_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .addModel("string") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .llmBudgetTable( + OrganizationUpdateResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .addMember( + OrganizationUpdateResponse.Member.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + OrganizationUpdateResponse.Member.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .organizationAlias("organization_alias") + .organizationId("organization_id") + .spend(0.0) + .addTeam( + OrganizationUpdateResponse.Team.builder() + .teamId("team_id") + .addAdmin(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .llmModelTable( + OrganizationUpdateResponse.Team.LlmModelTable.builder() + .createdBy("created_by") + .updatedBy("updated_by") + .modelAliases(JsonValue.from(mapOf())) + .build() + ) + .maxBudget(0.0) + .maxParallelRequests(0L) + .addMember(JsonValue.from(mapOf())) + .addMembersWithRole( + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .modelId(0L) + .addModel(JsonValue.from(mapOf())) + .organizationId("organization_id") + .rpmLimit(0L) + .spend(0.0) + .teamAlias("team_alias") + .tpmLimit(0L) + .build() + ) + .build() + + val roundtrippedOrganizationUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationUpdateResponse).isEqualTo(organizationUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt index 76a6a95e..db957b4b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.organization.info +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class InfoDeprecatedResponseTest { fun create() { val infoDeprecatedResponse = InfoDeprecatedResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val infoDeprecatedResponse = InfoDeprecatedResponse.builder().build() + + val roundtrippedInfoDeprecatedResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(infoDeprecatedResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInfoDeprecatedResponse).isEqualTo(infoDeprecatedResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt index f9a7b5b6..b94a39c0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt @@ -3,7 +3,9 @@ package ai.hanzo.api.models.organization.info import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper import ai.hanzo.api.models.team.Member +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -183,4 +185,100 @@ internal class InfoRetrieveResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val infoRetrieveResponse = + InfoRetrieveResponse.builder() + .budgetId("budget_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .addModel("string") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") + .llmBudgetTable( + InfoRetrieveResponse.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .addMember( + InfoRetrieveResponse.Member.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + InfoRetrieveResponse.Member.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .organizationAlias("organization_alias") + .organizationId("organization_id") + .spend(0.0) + .addTeam( + InfoRetrieveResponse.Team.builder() + .teamId("team_id") + .addAdmin(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .llmModelTable( + InfoRetrieveResponse.Team.LlmModelTable.builder() + .createdBy("created_by") + .updatedBy("updated_by") + .modelAliases(JsonValue.from(mapOf())) + .build() + ) + .maxBudget(0.0) + .maxParallelRequests(0L) + .addMember(JsonValue.from(mapOf())) + .addMembersWithRole( + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .modelId(0L) + .addModel(JsonValue.from(mapOf())) + .organizationId("organization_id") + .rpmLimit(0L) + .spend(0.0) + .teamAlias("team_alias") + .tpmLimit(0L) + .build() + ) + .build() + + val roundtrippedInfoRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(infoRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInfoRetrieveResponse).isEqualTo(infoRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt index e1cceb22..766b5c3c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.provider import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -48,4 +50,36 @@ internal class ProviderListBudgetsResponseTest { .build() ) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val providerListBudgetsResponse = + ProviderListBudgetsResponse.builder() + .providers( + ProviderListBudgetsResponse.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "budget_limit" to 0, + "time_period" to "time_period", + "budget_reset_at" to "budget_reset_at", + "spend" to 0, + ) + ), + ) + .build() + ) + .build() + + val roundtrippedProviderListBudgetsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(providerListBudgetsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProviderListBudgetsResponse).isEqualTo(providerListBudgetsResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt index fa92772a..6b2c5601 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.rerank +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class RerankCreateResponseTest { fun create() { val rerankCreateResponse = RerankCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rerankCreateResponse = RerankCreateResponse.builder().build() + + val roundtrippedRerankCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rerankCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRerankCreateResponse).isEqualTo(rerankCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt index a8b4a6ad..ef87fc15 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.rerank +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class RerankCreateV1ResponseTest { fun create() { val rerankCreateV1Response = RerankCreateV1Response.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rerankCreateV1Response = RerankCreateV1Response.builder().build() + + val roundtrippedRerankCreateV1Response = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rerankCreateV1Response), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRerankCreateV1Response).isEqualTo(rerankCreateV1Response) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt index 7481d113..a719b401 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.rerank +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class RerankCreateV2ResponseTest { fun create() { val rerankCreateV2Response = RerankCreateV2Response.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rerankCreateV2Response = RerankCreateV2Response.builder().build() + + val roundtrippedRerankCreateV2Response = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rerankCreateV2Response), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRerankCreateV2Response).isEqualTo(rerankCreateV2Response) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt index 4953d372..47d67f7b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.responses +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ResponseCreateResponseTest { fun create() { val responseCreateResponse = ResponseCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseCreateResponse = ResponseCreateResponse.builder().build() + + val roundtrippedResponseCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseCreateResponse).isEqualTo(responseCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt index b7dc4027..55ac3be8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.responses +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ResponseDeleteResponseTest { fun create() { val responseDeleteResponse = ResponseDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseDeleteResponse = ResponseDeleteResponse.builder().build() + + val roundtrippedResponseDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseDeleteResponse).isEqualTo(responseDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt index 48123c92..0fd97b74 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.responses +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ResponseRetrieveResponseTest { fun create() { val responseRetrieveResponse = ResponseRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseRetrieveResponse = ResponseRetrieveResponse.builder().build() + + val roundtrippedResponseRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseRetrieveResponse).isEqualTo(responseRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt index a3e2f246..ac662c11 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.responses.inputitems +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class InputItemListResponseTest { fun create() { val inputItemListResponse = InputItemListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inputItemListResponse = InputItemListResponse.builder().build() + + val roundtrippedInputItemListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inputItemListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInputItemListResponse).isEqualTo(inputItemListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt index d4b09cab..699f26f0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.routes +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class RouteListResponseTest { fun create() { val routeListResponse = RouteListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routeListResponse = RouteListResponse.builder().build() + + val roundtrippedRouteListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routeListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRouteListResponse).isEqualTo(routeListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt index 69b15609..a78d877b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.settings +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class SettingRetrieveResponseTest { fun create() { val settingRetrieveResponse = SettingRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val settingRetrieveResponse = SettingRetrieveResponse.builder().build() + + val roundtrippedSettingRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(settingRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSettingRetrieveResponse).isEqualTo(settingRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt index da6b55eb..a375ca83 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.spend +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class SpendCalculateSpendResponseTest { fun create() { val spendCalculateSpendResponse = SpendCalculateSpendResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val spendCalculateSpendResponse = SpendCalculateSpendResponse.builder().build() + + val roundtrippedSpendCalculateSpendResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(spendCalculateSpendResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpendCalculateSpendResponse).isEqualTo(spendCalculateSpendResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt index 66361caf..ce9441d4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.spend import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -61,4 +63,40 @@ internal class SpendListLogsResponseTest { assertThat(spendListLogsResponse.totalTokens()).contains(0L) assertThat(spendListLogsResponse.user()).contains("user") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val spendListLogsResponse = + SpendListLogsResponse.builder() + .apiKey("api_key") + .callType("call_type") + .endTime("string") + .messages("string") + .requestId("request_id") + .response("string") + .startTime("string") + .apiBase("api_base") + .cacheHit("cache_hit") + .cacheKey("cache_key") + .completionTokens(0L) + .metadata(JsonValue.from(mapOf())) + .model("model") + .promptTokens(0L) + .requestTags(JsonValue.from(mapOf())) + .requesterIpAddress("requester_ip_address") + .spend(0.0) + .totalTokens(0L) + .user("user") + .build() + + val roundtrippedSpendListLogsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(spendListLogsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpendListLogsResponse).isEqualTo(spendListLogsResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt index 35bb2810..05b2f238 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.spend import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -61,4 +63,40 @@ internal class SpendListTagsResponseTest { assertThat(spendListTagsResponse.totalTokens()).contains(0L) assertThat(spendListTagsResponse.user()).contains("user") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val spendListTagsResponse = + SpendListTagsResponse.builder() + .apiKey("api_key") + .callType("call_type") + .endTime("string") + .messages("string") + .requestId("request_id") + .response("string") + .startTime("string") + .apiBase("api_base") + .cacheHit("cache_hit") + .cacheKey("cache_key") + .completionTokens(0L) + .metadata(JsonValue.from(mapOf())) + .model("model") + .promptTokens(0L) + .requestTags(JsonValue.from(mapOf())) + .requesterIpAddress("requester_ip_address") + .spend(0.0) + .totalTokens(0L) + .user("user") + .build() + + val roundtrippedSpendListTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(spendListTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSpendListTagsResponse).isEqualTo(spendListTagsResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt index f7d4103d..f6acda31 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -15,4 +17,19 @@ internal class BlockTeamRequestTest { assertThat(blockTeamRequest.teamId()).isEqualTo("team_id") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val blockTeamRequest = BlockTeamRequest.builder().teamId("team_id").build() + + val roundtrippedBlockTeamRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(blockTeamRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBlockTeamRequest).isEqualTo(blockTeamRequest) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt index 4fe70acb..f3cd63e8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -22,4 +24,21 @@ internal class MemberTest { assertThat(member.userEmail()).contains("user_email") assertThat(member.userId()).contains("user_id") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val member = + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + + val roundtrippedMember = + jsonMapper.readValue(jsonMapper.writeValueAsString(member), jacksonTypeRef()) + + assertThat(roundtrippedMember).isEqualTo(member) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt index 3853807b..83160548 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -215,4 +217,114 @@ internal class TeamAddMemberResponseTest { assertThat(teamAddMemberResponse.teamAlias()).contains("team_alias") assertThat(teamAddMemberResponse.tpmLimit()).contains(0L) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamAddMemberResponse = + TeamAddMemberResponse.builder() + .teamId("team_id") + .addUpdatedTeamMembership( + TeamAddMemberResponse.UpdatedTeamMembership.builder() + .budgetId("budget_id") + .llmBudgetTable( + TeamAddMemberResponse.UpdatedTeamMembership.LlmBudgetTable.builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .teamId("team_id") + .userId("user_id") + .build() + ) + .addUpdatedUser( + TeamAddMemberResponse.UpdatedUser.builder() + .userId("user_id") + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maxBudget(0.0) + .metadata(JsonValue.from(mapOf())) + .modelMaxBudget(JsonValue.from(mapOf())) + .modelSpend(JsonValue.from(mapOf())) + .addModel(JsonValue.from(mapOf())) + .addOrganizationMembership( + TeamAddMemberResponse.UpdatedUser.OrganizationMembership.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("organization_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userId("user_id") + .budgetId("budget_id") + .llmBudgetTable( + TeamAddMemberResponse.UpdatedUser.OrganizationMembership + .LlmBudgetTable + .builder() + .budgetDuration("budget_duration") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget(JsonValue.from(mapOf())) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) + .build() + ) + .spend(0.0) + .user(JsonValue.from(mapOf())) + .userRole("user_role") + .build() + ) + .rpmLimit(0L) + .spend(0.0) + .ssoUserId("sso_user_id") + .addTeam("string") + .tpmLimit(0L) + .userEmail("user_email") + .userRole("user_role") + .build() + ) + .addAdmin(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .llmModelTable( + TeamAddMemberResponse.LlmModelTable.builder() + .createdBy("created_by") + .updatedBy("updated_by") + .modelAliases(JsonValue.from(mapOf())) + .build() + ) + .maxBudget(0.0) + .maxParallelRequests(0L) + .addMember(JsonValue.from(mapOf())) + .addMembersWithRole( + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .modelId(0L) + .addModel(JsonValue.from(mapOf())) + .organizationId("organization_id") + .rpmLimit(0L) + .spend(0.0) + .teamAlias("team_alias") + .tpmLimit(0L) + .build() + + val roundtrippedTeamAddMemberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamAddMemberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamAddMemberResponse).isEqualTo(teamAddMemberResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt index 86aba457..6fef77a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamBlockResponseTest { fun create() { val teamBlockResponse = TeamBlockResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamBlockResponse = TeamBlockResponse.builder().build() + + val roundtrippedTeamBlockResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamBlockResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamBlockResponse).isEqualTo(teamBlockResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt index 01cb1fbf..0ca83045 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -88,4 +90,52 @@ internal class TeamCreateResponseTest { assertThat(teamCreateResponse.teamAlias()).contains("team_alias") assertThat(teamCreateResponse.tpmLimit()).contains(0L) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamCreateResponse = + TeamCreateResponse.builder() + .teamId("team_id") + .addAdmin(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetResetAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .llmModelTable( + TeamCreateResponse.LlmModelTable.builder() + .createdBy("created_by") + .updatedBy("updated_by") + .modelAliases(JsonValue.from(mapOf())) + .build() + ) + .maxBudget(0.0) + .maxParallelRequests(0L) + .addMember(JsonValue.from(mapOf())) + .addMembersWithRole( + Member.builder() + .role(Member.Role.ADMIN) + .userEmail("user_email") + .userId("user_id") + .build() + ) + .metadata(JsonValue.from(mapOf())) + .modelId(0L) + .addModel(JsonValue.from(mapOf())) + .organizationId("organization_id") + .rpmLimit(0L) + .spend(0.0) + .teamAlias("team_alias") + .tpmLimit(0L) + .build() + + val roundtrippedTeamCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamCreateResponse).isEqualTo(teamCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt index d3ad86df..de19c85c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamDeleteResponseTest { fun create() { val teamDeleteResponse = TeamDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamDeleteResponse = TeamDeleteResponse.builder().build() + + val roundtrippedTeamDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamDeleteResponse).isEqualTo(teamDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt index e5e5e7a8..906ac97f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamDisableLoggingResponseTest { fun create() { val teamDisableLoggingResponse = TeamDisableLoggingResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamDisableLoggingResponse = TeamDisableLoggingResponse.builder().build() + + val roundtrippedTeamDisableLoggingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamDisableLoggingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamDisableLoggingResponse).isEqualTo(teamDisableLoggingResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt index 32a3c1f1..456b5942 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamListAvailableResponseTest { fun create() { val teamListAvailableResponse = TeamListAvailableResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamListAvailableResponse = TeamListAvailableResponse.builder().build() + + val roundtrippedTeamListAvailableResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamListAvailableResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamListAvailableResponse).isEqualTo(teamListAvailableResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt index c08abf49..a2aba8a0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamListResponseTest { fun create() { val teamListResponse = TeamListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamListResponse = TeamListResponse.builder().build() + + val roundtrippedTeamListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamListResponse).isEqualTo(teamListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt index ae11538a..7446376c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamRemoveMemberResponseTest { fun create() { val teamRemoveMemberResponse = TeamRemoveMemberResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamRemoveMemberResponse = TeamRemoveMemberResponse.builder().build() + + val roundtrippedTeamRemoveMemberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamRemoveMemberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamRemoveMemberResponse).isEqualTo(teamRemoveMemberResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt index f5e4773a..73d33a46 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamRetrieveInfoResponseTest { fun create() { val teamRetrieveInfoResponse = TeamRetrieveInfoResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamRetrieveInfoResponse = TeamRetrieveInfoResponse.builder().build() + + val roundtrippedTeamRetrieveInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamRetrieveInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamRetrieveInfoResponse).isEqualTo(teamRetrieveInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt index 1ddb8536..91964dfe 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamUnblockResponseTest { fun create() { val teamUnblockResponse = TeamUnblockResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamUnblockResponse = TeamUnblockResponse.builder().build() + + val roundtrippedTeamUnblockResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamUnblockResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamUnblockResponse).isEqualTo(teamUnblockResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt index bd2e5838..c795793a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -24,4 +26,25 @@ internal class TeamUpdateMemberResponseTest { assertThat(teamUpdateMemberResponse.maxBudgetInTeam()).contains(0.0) assertThat(teamUpdateMemberResponse.userEmail()).contains("user_email") } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamUpdateMemberResponse = + TeamUpdateMemberResponse.builder() + .teamId("team_id") + .userId("user_id") + .maxBudgetInTeam(0.0) + .userEmail("user_email") + .build() + + val roundtrippedTeamUpdateMemberResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamUpdateMemberResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamUpdateMemberResponse).isEqualTo(teamUpdateMemberResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt index 03d5827b..c6029a44 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TeamUpdateResponseTest { fun create() { val teamUpdateResponse = TeamUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val teamUpdateResponse = TeamUpdateResponse.builder().build() + + val roundtrippedTeamUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(teamUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTeamUpdateResponse).isEqualTo(teamUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt index ddea200c..f430cc63 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team.callback +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CallbackAddResponseTest { fun create() { val callbackAddResponse = CallbackAddResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val callbackAddResponse = CallbackAddResponse.builder().build() + + val roundtrippedCallbackAddResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(callbackAddResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCallbackAddResponse).isEqualTo(callbackAddResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt index f0197be0..cd2f6932 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team.callback +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class CallbackRetrieveResponseTest { fun create() { val callbackRetrieveResponse = CallbackRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val callbackRetrieveResponse = CallbackRetrieveResponse.builder().build() + + val roundtrippedCallbackRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(callbackRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCallbackRetrieveResponse).isEqualTo(callbackRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt index 45deebb0..93b99c5e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team.model +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ModelAddResponseTest { fun create() { val modelAddResponse = ModelAddResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelAddResponse = ModelAddResponse.builder().build() + + val roundtrippedModelAddResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelAddResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelAddResponse).isEqualTo(modelAddResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt index 13a21e93..3d6f3b40 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.team.model +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ModelRemoveResponseTest { fun create() { val modelRemoveResponse = ModelRemoveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelRemoveResponse = ModelRemoveResponse.builder().build() + + val roundtrippedModelRemoveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelRemoveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedModelRemoveResponse).isEqualTo(modelRemoveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt index 4679687e..98dbd402 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.test +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class TestPingResponseTest { fun create() { val testPingResponse = TestPingResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val testPingResponse = TestPingResponse.builder().build() + + val roundtrippedTestPingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(testPingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTestPingResponse).isEqualTo(testPingResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt index 1ca271cd..f03dac73 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.threads +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ThreadCreateResponseTest { fun create() { val threadCreateResponse = ThreadCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val threadCreateResponse = ThreadCreateResponse.builder().build() + + val roundtrippedThreadCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(threadCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThreadCreateResponse).isEqualTo(threadCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt index 5c074fdd..c3cd9cf0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.threads +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class ThreadRetrieveResponseTest { fun create() { val threadRetrieveResponse = ThreadRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val threadRetrieveResponse = ThreadRetrieveResponse.builder().build() + + val roundtrippedThreadRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(threadRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThreadRetrieveResponse).isEqualTo(threadRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt index 7fd78907..cf972a08 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.threads.messages +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class MessageCreateResponseTest { fun create() { val messageCreateResponse = MessageCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageCreateResponse = MessageCreateResponse.builder().build() + + val roundtrippedMessageCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageCreateResponse).isEqualTo(messageCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt index fea320dd..cfd3a33c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.threads.messages +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class MessageListResponseTest { fun create() { val messageListResponse = MessageListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageListResponse = MessageListResponse.builder().build() + + val roundtrippedMessageListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageListResponse).isEqualTo(messageListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt index 525da124..25f45b17 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.threads.runs +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class RunCreateResponseTest { fun create() { val runCreateResponse = RunCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = RunCreateResponse.builder().build() + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt index 4005dd47..973b8791 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -100,4 +102,57 @@ internal class UserCreateResponseTest { assertThat(userCreateResponse.userId()).contains("user_id") assertThat(userCreateResponse.userRole()).contains(UserCreateResponse.UserRole.PROXY_ADMIN) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userCreateResponse = + UserCreateResponse.builder() + .expires(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("key") + .token("token") + .aliases(JsonValue.from(mapOf())) + .addAllowedCacheControl(JsonValue.from(mapOf())) + .blocked(true) + .budgetDuration("budget_duration") + .budgetId("budget_id") + .config(JsonValue.from(mapOf())) + .createdBy("created_by") + .duration("duration") + .addEnforcedParam("string") + .addGuardrail("string") + .keyAlias("key_alias") + .keyName("key_name") + .llmBudgetTable(JsonValue.from(mapOf())) + .maxBudget(0.0) + .maxParallelRequests(0L) + .metadata(JsonValue.from(mapOf())) + .modelMaxBudget(JsonValue.from(mapOf())) + .modelRpmLimit(JsonValue.from(mapOf())) + .modelTpmLimit(JsonValue.from(mapOf())) + .addModel(JsonValue.from(mapOf())) + .permissions(JsonValue.from(mapOf())) + .rpmLimit(0L) + .spend(0.0) + .addTag("string") + .teamId("team_id") + .addTeam(JsonValue.from(mapOf())) + .tokenId("token_id") + .tpmLimit(0L) + .updatedBy("updated_by") + .userAlias("user_alias") + .userEmail("user_email") + .userId("user_id") + .userRole(UserCreateResponse.UserRole.PROXY_ADMIN) + .build() + + val roundtrippedUserCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserCreateResponse).isEqualTo(userCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt index 381137b1..22ed12f7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.user +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class UserDeleteResponseTest { fun create() { val userDeleteResponse = UserDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userDeleteResponse = UserDeleteResponse.builder().build() + + val roundtrippedUserDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserDeleteResponse).isEqualTo(userDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt index 4a1db978..c00be84f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.user +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class UserListResponseTest { fun create() { val userListResponse = UserListResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userListResponse = UserListResponse.builder().build() + + val roundtrippedUserListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserListResponse).isEqualTo(userListResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt index e4816200..f80f1a62 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.user +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class UserRetrieveInfoResponseTest { fun create() { val userRetrieveInfoResponse = UserRetrieveInfoResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveInfoResponse = UserRetrieveInfoResponse.builder().build() + + val roundtrippedUserRetrieveInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveInfoResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveInfoResponse).isEqualTo(userRetrieveInfoResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt index affbe40c..c0591613 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.user +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class UserUpdateResponseTest { fun create() { val userUpdateResponse = UserUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userUpdateResponse = UserUpdateResponse.builder().build() + + val roundtrippedUserUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserUpdateResponse).isEqualTo(userUpdateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt index 67fae4a5..4a07fc41 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.utils +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -13,4 +16,21 @@ internal class UtilGetSupportedOpenAIParamsResponseTest { val utilGetSupportedOpenAIParamsResponse = UtilGetSupportedOpenAIParamsResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val utilGetSupportedOpenAIParamsResponse = + UtilGetSupportedOpenAIParamsResponse.builder().build() + + val roundtrippedUtilGetSupportedOpenAIParamsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(utilGetSupportedOpenAIParamsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUtilGetSupportedOpenAIParamsResponse) + .isEqualTo(utilGetSupportedOpenAIParamsResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt index bafc2e42..40869aaa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt @@ -2,6 +2,8 @@ package ai.hanzo.api.models.utils +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -24,4 +26,25 @@ internal class UtilTokenCounterResponseTest { assertThat(utilTokenCounterResponse.tokenizerType()).isEqualTo("tokenizer_type") assertThat(utilTokenCounterResponse.totalTokens()).isEqualTo(0L) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val utilTokenCounterResponse = + UtilTokenCounterResponse.builder() + .modelUsed("model_used") + .requestModel("request_model") + .tokenizerType("tokenizer_type") + .totalTokens(0L) + .build() + + val roundtrippedUtilTokenCounterResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(utilTokenCounterResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUtilTokenCounterResponse).isEqualTo(utilTokenCounterResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt index 2062e75a..7fa174c8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt @@ -3,6 +3,8 @@ package ai.hanzo.api.models.utils import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -28,4 +30,25 @@ internal class UtilTransformRequestResponseTest { assertThat(utilTransformRequestResponse._rawRequestHeaders()) .isEqualTo(JsonValue.from(mapOf())) } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val utilTransformRequestResponse = + UtilTransformRequestResponse.builder() + .error("error") + .rawRequestApiBase("raw_request_api_base") + .rawRequestBody(JsonValue.from(mapOf())) + .rawRequestHeaders(JsonValue.from(mapOf())) + .build() + + val roundtrippedUtilTransformRequestResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(utilTransformRequestResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUtilTransformRequestResponse).isEqualTo(utilTransformRequestResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt index 0fd59fa2..c662a67d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.vertexai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class VertexAiCreateResponseTest { fun create() { val vertexAiCreateResponse = VertexAiCreateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val vertexAiCreateResponse = VertexAiCreateResponse.builder().build() + + val roundtrippedVertexAiCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(vertexAiCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVertexAiCreateResponse).isEqualTo(vertexAiCreateResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt index cb03cbea..cf87e634 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.vertexai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class VertexAiDeleteResponseTest { fun create() { val vertexAiDeleteResponse = VertexAiDeleteResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val vertexAiDeleteResponse = VertexAiDeleteResponse.builder().build() + + val roundtrippedVertexAiDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(vertexAiDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVertexAiDeleteResponse).isEqualTo(vertexAiDeleteResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt index 34f5c523..9168b15f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.vertexai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class VertexAiPatchResponseTest { fun create() { val vertexAiPatchResponse = VertexAiPatchResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val vertexAiPatchResponse = VertexAiPatchResponse.builder().build() + + val roundtrippedVertexAiPatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(vertexAiPatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVertexAiPatchResponse).isEqualTo(vertexAiPatchResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt index 4b365b05..352824d2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.vertexai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class VertexAiRetrieveResponseTest { fun create() { val vertexAiRetrieveResponse = VertexAiRetrieveResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val vertexAiRetrieveResponse = VertexAiRetrieveResponse.builder().build() + + val roundtrippedVertexAiRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(vertexAiRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVertexAiRetrieveResponse).isEqualTo(vertexAiRetrieveResponse) + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt index 7456d372..e94b83c6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.models.vertexai +import ai.hanzo.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -12,4 +15,19 @@ internal class VertexAiUpdateResponseTest { fun create() { val vertexAiUpdateResponse = VertexAiUpdateResponse.builder().build() } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val vertexAiUpdateResponse = VertexAiUpdateResponse.builder().build() + + val roundtrippedVertexAiUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(vertexAiUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVertexAiUpdateResponse).isEqualTo(vertexAiUpdateResponse) + } } From d1cf89db05f61aa38c0a8d274ba3ee77d17e0341 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 3 Apr 2025 12:40:59 +0000 Subject: [PATCH 07/75] feat(client): make datetime deserialization more lenient (#15) --- .../kotlin/ai/hanzo/api/core/ObjectMappers.kt | 64 ++++++++++++++++++- .../ai/hanzo/api/core/ObjectMappersTest.kt | 21 ++++++ 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt index 77c5157d..1a43c083 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt @@ -4,12 +4,16 @@ package ai.hanzo.api.core import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.cfg.CoercionAction import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.databind.type.LogicalType @@ -17,13 +21,23 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.kotlinModule import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField fun jsonMapper(): JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) .addModule(JavaTimeModule()) - .addModule(SimpleModule().addSerializer(InputStreamJsonSerializer)) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) .withCoercionConfig(LogicalType.Boolean) { it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) @@ -91,7 +105,10 @@ fun jsonMapper(): JsonMapper = .disable(MapperFeature.AUTO_DETECT_SETTERS) .build() -private object InputStreamJsonSerializer : BaseSerializer(InputStream::class) { +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer override fun serialize( value: InputStream?, @@ -105,3 +122,46 @@ private object InputStreamJsonSerializer : BaseSerializer(InputStre } } } + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt index a57105de..c0eb9de5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ObjectMappersTest.kt @@ -2,10 +2,15 @@ package ai.hanzo.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest internal class ObjectMappersTest { @@ -78,4 +83,20 @@ internal class ObjectMappersTest { assertThat(e).isInstanceOf(MismatchedInputException::class.java) } } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } } From 69c2c6cd26d41cd1e0a5012398cd8ba54a7617ca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 3 Apr 2025 13:24:33 +0000 Subject: [PATCH 08/75] feat(client): expose request body setter and getter (#16) --- .../api/models/add/AddAddAllowedIpParams.kt | 2 +- .../models/anthropic/AnthropicCreateParams.kt | 3 +-- .../models/anthropic/AnthropicDeleteParams.kt | 3 +-- .../models/anthropic/AnthropicModifyParams.kt | 3 +-- .../models/anthropic/AnthropicUpdateParams.kt | 3 +-- .../models/assemblyai/AssemblyaiCreateParams.kt | 3 +-- .../models/assemblyai/AssemblyaiDeleteParams.kt | 3 +-- .../models/assemblyai/AssemblyaiPatchParams.kt | 3 +-- .../models/assemblyai/AssemblyaiUpdateParams.kt | 3 +-- .../models/assistants/AssistantCreateParams.kt | 3 +-- .../models/assistants/AssistantDeleteParams.kt | 3 +-- .../models/audio/speech/SpeechCreateParams.kt | 3 +-- .../transcriptions/TranscriptionCreateParams.kt | 12 ++++++++++-- .../hanzo/api/models/azure/AzureCreateParams.kt | 3 +-- .../hanzo/api/models/azure/AzureDeleteParams.kt | 3 +-- .../hanzo/api/models/azure/AzurePatchParams.kt | 3 +-- .../hanzo/api/models/azure/AzureUpdateParams.kt | 3 +-- .../batches/BatchCancelWithProviderParams.kt | 3 +-- .../api/models/batches/BatchCreateParams.kt | 3 +-- .../batches/BatchCreateWithProviderParams.kt | 3 +-- .../models/batches/cancel/CancelCancelParams.kt | 3 +-- .../api/models/bedrock/BedrockCreateParams.kt | 3 +-- .../api/models/bedrock/BedrockDeleteParams.kt | 3 +-- .../api/models/bedrock/BedrockPatchParams.kt | 3 +-- .../api/models/bedrock/BedrockUpdateParams.kt | 3 +-- .../api/models/budget/BudgetCreateParams.kt | 2 +- .../api/models/budget/BudgetDeleteParams.kt | 11 ++++++++++- .../hanzo/api/models/budget/BudgetInfoParams.kt | 11 ++++++++++- .../api/models/budget/BudgetUpdateParams.kt | 2 +- .../hanzo/api/models/cache/CacheDeleteParams.kt | 3 +-- .../api/models/cache/CacheFlushAllParams.kt | 3 +-- .../chat/completions/CompletionCreateParams.kt | 3 +-- .../api/models/cohere/CohereCreateParams.kt | 3 +-- .../api/models/cohere/CohereDeleteParams.kt | 3 +-- .../api/models/cohere/CohereModifyParams.kt | 3 +-- .../api/models/cohere/CohereUpdateParams.kt | 3 +-- .../models/completions/CompletionCreateParams.kt | 3 +-- .../PassThroughEndpointCreateParams.kt | 2 +- .../PassThroughEndpointDeleteParams.kt | 3 +-- .../PassThroughEndpointUpdateParams.kt | 3 +-- .../models/credentials/CredentialCreateParams.kt | 14 +++++++++++++- .../models/credentials/CredentialDeleteParams.kt | 3 +-- .../api/models/customer/CustomerBlockParams.kt | 2 +- .../api/models/customer/CustomerCreateParams.kt | 16 +++++++++++++++- .../api/models/customer/CustomerDeleteParams.kt | 11 ++++++++++- .../api/models/customer/CustomerUnblockParams.kt | 2 +- .../api/models/customer/CustomerUpdateParams.kt | 16 +++++++++++++++- .../models/delete/DeleteCreateAllowedIpParams.kt | 2 +- .../models/embeddings/EmbeddingCreateParams.kt | 3 +-- .../api/models/engines/EngineCompleteParams.kt | 3 +-- .../api/models/engines/EngineEmbedParams.kt | 3 +-- .../models/engines/chat/ChatCompleteParams.kt | 3 +-- .../euassemblyai/EuAssemblyaiCreateParams.kt | 3 +-- .../euassemblyai/EuAssemblyaiDeleteParams.kt | 3 +-- .../euassemblyai/EuAssemblyaiPatchParams.kt | 3 +-- .../euassemblyai/EuAssemblyaiUpdateParams.kt | 3 +-- .../hanzo/api/models/files/FileCreateParams.kt | 14 ++++++++++++-- .../hanzo/api/models/files/FileDeleteParams.kt | 3 +-- .../models/finetuning/jobs/JobCreateParams.kt | 16 +++++++++++++++- .../finetuning/jobs/cancel/CancelCreateParams.kt | 3 +-- .../api/models/gemini/GeminiCreateParams.kt | 3 +-- .../api/models/gemini/GeminiDeleteParams.kt | 3 +-- .../hanzo/api/models/gemini/GeminiPatchParams.kt | 3 +-- .../api/models/gemini/GeminiUpdateParams.kt | 3 +-- .../api/models/global/spend/SpendResetParams.kt | 3 +-- .../images/generations/GenerationCreateParams.kt | 3 +-- .../ai/hanzo/api/models/key/KeyBlockParams.kt | 2 +- .../hanzo/api/models/key/KeyCheckHealthParams.kt | 3 +-- .../ai/hanzo/api/models/key/KeyDeleteParams.kt | 12 +++++++++++- .../ai/hanzo/api/models/key/KeyGenerateParams.kt | 16 +++++++++++++++- .../api/models/key/KeyRegenerateByKeyParams.kt | 3 +-- .../ai/hanzo/api/models/key/KeyUnblockParams.kt | 2 +- .../ai/hanzo/api/models/key/KeyUpdateParams.kt | 16 +++++++++++++++- .../api/models/langfuse/LangfuseCreateParams.kt | 3 +-- .../api/models/langfuse/LangfuseDeleteParams.kt | 3 +-- .../api/models/langfuse/LangfusePatchParams.kt | 3 +-- .../api/models/langfuse/LangfuseUpdateParams.kt | 3 +-- .../hanzo/api/models/model/ModelCreateParams.kt | 13 ++++++++++++- .../hanzo/api/models/model/ModelDeleteParams.kt | 11 ++++++++++- .../api/models/model/update/UpdateFullParams.kt | 2 +- .../models/model/update/UpdatePartialParams.kt | 2 +- .../models/moderations/ModerationCreateParams.kt | 3 +-- .../api/models/openai/OpenAICreateParams.kt | 3 +-- .../api/models/openai/OpenAIDeleteParams.kt | 3 +-- .../hanzo/api/models/openai/OpenAIPatchParams.kt | 3 +-- .../api/models/openai/OpenAIUpdateParams.kt | 3 +-- .../deployments/DeploymentCompleteParams.kt | 3 +-- .../openai/deployments/DeploymentEmbedParams.kt | 3 +-- .../deployments/chat/ChatCompleteParams.kt | 3 +-- .../organization/OrganizationAddMemberParams.kt | 13 ++++++++++++- .../organization/OrganizationCreateParams.kt | 16 +++++++++++++++- .../OrganizationDeleteMemberParams.kt | 13 ++++++++++++- .../organization/OrganizationDeleteParams.kt | 11 ++++++++++- .../OrganizationUpdateMemberParams.kt | 16 +++++++++++++++- .../organization/OrganizationUpdateParams.kt | 16 +++++++++++++++- .../organization/info/InfoDeprecatedParams.kt | 11 ++++++++++- .../api/models/rerank/RerankCreateParams.kt | 3 +-- .../api/models/rerank/RerankCreateV1Params.kt | 3 +-- .../api/models/rerank/RerankCreateV2Params.kt | 3 +-- .../api/models/responses/ResponseCreateParams.kt | 3 +-- .../api/models/responses/ResponseDeleteParams.kt | 3 +-- .../models/spend/SpendCalculateSpendParams.kt | 13 ++++++++++++- .../hanzo/api/models/team/TeamAddMemberParams.kt | 13 ++++++++++++- .../ai/hanzo/api/models/team/TeamBlockParams.kt | 2 +- .../ai/hanzo/api/models/team/TeamCreateParams.kt | 16 +++++++++++++++- .../ai/hanzo/api/models/team/TeamDeleteParams.kt | 11 ++++++++++- .../api/models/team/TeamDisableLoggingParams.kt | 3 +-- .../api/models/team/TeamRemoveMemberParams.kt | 13 ++++++++++++- .../hanzo/api/models/team/TeamUnblockParams.kt | 2 +- .../api/models/team/TeamUpdateMemberParams.kt | 16 +++++++++++++++- .../ai/hanzo/api/models/team/TeamUpdateParams.kt | 16 +++++++++++++++- .../models/team/callback/CallbackAddParams.kt | 13 ++++++++++++- .../api/models/team/model/ModelAddParams.kt | 12 +++++++++++- .../api/models/team/model/ModelRemoveParams.kt | 12 +++++++++++- .../api/models/threads/ThreadCreateParams.kt | 3 +-- .../threads/messages/MessageCreateParams.kt | 3 +-- .../api/models/threads/runs/RunCreateParams.kt | 3 +-- .../ai/hanzo/api/models/user/UserCreateParams.kt | 16 +++++++++++++++- .../ai/hanzo/api/models/user/UserDeleteParams.kt | 11 ++++++++++- .../ai/hanzo/api/models/user/UserUpdateParams.kt | 16 +++++++++++++++- .../api/models/utils/UtilTokenCounterParams.kt | 13 ++++++++++++- .../models/utils/UtilTransformRequestParams.kt | 12 +++++++++++- .../api/models/vertexai/VertexAiCreateParams.kt | 3 +-- .../api/models/vertexai/VertexAiDeleteParams.kt | 3 +-- .../api/models/vertexai/VertexAiPatchParams.kt | 3 +-- .../api/models/vertexai/VertexAiUpdateParams.kt | 3 +-- 126 files changed, 540 insertions(+), 205 deletions(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParams.kt index ac401b88..6baa3523 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParams.kt @@ -174,7 +174,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): IpAddress = ipAddress + fun _body(): IpAddress = ipAddress override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt index 4bcbcd47..9d3b5a16 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt index 4ffd9477..bca28e9d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt index b8d6ef81..09baea8f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt index f76313ff..1c94785e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt index 68f14015..b98f49f6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt index 4a1bb714..bddacc4f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt index 8a70ba28..3c1b195e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt index ad96547c..118e71b2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParams.kt index 42828aa1..cb3c86b8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParams.kt @@ -185,8 +185,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt index 3f3f74fb..aef03dc0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParams.kt index de8fb161..7382297a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParams.kt @@ -185,8 +185,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParams.kt index e022d831..1101d936 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParams.kt @@ -75,6 +75,15 @@ private constructor( additionalQueryParams = transcriptionCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [file] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun file(file: InputStream) = apply { body.file(file) } /** @@ -208,8 +217,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Map> = mapOf("file" to _file()).toImmutable() + fun _body(): Map> = mapOf("file" to _file()).toImmutable() override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt index 5f79a483..52385c48 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt index 2e0b8d53..cdd37018 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt index bbdc0015..3f173e68 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt index 8a0549e0..d583f0e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt index 45ecb807..15de1c2c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt @@ -226,8 +226,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateParams.kt index c9e7601e..756256b4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateParams.kt @@ -207,8 +207,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt index cc3a3bce..23ce7afd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt @@ -218,8 +218,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt index bf674ef6..b9bf4ebf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt @@ -226,8 +226,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt index 6bd46759..8e6fb92a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt index 0025f993..8c3d7671 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt index f794ca2c..d552d132 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt index b0c9534b..f36cf979 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt index 9a0904e5..d44db89e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt @@ -188,7 +188,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BudgetNew = budgetNew + fun _body(): BudgetNew = budgetNew override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt index 5eca20f2..5756e14b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt @@ -79,6 +79,15 @@ private constructor( additionalQueryParams = budgetDeleteParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun id(id: String) = apply { body.id(id) } /** @@ -226,7 +235,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt index 6b8e18cc..b4a11982 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt @@ -82,6 +82,15 @@ private constructor( additionalQueryParams = budgetInfoParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [budgets] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun budgets(budgets: List) = apply { body.budgets(budgets) } /** @@ -233,7 +242,7 @@ private constructor( BudgetInfoParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt index c4f903ca..556b4779 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt @@ -188,7 +188,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BudgetNew = budgetNew + fun _body(): BudgetNew = budgetNew override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt index deaaa814..0de9c44e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt @@ -192,8 +192,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParams.kt index fbcd86df..ed6128fc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParams.kt @@ -190,8 +190,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt index 77537594..4cd6d03d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt @@ -212,8 +212,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt index e3b0069c..4f3f27b4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt index 191c3192..6f085f7f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt index f1efd5d2..3da1e6bf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt index c6145aff..5f8578ac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateParams.kt index 55ac81c0..cf4db7e8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateParams.kt @@ -209,8 +209,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParams.kt index 1961b362..4ca80943 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParams.kt @@ -182,7 +182,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): PassThroughGenericEndpoint = passThroughGenericEndpoint + fun _body(): PassThroughGenericEndpoint = passThroughGenericEndpoint override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt index 05855747..8fb3d6bd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt @@ -210,8 +210,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt index 62c95a73..aa20dbcc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt index 70a6e81f..84b83fa5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt @@ -97,6 +97,18 @@ private constructor( additionalQueryParams = credentialCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [credentialInfo] + * - [credentialName] + * - [credentialValues] + * - [modelId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun credentialInfo(credentialInfo: JsonValue) = apply { body.credentialInfo(credentialInfo) } @@ -269,7 +281,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt index e8325d85..750c822f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockParams.kt index 173a961a..8eb202f7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockParams.kt @@ -184,7 +184,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BlockUsers = blockUsers + fun _body(): BlockUsers = blockUsers override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt index 5c1e2f69..5451a389 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt @@ -298,6 +298,20 @@ private constructor( additionalQueryParams = customerCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [userId] + * - [alias] + * - [allowedModelRegion] + * - [blocked] + * - [budgetDuration] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun userId(userId: String) = apply { body.userId(userId) } /** @@ -675,7 +689,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt index ecad3915..002ec0f2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt @@ -91,6 +91,15 @@ private constructor( additionalQueryParams = customerDeleteParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [userIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun userIds(userIds: List) = apply { body.userIds(userIds) } /** @@ -246,7 +255,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParams.kt index 20b7efc7..c933f691 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParams.kt @@ -186,7 +186,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BlockUsers = blockUsers + fun _body(): BlockUsers = blockUsers override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt index a169e4da..9318d6da 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt @@ -179,6 +179,20 @@ private constructor( additionalQueryParams = customerUpdateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [userId] + * - [alias] + * - [allowedModelRegion] + * - [blocked] + * - [budgetId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun userId(userId: String) = apply { body.userId(userId) } /** @@ -420,7 +434,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParams.kt index cb74bec4..f8d462b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParams.kt @@ -175,7 +175,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): IpAddress = ipAddress + fun _body(): IpAddress = ipAddress override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt index cadff085..172664c0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt index 4f7464b9..c6ea2ef2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt @@ -217,8 +217,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt index 9def10f8..9805df55 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt @@ -215,8 +215,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt index 6b4fdbf4..9a460364 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt @@ -220,8 +220,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt index 39a35b0c..0d62eba3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt index 450aefe6..6ce811e3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt index fae411c9..812b73b1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt index 2863e1a8..f09079e0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt index 23fc1df5..4b143494 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt @@ -120,6 +120,17 @@ private constructor( fun provider(provider: String) = apply { this.provider = provider } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [file] + * - [purpose] + * - [customLlmProvider] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun file(file: InputStream) = apply { body.file(file) } /** @@ -281,8 +292,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Map> = + fun _body(): Map> = mapOf( "file" to _file(), "purpose" to _purpose(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt index 41f9f952..e2536fb0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt @@ -224,8 +224,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt index a8ad49c3..22f241cc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt @@ -200,6 +200,20 @@ private constructor( additionalQueryParams = jobCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [customLlmProvider] + * - [model] + * - [trainingFile] + * - [hyperparameters] + * - [integrations] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun customLlmProvider(customLlmProvider: CustomLlmProvider) = apply { body.customLlmProvider(customLlmProvider) } @@ -466,7 +480,7 @@ private constructor( JobCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt index 0f1253fd..ee50a826 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt @@ -213,8 +213,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt index 9398fd8b..2958e148 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt index 6ee9cf08..28940b6a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt index 8a956aa0..7efc0bf2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt index e6c64ac4..87af4b47 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt index 5a5d7da6..8f8fbb4b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt @@ -188,8 +188,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt index a239be9d..7c5b7c55 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt @@ -182,8 +182,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt index 9c52f0be..ac43e730 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt @@ -212,7 +212,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BlockKeyRequest = blockKeyRequest + fun _body(): BlockKeyRequest = blockKeyRequest override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt index c5cd162b..2c7f7a28 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt @@ -218,8 +218,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt index 9bf6a088..0b461f6c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt @@ -124,6 +124,16 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [keyAliases] + * - [keys] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun keyAliases(keyAliases: List?) = apply { body.keyAliases(keyAliases) } /** Alias for calling [Builder.keyAliases] with `keyAliases.orElse(null)`. */ @@ -297,7 +307,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt index 99dcdc5e..b4ce19b0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt @@ -421,6 +421,20 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [aliases] + * - [allowedCacheControls] + * - [blocked] + * - [budgetDuration] + * - [budgetId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun aliases(aliases: JsonValue) = apply { body.aliases(aliases) } fun allowedCacheControls(allowedCacheControls: List?) = apply { @@ -960,7 +974,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt index ec7044cd..f9b3a7f7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt @@ -261,8 +261,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional = Optional.ofNullable(regenerateKeyRequest) + fun _body(): Optional = Optional.ofNullable(regenerateKeyRequest) fun _pathParam(index: Int): String = when (index) { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt index 1656e19d..24bd02a2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt @@ -212,7 +212,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BlockKeyRequest = blockKeyRequest + fun _body(): BlockKeyRequest = blockKeyRequest override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt index f3439e5d..1179275c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt @@ -415,6 +415,20 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [key] + * - [aliases] + * - [allowedCacheControls] + * - [blocked] + * - [budgetDuration] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun key(key: String) = apply { body.key(key) } /** @@ -959,7 +973,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt index 1580aa8f..5028eaa0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt index 89906c9f..0a9ff26a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt index 1f6e1ccc..06cc2c2c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt index f27b1956..44de2678 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt index a8c7a116..5198146a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt @@ -119,6 +119,17 @@ private constructor( additionalQueryParams = modelCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [llmParams] + * - [modelInfo] + * - [modelName] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** LLM Params with 'model' requirement - used for completions */ fun llmParams(llmParams: LlmParams) = apply { body.llmParams(llmParams) } @@ -292,7 +303,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt index 641b4136..1f0fc696 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt @@ -74,6 +74,15 @@ private constructor( additionalQueryParams = modelDeleteParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun id(id: String) = apply { body.id(id) } /** @@ -221,7 +230,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullParams.kt index 763bb3b4..113e3ab4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullParams.kt @@ -177,7 +177,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): UpdateDeployment = updateDeployment + fun _body(): UpdateDeployment = updateDeployment override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt index d46f0213..ebaea00e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt @@ -199,7 +199,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): UpdateDeployment = updateDeployment + fun _body(): UpdateDeployment = updateDeployment fun _pathParam(index: Int): String = when (index) { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParams.kt index e82d90ac..df40bb86 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParams.kt @@ -191,8 +191,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt index 95cad570..8b8b99dd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt index 5948bb33..59abc202 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt index 3e08c63e..a4445277 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt index b36d180b..6983da52 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt index 3e8d4f51..11b074ff 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt @@ -218,8 +218,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt index c2461b8d..cad94bf3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt @@ -215,8 +215,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt index 311c3f14..7d553ad7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt @@ -220,8 +220,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt index 4722c4ac..dd80c27e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt @@ -149,6 +149,17 @@ private constructor( additionalQueryParams = organizationAddMemberParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [member] + * - [organizationId] + * - [maxBudgetInOrganization] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun member(member: Member) = apply { body.member(member) } /** @@ -348,7 +359,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt index 98388849..e429d8ef 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt @@ -261,6 +261,20 @@ private constructor( additionalQueryParams = organizationCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [organizationAlias] + * - [budgetDuration] + * - [budgetId] + * - [maxBudget] + * - [maxParallelRequests] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun organizationAlias(organizationAlias: String) = apply { body.organizationAlias(organizationAlias) } @@ -595,7 +609,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt index 09cbf528..56eb3ada 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt @@ -103,6 +103,17 @@ private constructor( additionalQueryParams = organizationDeleteMemberParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [organizationId] + * - [userEmail] + * - [userId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun organizationId(organizationId: String) = apply { body.organizationId(organizationId) } /** @@ -280,7 +291,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt index dbb3f88c..22c691eb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt @@ -82,6 +82,15 @@ private constructor( additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [organizationIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun organizationIds(organizationIds: List) = apply { body.organizationIds(organizationIds) } @@ -243,7 +252,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt index 06d23f14..6f25078b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt @@ -142,6 +142,20 @@ private constructor( additionalQueryParams = organizationUpdateMemberParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [organizationId] + * - [maxBudgetInOrganization] + * - [role] + * - [userEmail] + * - [userId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun organizationId(organizationId: String) = apply { body.organizationId(organizationId) } /** @@ -374,7 +388,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt index c41de8f8..4b28e3ae 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt @@ -140,6 +140,20 @@ private constructor( additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [budgetId] + * - [metadata] + * - [models] + * - [organizationAlias] + * - [organizationId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun budgetId(budgetId: String?) = apply { body.budgetId(budgetId) } /** Alias for calling [Builder.budgetId] with `budgetId.orElse(null)`. */ @@ -376,7 +390,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt index f3bcde2e..8da6cf1e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt @@ -77,6 +77,15 @@ private constructor( additionalQueryParams = infoDeprecatedParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [organizations] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun organizations(organizations: List) = apply { body.organizations(organizations) } /** @@ -234,7 +243,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateParams.kt index 6bade3a9..b70b8030 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateParams.kt @@ -181,8 +181,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Params.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Params.kt index cf4390b8..a0f7aa37 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Params.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Params.kt @@ -181,8 +181,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Params.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Params.kt index d42d3278..d3af1f95 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Params.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Params.kt @@ -181,8 +181,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateParams.kt index 38b67050..6299fcc9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateParams.kt @@ -190,8 +190,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt index d942c622..97fba8a0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt @@ -211,8 +211,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt index c1deaad2..9964e1ab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt @@ -136,6 +136,17 @@ private constructor( additionalQueryParams = spendCalculateSpendParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [completionResponse] + * - [messages] + * - [model] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun completionResponse(completionResponse: JsonValue) = apply { body.completionResponse(completionResponse) } @@ -304,7 +315,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt index fda9ecf0..8530b6f8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt @@ -128,6 +128,17 @@ private constructor( additionalQueryParams = teamAddMemberParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [member] + * - [teamId] + * - [maxBudgetInTeam] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun member(member: Member) = apply { body.member(member) } /** @@ -318,7 +329,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockParams.kt index 7877178f..1b90b54d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockParams.kt @@ -192,7 +192,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BlockTeamRequest = blockTeamRequest + fun _body(): BlockTeamRequest = blockTeamRequest override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt index 456a2fd6..b34443bf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt @@ -321,6 +321,20 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [admins] + * - [blocked] + * - [budgetDuration] + * - [guardrails] + * - [maxBudget] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun admins(admins: List) = apply { body.admins(admins) } /** @@ -708,7 +722,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt index fc00a6f3..57867823 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt @@ -107,6 +107,15 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [teamIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun teamIds(teamIds: List) = apply { body.teamIds(teamIds) } /** @@ -263,7 +272,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt index d3e20f46..cd1b73ca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt @@ -213,8 +213,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt index 6c0c1f98..ab62ab6b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt @@ -118,6 +118,17 @@ private constructor( additionalQueryParams = teamRemoveMemberParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [teamId] + * - [userEmail] + * - [userId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun teamId(teamId: String) = apply { body.teamId(teamId) } /** @@ -292,7 +303,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockParams.kt index 37cd4268..14ee49b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockParams.kt @@ -189,7 +189,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): BlockTeamRequest = blockTeamRequest + fun _body(): BlockTeamRequest = blockTeamRequest override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt index 14f2f3b8..af2927f9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt @@ -133,6 +133,20 @@ private constructor( additionalQueryParams = teamUpdateMemberParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [teamId] + * - [maxBudgetInTeam] + * - [role] + * - [userEmail] + * - [userId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun teamId(teamId: String) = apply { body.teamId(teamId) } /** @@ -346,7 +360,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt index 7f6a5565..60733ae5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt @@ -277,6 +277,20 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [teamId] + * - [blocked] + * - [budgetDuration] + * - [guardrails] + * - [maxBudget] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun teamId(teamId: String) = apply { body.teamId(teamId) } /** @@ -621,7 +635,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt index 79fb0abb..bee18451 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt @@ -168,6 +168,17 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [callbackName] + * - [callbackVars] + * - [callbackType] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun callbackName(callbackName: String) = apply { body.callbackName(callbackName) } /** @@ -352,7 +363,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt index 4842f3c6..f11c249e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt @@ -105,6 +105,16 @@ private constructor( additionalQueryParams = modelAddParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [models] + * - [teamId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun models(models: List) = apply { body.models(models) } /** @@ -267,7 +277,7 @@ private constructor( ModelAddParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt index 44672026..0b4b5a30 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt @@ -105,6 +105,16 @@ private constructor( additionalQueryParams = modelRemoveParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [models] + * - [teamId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun models(models: List) = apply { body.models(models) } /** @@ -271,7 +281,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateParams.kt index afa173b5..5c7c2441 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateParams.kt @@ -185,8 +185,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt index b08965ab..f46a0982 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt index 2dbb7709..3539cbb9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt index 603ae31e..d9c33440 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt @@ -406,6 +406,20 @@ private constructor( additionalQueryParams = userCreateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [aliases] + * - [allowedCacheControls] + * - [autoCreateKey] + * - [blocked] + * - [budgetDuration] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun aliases(aliases: JsonValue) = apply { body.aliases(aliases) } fun allowedCacheControls(allowedCacheControls: List?) = apply { @@ -922,7 +936,7 @@ private constructor( UserCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt index b18a6de7..a89ae388 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt @@ -110,6 +110,15 @@ private constructor( /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [userIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun userIds(userIds: List) = apply { body.userIds(userIds) } /** @@ -266,7 +275,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = Headers.builder() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt index a6d0defe..1166df9d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt @@ -345,6 +345,20 @@ private constructor( additionalQueryParams = userUpdateParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [aliases] + * - [allowedCacheControls] + * - [blocked] + * - [budgetDuration] + * - [config] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun aliases(aliases: JsonValue) = apply { body.aliases(aliases) } fun allowedCacheControls(allowedCacheControls: List?) = apply { @@ -800,7 +814,7 @@ private constructor( UserUpdateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt index b262b58f..04b16b59 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt @@ -104,6 +104,17 @@ private constructor( additionalQueryParams = utilTokenCounterParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [model] + * - [messages] + * - [prompt] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun model(model: String) = apply { body.model(model) } /** @@ -285,7 +296,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt index 6ae8ee95..85a2233d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt @@ -79,6 +79,16 @@ private constructor( additionalQueryParams = utilTransformRequestParams.additionalQueryParams.toBuilder() } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [callType] + * - [requestBody] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + fun callType(callType: CallType) = apply { body.callType(callType) } /** @@ -230,7 +240,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt index 1fdc0ee4..f164a447 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt index 1c5fd655..33233b61 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt index aa9ce662..ee65e055 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt index 8760e3f4..f7bf1bee 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = From 91c37b152243864b852b3ab04c05ab0aadf28912 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 18:06:30 +0000 Subject: [PATCH 09/75] perf(client): cached parsed type in `HttpResponseFor` (#17) --- .../src/main/kotlin/ai/hanzo/api/core/http/HttpResponseFor.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpResponseFor.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpResponseFor.kt index f22c643a..f8b25335 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpResponseFor.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpResponseFor.kt @@ -11,7 +11,9 @@ interface HttpResponseFor : HttpResponse { internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = object : HttpResponseFor { - override fun parse(): T = parse() + private val parsed: T by lazy { parse() } + + override fun parse(): T = parsed override fun statusCode(): Int = this@parseable.statusCode() From b4a0c8b295e7216dd22f472b4ee4198664f7dad0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 03:13:42 +0000 Subject: [PATCH 10/75] chore(internal): swap from `getNullable` to `getOptional` (#18) --- .../main/kotlin/ai/hanzo/api/core/Values.kt | 8 +- .../ai/hanzo/api/models/budget/BudgetNew.kt | 18 ++- .../api/models/cache/CachePingResponse.kt | 9 +- .../credentials/CredentialCreateParams.kt | 2 +- .../models/customer/CustomerCreateParams.kt | 27 ++-- .../models/customer/CustomerListResponse.kt | 26 ++-- .../customer/CustomerRetrieveInfoResponse.kt | 26 ++-- .../models/customer/CustomerUpdateParams.kt | 13 +- .../api/models/files/FileCreateParams.kt | 2 +- .../models/finetuning/jobs/JobCreateParams.kt | 19 ++- .../global/spend/SpendListTagsResponse.kt | 30 ++--- .../spend/SpendRetrieveReportResponse.kt | 30 ++--- .../guardrails/GuardrailListResponse.kt | 3 +- .../api/models/key/GenerateKeyResponse.kt | 49 ++++--- .../hanzo/api/models/key/KeyBlockResponse.kt | 48 ++++--- .../api/models/key/KeyCheckHealthResponse.kt | 11 +- .../hanzo/api/models/key/KeyDeleteParams.kt | 5 +- .../hanzo/api/models/key/KeyGenerateParams.kt | 45 +++---- .../hanzo/api/models/key/KeyListResponse.kt | 120 +++++++----------- .../hanzo/api/models/key/KeyUpdateParams.kt | 41 +++--- .../key/regenerate/RegenerateKeyRequest.kt | 47 +++---- .../api/models/model/ModelCreateParams.kt | 74 +++++------ .../ai/hanzo/api/models/model/ModelInfo.kt | 22 ++-- .../models/model/update/UpdateDeployment.kt | 82 +++++------- .../api/models/organization/OrgMember.kt | 4 +- .../OrganizationAddMemberParams.kt | 2 +- .../OrganizationAddMemberResponse.kt | 76 +++++------ .../organization/OrganizationCreateParams.kt | 21 ++- .../OrganizationCreateResponse.kt | 5 +- .../OrganizationDeleteMemberParams.kt | 4 +- .../OrganizationDeleteResponse.kt | 95 ++++++-------- .../organization/OrganizationListResponse.kt | 95 ++++++-------- .../OrganizationUpdateMemberParams.kt | 8 +- .../OrganizationUpdateMemberResponse.kt | 23 ++-- .../organization/OrganizationUpdateParams.kt | 13 +- .../OrganizationUpdateResponse.kt | 95 ++++++-------- .../organization/info/InfoRetrieveResponse.kt | 95 ++++++-------- .../provider/ProviderListBudgetsResponse.kt | 2 +- .../models/spend/SpendCalculateSpendParams.kt | 5 +- .../api/models/spend/SpendListLogsResponse.kt | 30 ++--- .../api/models/spend/SpendListTagsResponse.kt | 30 ++--- .../kotlin/ai/hanzo/api/models/team/Member.kt | 4 +- .../api/models/team/TeamAddMemberParams.kt | 3 +- .../api/models/team/TeamAddMemberResponse.kt | 112 +++++++--------- .../hanzo/api/models/team/TeamCreateParams.kt | 32 ++--- .../api/models/team/TeamCreateResponse.kt | 42 +++--- .../api/models/team/TeamRemoveMemberParams.kt | 4 +- .../api/models/team/TeamUpdateMemberParams.kt | 9 +- .../models/team/TeamUpdateMemberResponse.kt | 5 +- .../hanzo/api/models/team/TeamUpdateParams.kt | 23 ++-- .../models/team/callback/CallbackAddParams.kt | 3 +- .../hanzo/api/models/user/UserCreateParams.kt | 44 +++---- .../api/models/user/UserCreateResponse.kt | 57 ++++----- .../hanzo/api/models/user/UserUpdateParams.kt | 36 +++--- .../models/utils/UtilTokenCounterParams.kt | 5 +- .../utils/UtilTransformRequestResponse.kt | 4 +- 56 files changed, 755 insertions(+), 988 deletions(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt index a7334087..fe3fe016 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt @@ -132,11 +132,11 @@ sealed class JsonField { } @JvmSynthetic - internal fun getNullable(name: String): T? = + internal fun getOptional(name: String): Optional<@UnsafeVariance T> = when (this) { - is KnownValue -> value - is JsonMissing -> null - is JsonNull -> null + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() else -> throw HanzoInvalidDataException("`$name` is invalid, received $this") } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt index 951c4603..4d9916df 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt @@ -66,8 +66,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * The unique budget id. @@ -75,7 +74,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Requests will fail if this budget (in USD) is exceeded. @@ -83,7 +82,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * Max concurrent requests allowed for this budget id. @@ -92,7 +91,7 @@ private constructor( * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * Max budget for each model (e.g. {'gpt-4o': {'max_budget': '0.0000001', 'budget_duration': @@ -101,8 +100,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelMaxBudget(): Optional = - Optional.ofNullable(modelMaxBudget.getNullable("model_max_budget")) + fun modelMaxBudget(): Optional = modelMaxBudget.getOptional("model_max_budget") /** * Max requests per minute, allowed for this budget id. @@ -110,7 +108,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * Requests will NOT fail if this is exceeded. Will fire alerting though. @@ -118,7 +116,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * Max tokens per minute, allowed for this budget id. @@ -126,7 +124,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt index 569acdcd..fa02f041 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt @@ -74,22 +74,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmCacheParams(): Optional = - Optional.ofNullable(llmCacheParams.getNullable("llm_cache_params")) + fun llmCacheParams(): Optional = llmCacheParams.getOptional("llm_cache_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun pingResponse(): Optional = - Optional.ofNullable(pingResponse.getNullable("ping_response")) + fun pingResponse(): Optional = pingResponse.getOptional("ping_response") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun setCacheResponse(): Optional = - Optional.ofNullable(setCacheResponse.getNullable("set_cache_response")) + fun setCacheResponse(): Optional = setCacheResponse.getOptional("set_cache_response") /** * Returns the raw JSON value of [cacheType]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt index 84b83fa5..580166d7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt @@ -328,7 +328,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * Returns the raw JSON value of [credentialName]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt index 5451a389..17b0e72b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt @@ -772,20 +772,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun alias(): Optional = Optional.ofNullable(alias.getNullable("alias")) + fun alias(): Optional = alias.getOptional("alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun allowedModelRegion(): Optional = - Optional.ofNullable(allowedModelRegion.getNullable("allowed_model_region")) + allowedModelRegion.getOptional("allowed_model_region") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * Max duration budget should be set for (e.g. '1hr', '1d', '28d') @@ -793,21 +793,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun defaultModel(): Optional = - Optional.ofNullable(defaultModel.getNullable("default_model")) + fun defaultModel(): Optional = defaultModel.getOptional("default_model") /** * Requests will fail if this budget (in USD) is exceeded. @@ -815,7 +813,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * Max concurrent requests allowed for this budget id. @@ -824,7 +822,7 @@ private constructor( * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * Max budget for each model (e.g. {'gpt-4o': {'max_budget': '0.0000001', 'budget_duration': @@ -834,7 +832,7 @@ private constructor( * server responded with an unexpected value). */ fun modelMaxBudget(): Optional = - Optional.ofNullable(modelMaxBudget.getNullable("model_max_budget")) + modelMaxBudget.getOptional("model_max_budget") /** * Max requests per minute, allowed for this budget id. @@ -842,7 +840,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * Requests will NOT fail if this is exceeded. Will fire alerting though. @@ -850,8 +848,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * Max tokens per minute, allowed for this budget id. @@ -859,7 +856,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [userId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt index a840dfab..c5307ab4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt @@ -72,21 +72,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun alias(): Optional = Optional.ofNullable(alias.getNullable("alias")) + fun alias(): Optional = alias.getOptional("alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun allowedModelRegion(): Optional = - Optional.ofNullable(allowedModelRegion.getNullable("allowed_model_region")) + allowedModelRegion.getOptional("allowed_model_region") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun defaultModel(): Optional = - Optional.ofNullable(defaultModel.getNullable("default_model")) + fun defaultModel(): Optional = defaultModel.getOptional("default_model") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -94,14 +93,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * Returns the raw JSON value of [blocked]. @@ -568,21 +566,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -592,20 +589,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt index 54873e55..357a2df7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt @@ -72,21 +72,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun alias(): Optional = Optional.ofNullable(alias.getNullable("alias")) + fun alias(): Optional = alias.getOptional("alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun allowedModelRegion(): Optional = - Optional.ofNullable(allowedModelRegion.getNullable("allowed_model_region")) + allowedModelRegion.getOptional("allowed_model_region") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun defaultModel(): Optional = - Optional.ofNullable(defaultModel.getNullable("default_model")) + fun defaultModel(): Optional = defaultModel.getOptional("default_model") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -94,14 +93,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * Returns the raw JSON value of [blocked]. @@ -568,21 +566,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -592,20 +589,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt index 9318d6da..4de34a02 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt @@ -491,39 +491,38 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun alias(): Optional = Optional.ofNullable(alias.getNullable("alias")) + fun alias(): Optional = alias.getOptional("alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun allowedModelRegion(): Optional = - Optional.ofNullable(allowedModelRegion.getNullable("allowed_model_region")) + allowedModelRegion.getOptional("allowed_model_region") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun defaultModel(): Optional = - Optional.ofNullable(defaultModel.getNullable("default_model")) + fun defaultModel(): Optional = defaultModel.getOptional("default_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * Returns the raw JSON value of [userId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt index 4b143494..473f3659 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt @@ -334,7 +334,7 @@ private constructor( * server responded with an unexpected value). */ fun customLlmProvider(): Optional = - Optional.ofNullable(customLlmProvider.value.getNullable("custom_llm_provider")) + customLlmProvider.value.getOptional("custom_llm_provider") /** * Returns the raw multipart value of [file]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt index 22f241cc..9f36707c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt @@ -555,33 +555,31 @@ private constructor( * server responded with an unexpected value). */ fun hyperparameters(): Optional = - Optional.ofNullable(hyperparameters.getNullable("hyperparameters")) + hyperparameters.getOptional("hyperparameters") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun integrations(): Optional> = - Optional.ofNullable(integrations.getNullable("integrations")) + fun integrations(): Optional> = integrations.getOptional("integrations") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun seed(): Optional = Optional.ofNullable(seed.getNullable("seed")) + fun seed(): Optional = seed.getOptional("seed") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun suffix(): Optional = Optional.ofNullable(suffix.getNullable("suffix")) + fun suffix(): Optional = suffix.getOptional("suffix") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun validationFile(): Optional = - Optional.ofNullable(validationFile.getNullable("validation_file")) + fun validationFile(): Optional = validationFile.getOptional("validation_file") /** * Returns the raw JSON value of [customLlmProvider]. @@ -1111,21 +1109,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun batchSize(): Optional = - Optional.ofNullable(batchSize.getNullable("batch_size")) + fun batchSize(): Optional = batchSize.getOptional("batch_size") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun learningRateMultiplier(): Optional = - Optional.ofNullable(learningRateMultiplier.getNullable("learning_rate_multiplier")) + learningRateMultiplier.getOptional("learning_rate_multiplier") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun nEpochs(): Optional = Optional.ofNullable(nEpochs.getNullable("n_epochs")) + fun nEpochs(): Optional = nEpochs.getOptional("n_epochs") /** * Returns the raw JSON value of [batchSize]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt index 8f7db942..0f10c99e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt @@ -123,13 +123,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endTime(): Optional = Optional.ofNullable(endTime.getNullable("endTime")) + fun endTime(): Optional = endTime.getOptional("endTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun messages(): Optional = Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional = messages.getOptional("messages") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -141,38 +141,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun response(): Optional = Optional.ofNullable(response.getNullable("response")) + fun response(): Optional = response.getOptional("response") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startTime(): Optional = Optional.ofNullable(startTime.getNullable("startTime")) + fun startTime(): Optional = startTime.getOptional("startTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiBase(): Optional = Optional.ofNullable(apiBase.getNullable("api_base")) + fun apiBase(): Optional = apiBase.getOptional("api_base") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheHit(): Optional = Optional.ofNullable(cacheHit.getNullable("cache_hit")) + fun cacheHit(): Optional = cacheHit.getOptional("cache_hit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheKey(): Optional = Optional.ofNullable(cacheKey.getNullable("cache_key")) + fun cacheKey(): Optional = cacheKey.getOptional("cache_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -180,14 +179,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = model.getOptional("model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") @JsonProperty("request_tags") @ExcludeMissing fun _requestTags(): JsonValue = requestTags @@ -196,25 +194,25 @@ private constructor( * server responded with an unexpected value). */ fun requesterIpAddress(): Optional = - Optional.ofNullable(requesterIpAddress.getNullable("requester_ip_address")) + requesterIpAddress.getOptional("requester_ip_address") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun totalTokens(): Optional = Optional.ofNullable(totalTokens.getNullable("total_tokens")) + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun user(): Optional = Optional.ofNullable(user.getNullable("user")) + fun user(): Optional = user.getOptional("user") /** * Returns the raw JSON value of [apiKey]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt index 7e6ba14d..f587e223 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt @@ -123,13 +123,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endTime(): Optional = Optional.ofNullable(endTime.getNullable("endTime")) + fun endTime(): Optional = endTime.getOptional("endTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun messages(): Optional = Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional = messages.getOptional("messages") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -141,38 +141,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun response(): Optional = Optional.ofNullable(response.getNullable("response")) + fun response(): Optional = response.getOptional("response") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startTime(): Optional = Optional.ofNullable(startTime.getNullable("startTime")) + fun startTime(): Optional = startTime.getOptional("startTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiBase(): Optional = Optional.ofNullable(apiBase.getNullable("api_base")) + fun apiBase(): Optional = apiBase.getOptional("api_base") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheHit(): Optional = Optional.ofNullable(cacheHit.getNullable("cache_hit")) + fun cacheHit(): Optional = cacheHit.getOptional("cache_hit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheKey(): Optional = Optional.ofNullable(cacheKey.getNullable("cache_key")) + fun cacheKey(): Optional = cacheKey.getOptional("cache_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -180,14 +179,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = model.getOptional("model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") @JsonProperty("request_tags") @ExcludeMissing fun _requestTags(): JsonValue = requestTags @@ -196,25 +194,25 @@ private constructor( * server responded with an unexpected value). */ fun requesterIpAddress(): Optional = - Optional.ofNullable(requesterIpAddress.getNullable("requester_ip_address")) + requesterIpAddress.getOptional("requester_ip_address") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun totalTokens(): Optional = Optional.ofNullable(totalTokens.getNullable("total_tokens")) + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun user(): Optional = Optional.ofNullable(user.getNullable("user")) + fun user(): Optional = user.getOptional("user") /** * Returns the raw JSON value of [apiKey]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt index 98caef87..040de0b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt @@ -427,8 +427,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun defaultOn(): Optional = - Optional.ofNullable(defaultOn.getNullable("default_on")) + fun defaultOn(): Optional = defaultOn.getOptional("default_on") /** * Returns the raw JSON value of [guardrail]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt index 85167c00..f7e17e4b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt @@ -153,7 +153,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun expires(): Optional = Optional.ofNullable(expires.getNullable("expires")) + fun expires(): Optional = expires.getOptional("expires") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -165,7 +165,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun token(): Optional = Optional.ofNullable(token.getNullable("token")) + fun token(): Optional = token.getOptional("token") @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases @@ -174,26 +174,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -201,39 +200,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdBy(): Optional = Optional.ofNullable(createdBy.getNullable("created_by")) + fun createdBy(): Optional = createdBy.getOptional("created_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun enforcedParams(): Optional> = - Optional.ofNullable(enforcedParams.getNullable("enforced_params")) + fun enforcedParams(): Optional> = enforcedParams.getOptional("enforced_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyName(): Optional = Optional.ofNullable(keyName.getNullable("key_name")) + fun keyName(): Optional = keyName.getOptional("key_name") @JsonProperty("llm_budget_table") @ExcludeMissing @@ -243,14 +240,14 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -266,7 +263,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -274,49 +271,49 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tokenId(): Optional = Optional.ofNullable(tokenId.getNullable("token_id")) + fun tokenId(): Optional = tokenId.getOptional("token_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedBy(): Optional = Optional.ofNullable(updatedBy.getNullable("updated_by")) + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [expires]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt index a2bb4a7c..c7d1fa0e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt @@ -152,7 +152,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun token(): Optional = Optional.ofNullable(token.getNullable("token")) + fun token(): Optional = token.getOptional("token") @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases @@ -161,27 +161,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -189,32 +187,31 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdBy(): Optional = Optional.ofNullable(createdBy.getNullable("created_by")) + fun createdBy(): Optional = createdBy.getOptional("created_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun expires(): Optional = Optional.ofNullable(expires.getNullable("expires")) + fun expires(): Optional = expires.getOptional("expires") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyName(): Optional = Optional.ofNullable(keyName.getNullable("key_name")) + fun keyName(): Optional = keyName.getOptional("key_name") @JsonProperty("llm_budget_table") @ExcludeMissing @@ -224,14 +221,14 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -245,13 +242,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) + fun orgId(): Optional = orgId.getOptional("org_id") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -259,51 +256,50 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun softBudgetCooldown(): Optional = - Optional.ofNullable(softBudgetCooldown.getNullable("soft_budget_cooldown")) + softBudgetCooldown.getOptional("soft_budget_cooldown") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedAt(): Optional = - Optional.ofNullable(updatedAt.getNullable("updated_at")) + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedBy(): Optional = Optional.ofNullable(updatedBy.getNullable("updated_by")) + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [token]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt index a482ec79..ac49f103 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt @@ -38,14 +38,14 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun key(): Optional = Optional.ofNullable(key.getNullable("key")) + fun key(): Optional = key.getOptional("key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun loggingCallbacks(): Optional = - Optional.ofNullable(loggingCallbacks.getNullable("logging_callbacks")) + loggingCallbacks.getOptional("logging_callbacks") /** * Returns the raw JSON value of [key]. @@ -327,20 +327,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun callbacks(): Optional> = - Optional.ofNullable(callbacks.getNullable("callbacks")) + fun callbacks(): Optional> = callbacks.getOptional("callbacks") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun details(): Optional = Optional.ofNullable(details.getNullable("details")) + fun details(): Optional = details.getOptional("details") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) + fun status(): Optional = status.getOptional("status") /** * Returns the raw JSON value of [callbacks]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt index 0b461f6c..a9567909 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt @@ -338,14 +338,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAliases(): Optional> = - Optional.ofNullable(keyAliases.getNullable("key_aliases")) + fun keyAliases(): Optional> = keyAliases.getOptional("key_aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keys(): Optional> = Optional.ofNullable(keys.getNullable("keys")) + fun keys(): Optional> = keys.getOptional("keys") /** * Returns the raw JSON value of [keyAliases]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt index b4ce19b0..eb086a96 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt @@ -1115,26 +1115,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -1142,46 +1141,44 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun enforcedParams(): Optional> = - Optional.ofNullable(enforcedParams.getNullable("enforced_params")) + fun enforcedParams(): Optional> = enforcedParams.getOptional("enforced_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun key(): Optional = Optional.ofNullable(key.getNullable("key")) + fun key(): Optional = key.getOptional("key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -1201,7 +1198,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -1209,51 +1206,49 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun sendInviteEmail(): Optional = - Optional.ofNullable(sendInviteEmail.getNullable("send_invite_email")) + fun sendInviteEmail(): Optional = sendInviteEmail.getOptional("send_invite_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [allowedCacheControls]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt index 76002887..ae9c5695 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt @@ -55,25 +55,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun currentPage(): Optional = Optional.ofNullable(currentPage.getNullable("current_page")) + fun currentPage(): Optional = currentPage.getOptional("current_page") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keys(): Optional> = Optional.ofNullable(keys.getNullable("keys")) + fun keys(): Optional> = keys.getOptional("keys") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun totalCount(): Optional = Optional.ofNullable(totalCount.getNullable("total_count")) + fun totalCount(): Optional = totalCount.getOptional("total_count") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun totalPages(): Optional = Optional.ofNullable(totalPages.getNullable("total_pages")) + fun totalPages(): Optional = totalPages.getOptional("total_pages") /** * Returns the raw JSON value of [currentPage]. @@ -748,7 +748,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun token(): Optional = Optional.ofNullable(token.getNullable("token")) + fun token(): Optional = token.getOptional("token") @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases @@ -757,40 +757,39 @@ private constructor( * the server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun allowedModelRegion(): Optional = - Optional.ofNullable(allowedModelRegion.getNullable("allowed_model_region")) + allowedModelRegion.getOptional("allowed_model_region") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun apiKey(): Optional = Optional.ofNullable(apiKey.getNullable("api_key")) + fun apiKey(): Optional = apiKey.getOptional("api_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + budgetResetAt.getOptional("budget_reset_at") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -798,69 +797,65 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun createdBy(): Optional = - Optional.ofNullable(createdBy.getNullable("created_by")) + fun createdBy(): Optional = createdBy.getOptional("created_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun endUserId(): Optional = - Optional.ofNullable(endUserId.getNullable("end_user_id")) + fun endUserId(): Optional = endUserId.getOptional("end_user_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun endUserMaxBudget(): Optional = - Optional.ofNullable(endUserMaxBudget.getNullable("end_user_max_budget")) + endUserMaxBudget.getOptional("end_user_max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun endUserRpmLimit(): Optional = - Optional.ofNullable(endUserRpmLimit.getNullable("end_user_rpm_limit")) + endUserRpmLimit.getOptional("end_user_rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun endUserTpmLimit(): Optional = - Optional.ofNullable(endUserTpmLimit.getNullable("end_user_tpm_limit")) + endUserTpmLimit.getOptional("end_user_tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun expires(): Optional = Optional.ofNullable(expires.getNullable("expires")) + fun expires(): Optional = expires.getOptional("expires") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun keyAlias(): Optional = - Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun keyName(): Optional = Optional.ofNullable(keyName.getNullable("key_name")) + fun keyName(): Optional = keyName.getOptional("key_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun lastRefreshedAt(): Optional = - Optional.ofNullable(lastRefreshedAt.getNullable("last_refreshed_at")) + lastRefreshedAt.getOptional("last_refreshed_at") @JsonProperty("llm_budget_table") @ExcludeMissing @@ -870,15 +865,14 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -892,14 +886,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun models(): Optional> = - Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) + fun orgId(): Optional = orgId.getOptional("org_id") @JsonProperty("parent_otel_span") @ExcludeMissing @@ -911,75 +904,70 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun rpmLimitPerModel(): Optional = - Optional.ofNullable(rpmLimitPerModel.getNullable("rpm_limit_per_model")) + rpmLimitPerModel.getOptional("rpm_limit_per_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun softBudgetCooldown(): Optional = - Optional.ofNullable(softBudgetCooldown.getNullable("soft_budget_cooldown")) + softBudgetCooldown.getOptional("soft_budget_cooldown") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamAlias(): Optional = - Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamBlocked(): Optional = - Optional.ofNullable(teamBlocked.getNullable("team_blocked")) + fun teamBlocked(): Optional = teamBlocked.getOptional("team_blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamMaxBudget(): Optional = - Optional.ofNullable(teamMaxBudget.getNullable("team_max_budget")) + fun teamMaxBudget(): Optional = teamMaxBudget.getOptional("team_max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamMember(): Optional = - Optional.ofNullable(teamMember.getNullable("team_member")) + fun teamMember(): Optional = teamMember.getOptional("team_member") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun teamMemberSpend(): Optional = - Optional.ofNullable(teamMemberSpend.getNullable("team_member_spend")) + teamMemberSpend.getOptional("team_member_spend") @JsonProperty("team_metadata") @ExcludeMissing @@ -993,69 +981,62 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamModels(): Optional> = - Optional.ofNullable(teamModels.getNullable("team_models")) + fun teamModels(): Optional> = teamModels.getOptional("team_models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamRpmLimit(): Optional = - Optional.ofNullable(teamRpmLimit.getNullable("team_rpm_limit")) + fun teamRpmLimit(): Optional = teamRpmLimit.getOptional("team_rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamSpend(): Optional = - Optional.ofNullable(teamSpend.getNullable("team_spend")) + fun teamSpend(): Optional = teamSpend.getOptional("team_spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun teamTpmLimit(): Optional = - Optional.ofNullable(teamTpmLimit.getNullable("team_tpm_limit")) + fun teamTpmLimit(): Optional = teamTpmLimit.getOptional("team_tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun tpmLimitPerModel(): Optional = - Optional.ofNullable(tpmLimitPerModel.getNullable("tpm_limit_per_model")) + tpmLimitPerModel.getOptional("tpm_limit_per_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun updatedAt(): Optional = - Optional.ofNullable(updatedAt.getNullable("updated_at")) + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun updatedBy(): Optional = - Optional.ofNullable(updatedBy.getNullable("updated_by")) + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userEmail(): Optional = - Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Admin Roles: PROXY_ADMIN: admin over the platform PROXY_ADMIN_VIEW_ONLY: can login, @@ -1073,22 +1054,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userRole(): Optional = - Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userRpmLimit(): Optional = - Optional.ofNullable(userRpmLimit.getNullable("user_rpm_limit")) + fun userRpmLimit(): Optional = userRpmLimit.getOptional("user_rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userTpmLimit(): Optional = - Optional.ofNullable(userTpmLimit.getNullable("user_tpm_limit")) + fun userTpmLimit(): Optional = userTpmLimit.getOptional("user_tpm_limit") /** * Returns the raw JSON value of [token]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt index 1179275c..53de2136 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt @@ -1120,26 +1120,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -1147,40 +1146,38 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun enforcedParams(): Optional> = - Optional.ofNullable(enforcedParams.getNullable("enforced_params")) + fun enforcedParams(): Optional> = enforcedParams.getOptional("enforced_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -1200,7 +1197,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -1208,51 +1205,51 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun tempBudgetExpiry(): Optional = - Optional.ofNullable(tempBudgetExpiry.getNullable("temp_budget_expiry")) + tempBudgetExpiry.getOptional("temp_budget_expiry") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun tempBudgetIncrease(): Optional = - Optional.ofNullable(tempBudgetIncrease.getNullable("temp_budget_increase")) + tempBudgetIncrease.getOptional("temp_budget_increase") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [key]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt index 5302f054..895fbd19 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt @@ -144,26 +144,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -171,46 +170,44 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun enforcedParams(): Optional> = - Optional.ofNullable(enforcedParams.getNullable("enforced_params")) + fun enforcedParams(): Optional> = enforcedParams.getOptional("enforced_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun key(): Optional = Optional.ofNullable(key.getNullable("key")) + fun key(): Optional = key.getOptional("key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -226,14 +223,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun newMasterKey(): Optional = - Optional.ofNullable(newMasterKey.getNullable("new_master_key")) + fun newMasterKey(): Optional = newMasterKey.getOptional("new_master_key") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -241,50 +237,49 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun sendInviteEmail(): Optional = - Optional.ofNullable(sendInviteEmail.getNullable("send_invite_email")) + fun sendInviteEmail(): Optional = sendInviteEmail.getOptional("send_invite_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [allowedCacheControls]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt index 5198146a..1f753cfa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt @@ -710,114 +710,103 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiBase(): Optional = Optional.ofNullable(apiBase.getNullable("api_base")) + fun apiBase(): Optional = apiBase.getOptional("api_base") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiKey(): Optional = Optional.ofNullable(apiKey.getNullable("api_key")) + fun apiKey(): Optional = apiKey.getOptional("api_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiVersion(): Optional = - Optional.ofNullable(apiVersion.getNullable("api_version")) + fun apiVersion(): Optional = apiVersion.getOptional("api_version") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsAccessKeyId(): Optional = - Optional.ofNullable(awsAccessKeyId.getNullable("aws_access_key_id")) + fun awsAccessKeyId(): Optional = awsAccessKeyId.getOptional("aws_access_key_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsRegionName(): Optional = - Optional.ofNullable(awsRegionName.getNullable("aws_region_name")) + fun awsRegionName(): Optional = awsRegionName.getOptional("aws_region_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun awsSecretAccessKey(): Optional = - Optional.ofNullable(awsSecretAccessKey.getNullable("aws_secret_access_key")) + awsSecretAccessKey.getOptional("aws_secret_access_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun configurableClientsideAuthParams(): Optional> = - Optional.ofNullable( - configurableClientsideAuthParams.getNullable("configurable_clientside_auth_params") - ) + configurableClientsideAuthParams.getOptional("configurable_clientside_auth_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customLlmProvider(): Optional = - Optional.ofNullable(customLlmProvider.getNullable("custom_llm_provider")) + customLlmProvider.getOptional("custom_llm_provider") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun inputCostPerSecond(): Optional = - Optional.ofNullable(inputCostPerSecond.getNullable("input_cost_per_second")) + inputCostPerSecond.getOptional("input_cost_per_second") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun inputCostPerToken(): Optional = - Optional.ofNullable(inputCostPerToken.getNullable("input_cost_per_token")) + inputCostPerToken.getOptional("input_cost_per_token") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmTraceId(): Optional = - Optional.ofNullable(llmTraceId.getNullable("llm_trace_id")) + fun llmTraceId(): Optional = llmTraceId.getOptional("llm_trace_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxFileSizeMb(): Optional = - Optional.ofNullable(maxFileSizeMb.getNullable("max_file_size_mb")) + fun maxFileSizeMb(): Optional = maxFileSizeMb.getOptional("max_file_size_mb") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxRetries(): Optional = - Optional.ofNullable(maxRetries.getNullable("max_retries")) + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun mergeReasoningContentInChoices(): Optional = - Optional.ofNullable( - mergeReasoningContentInChoices.getNullable("merge_reasoning_content_in_choices") - ) + mergeReasoningContentInChoices.getOptional("merge_reasoning_content_in_choices") @JsonProperty("model_info") @ExcludeMissing fun _modelInfo(): JsonValue = modelInfo @@ -825,89 +814,84 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organization(): Optional = - Optional.ofNullable(organization.getNullable("organization")) + fun organization(): Optional = organization.getOptional("organization") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun outputCostPerSecond(): Optional = - Optional.ofNullable(outputCostPerSecond.getNullable("output_cost_per_second")) + outputCostPerSecond.getOptional("output_cost_per_second") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun outputCostPerToken(): Optional = - Optional.ofNullable(outputCostPerToken.getNullable("output_cost_per_token")) + outputCostPerToken.getOptional("output_cost_per_token") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun regionName(): Optional = - Optional.ofNullable(regionName.getNullable("region_name")) + fun regionName(): Optional = regionName.getOptional("region_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpm(): Optional = Optional.ofNullable(rpm.getNullable("rpm")) + fun rpm(): Optional = rpm.getOptional("rpm") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun streamTimeout(): Optional = - Optional.ofNullable(streamTimeout.getNullable("stream_timeout")) + fun streamTimeout(): Optional = streamTimeout.getOptional("stream_timeout") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) + fun timeout(): Optional = timeout.getOptional("timeout") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpm(): Optional = Optional.ofNullable(tpm.getNullable("tpm")) + fun tpm(): Optional = tpm.getOptional("tpm") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun useInPassThrough(): Optional = - Optional.ofNullable(useInPassThrough.getNullable("use_in_pass_through")) + useInPassThrough.getOptional("use_in_pass_through") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vertexCredentials(): Optional = - Optional.ofNullable(vertexCredentials.getNullable("vertex_credentials")) + vertexCredentials.getOptional("vertex_credentials") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexLocation(): Optional = - Optional.ofNullable(vertexLocation.getNullable("vertex_location")) + fun vertexLocation(): Optional = vertexLocation.getOptional("vertex_location") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexProject(): Optional = - Optional.ofNullable(vertexProject.getNullable("vertex_project")) + fun vertexProject(): Optional = vertexProject.getOptional("vertex_project") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun watsonxRegionName(): Optional = - Optional.ofNullable(watsonxRegionName.getNullable("watsonx_region_name")) + watsonxRegionName.getOptional("watsonx_region_name") /** * Returns the raw JSON value of [model]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt index 2ce4510d..0a946473 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt @@ -70,64 +70,62 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + fun id(): Optional = id.getOptional("id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun baseModel(): Optional = Optional.ofNullable(baseModel.getNullable("base_model")) + fun baseModel(): Optional = baseModel.getOptional("base_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdBy(): Optional = Optional.ofNullable(createdBy.getNullable("created_by")) + fun createdBy(): Optional = createdBy.getOptional("created_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dbModel(): Optional = Optional.ofNullable(dbModel.getNullable("db_model")) + fun dbModel(): Optional = dbModel.getOptional("db_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun teamPublicModelName(): Optional = - Optional.ofNullable(teamPublicModelName.getNullable("team_public_model_name")) + teamPublicModelName.getOptional("team_public_model_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tier(): Optional = Optional.ofNullable(tier.getNullable("tier")) + fun tier(): Optional = tier.getOptional("tier") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedAt(): Optional = - Optional.ofNullable(updatedAt.getNullable("updated_at")) + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedBy(): Optional = Optional.ofNullable(updatedBy.getNullable("updated_by")) + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") /** * Returns the raw JSON value of [id]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt index cb6172c7..a300b9d2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt @@ -54,19 +54,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmParams(): Optional = Optional.ofNullable(llmParams.getNullable("llm_params")) + fun llmParams(): Optional = llmParams.getOptional("llm_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelInfo(): Optional = Optional.ofNullable(modelInfo.getNullable("model_info")) + fun modelInfo(): Optional = modelInfo.getOptional("model_info") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelName(): Optional = Optional.ofNullable(modelName.getNullable("model_name")) + fun modelName(): Optional = modelName.getOptional("model_name") /** * Returns the raw JSON value of [llmParams]. @@ -383,120 +383,109 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiBase(): Optional = Optional.ofNullable(apiBase.getNullable("api_base")) + fun apiBase(): Optional = apiBase.getOptional("api_base") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiKey(): Optional = Optional.ofNullable(apiKey.getNullable("api_key")) + fun apiKey(): Optional = apiKey.getOptional("api_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiVersion(): Optional = - Optional.ofNullable(apiVersion.getNullable("api_version")) + fun apiVersion(): Optional = apiVersion.getOptional("api_version") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsAccessKeyId(): Optional = - Optional.ofNullable(awsAccessKeyId.getNullable("aws_access_key_id")) + fun awsAccessKeyId(): Optional = awsAccessKeyId.getOptional("aws_access_key_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsRegionName(): Optional = - Optional.ofNullable(awsRegionName.getNullable("aws_region_name")) + fun awsRegionName(): Optional = awsRegionName.getOptional("aws_region_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun awsSecretAccessKey(): Optional = - Optional.ofNullable(awsSecretAccessKey.getNullable("aws_secret_access_key")) + awsSecretAccessKey.getOptional("aws_secret_access_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun configurableClientsideAuthParams(): Optional> = - Optional.ofNullable( - configurableClientsideAuthParams.getNullable("configurable_clientside_auth_params") - ) + configurableClientsideAuthParams.getOptional("configurable_clientside_auth_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customLlmProvider(): Optional = - Optional.ofNullable(customLlmProvider.getNullable("custom_llm_provider")) + customLlmProvider.getOptional("custom_llm_provider") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun inputCostPerSecond(): Optional = - Optional.ofNullable(inputCostPerSecond.getNullable("input_cost_per_second")) + inputCostPerSecond.getOptional("input_cost_per_second") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun inputCostPerToken(): Optional = - Optional.ofNullable(inputCostPerToken.getNullable("input_cost_per_token")) + inputCostPerToken.getOptional("input_cost_per_token") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmTraceId(): Optional = - Optional.ofNullable(llmTraceId.getNullable("llm_trace_id")) + fun llmTraceId(): Optional = llmTraceId.getOptional("llm_trace_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxFileSizeMb(): Optional = - Optional.ofNullable(maxFileSizeMb.getNullable("max_file_size_mb")) + fun maxFileSizeMb(): Optional = maxFileSizeMb.getOptional("max_file_size_mb") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxRetries(): Optional = - Optional.ofNullable(maxRetries.getNullable("max_retries")) + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun mergeReasoningContentInChoices(): Optional = - Optional.ofNullable( - mergeReasoningContentInChoices.getNullable("merge_reasoning_content_in_choices") - ) + mergeReasoningContentInChoices.getOptional("merge_reasoning_content_in_choices") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = model.getOptional("model") @JsonProperty("model_info") @ExcludeMissing fun _modelInfo(): JsonValue = modelInfo @@ -504,89 +493,84 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organization(): Optional = - Optional.ofNullable(organization.getNullable("organization")) + fun organization(): Optional = organization.getOptional("organization") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun outputCostPerSecond(): Optional = - Optional.ofNullable(outputCostPerSecond.getNullable("output_cost_per_second")) + outputCostPerSecond.getOptional("output_cost_per_second") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun outputCostPerToken(): Optional = - Optional.ofNullable(outputCostPerToken.getNullable("output_cost_per_token")) + outputCostPerToken.getOptional("output_cost_per_token") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun regionName(): Optional = - Optional.ofNullable(regionName.getNullable("region_name")) + fun regionName(): Optional = regionName.getOptional("region_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpm(): Optional = Optional.ofNullable(rpm.getNullable("rpm")) + fun rpm(): Optional = rpm.getOptional("rpm") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun streamTimeout(): Optional = - Optional.ofNullable(streamTimeout.getNullable("stream_timeout")) + fun streamTimeout(): Optional = streamTimeout.getOptional("stream_timeout") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) + fun timeout(): Optional = timeout.getOptional("timeout") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpm(): Optional = Optional.ofNullable(tpm.getNullable("tpm")) + fun tpm(): Optional = tpm.getOptional("tpm") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun useInPassThrough(): Optional = - Optional.ofNullable(useInPassThrough.getNullable("use_in_pass_through")) + useInPassThrough.getOptional("use_in_pass_through") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vertexCredentials(): Optional = - Optional.ofNullable(vertexCredentials.getNullable("vertex_credentials")) + vertexCredentials.getOptional("vertex_credentials") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexLocation(): Optional = - Optional.ofNullable(vertexLocation.getNullable("vertex_location")) + fun vertexLocation(): Optional = vertexLocation.getOptional("vertex_location") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexProject(): Optional = - Optional.ofNullable(vertexProject.getNullable("vertex_project")) + fun vertexProject(): Optional = vertexProject.getOptional("vertex_project") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun watsonxRegionName(): Optional = - Optional.ofNullable(watsonxRegionName.getNullable("watsonx_region_name")) + watsonxRegionName.getOptional("watsonx_region_name") /** * Returns the raw JSON value of [apiBase]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt index 2d1e9483..08256284 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt @@ -43,13 +43,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [role]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt index dd80c27e..fc3141fd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt @@ -401,7 +401,7 @@ private constructor( * server responded with an unexpected value). */ fun maxBudgetInOrganization(): Optional = - Optional.ofNullable(maxBudgetInOrganization.getNullable("max_budget_in_organization")) + maxBudgetInOrganization.getOptional("max_budget_in_organization") /** * Returns the raw JSON value of [member]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt index b74747cb..1304d25a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt @@ -368,7 +368,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -377,13 +377,13 @@ private constructor( * server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -391,7 +391,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -772,22 +772,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -797,20 +795,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -1253,21 +1250,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -1281,57 +1276,56 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun organizationMemberships(): Optional> = - Optional.ofNullable(organizationMemberships.getNullable("organization_memberships")) + organizationMemberships.getOptional("organization_memberships") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun ssoUserId(): Optional = - Optional.ofNullable(ssoUserId.getNullable("sso_user_id")) + fun ssoUserId(): Optional = ssoUserId.getOptional("sso_user_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [userId]. @@ -1955,8 +1949,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetId(): Optional = - Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -1965,13 +1958,13 @@ private constructor( * the server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -1979,8 +1972,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userRole(): Optional = - Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -2370,21 +2362,20 @@ private constructor( * if the server responded with an unexpected value). */ fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -2394,22 +2385,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun rpmLimit(): Optional = - Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun tpmLimit(): Optional = - Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt index e429d8ef..84f4f74c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt @@ -690,27 +690,26 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -722,33 +721,31 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [organizationAlias]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt index 11ef8d7d..d56ad9d6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt @@ -117,14 +117,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationAlias(): Optional = - Optional.ofNullable(organizationAlias.getNullable("organization_alias")) + fun organizationAlias(): Optional = organizationAlias.getOptional("organization_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * Returns the raw JSON value of [budgetId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt index 56eb3ada..fc6f5bc6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt @@ -326,13 +326,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [organizationId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt index 60e13352..c30c4efd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt @@ -137,14 +137,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -152,27 +151,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationAlias(): Optional = - Optional.ofNullable(organizationAlias.getNullable("organization_alias")) + fun organizationAlias(): Optional = organizationAlias.getOptional("organization_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * Returns the raw JSON value of [budgetId]. @@ -681,21 +678,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -705,20 +701,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -1123,7 +1118,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -1132,13 +1127,13 @@ private constructor( * server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -1146,7 +1141,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -1524,22 +1519,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -1549,20 +1542,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -2018,68 +2010,63 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmModelTable(): Optional = - Optional.ofNullable(llmModelTable.getNullable("llm_model_table")) + fun llmModelTable(): Optional = llmModelTable.getOptional("llm_model_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = - Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -2087,44 +2074,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. @@ -2866,8 +2852,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun modelAliases(): Optional = - Optional.ofNullable(modelAliases.getNullable("model_aliases")) + fun modelAliases(): Optional = modelAliases.getOptional("model_aliases") /** * Returns the raw JSON value of [createdBy]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt index d39d56d1..55671146 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt @@ -137,14 +137,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -152,27 +151,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationAlias(): Optional = - Optional.ofNullable(organizationAlias.getNullable("organization_alias")) + fun organizationAlias(): Optional = organizationAlias.getOptional("organization_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * Returns the raw JSON value of [budgetId]. @@ -681,21 +678,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -705,20 +701,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -1123,7 +1118,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -1132,13 +1127,13 @@ private constructor( * server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -1146,7 +1141,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -1524,22 +1519,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -1549,20 +1542,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -2018,68 +2010,63 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmModelTable(): Optional = - Optional.ofNullable(llmModelTable.getNullable("llm_model_table")) + fun llmModelTable(): Optional = llmModelTable.getOptional("llm_model_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = - Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -2087,44 +2074,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. @@ -2866,8 +2852,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun modelAliases(): Optional = - Optional.ofNullable(modelAliases.getNullable("model_aliases")) + fun modelAliases(): Optional = modelAliases.getOptional("model_aliases") /** * Returns the raw JSON value of [createdBy]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt index 6f25078b..86ce5de1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt @@ -430,7 +430,7 @@ private constructor( * server responded with an unexpected value). */ fun maxBudgetInOrganization(): Optional = - Optional.ofNullable(maxBudgetInOrganization.getNullable("max_budget_in_organization")) + maxBudgetInOrganization.getOptional("max_budget_in_organization") /** * Admin Roles: PROXY_ADMIN: admin over the platform PROXY_ADMIN_VIEW_ONLY: can login, view @@ -447,19 +447,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun role(): Optional = Optional.ofNullable(role.getNullable("role")) + fun role(): Optional = role.getOptional("role") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [organizationId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt index 70b27716..f791ef25 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt @@ -96,7 +96,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -104,14 +104,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -119,7 +118,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -484,21 +483,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -508,20 +506,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt index 4b28e3ae..b15dae1f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt @@ -443,7 +443,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -451,33 +451,32 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun organizationAlias(): Optional = - Optional.ofNullable(organizationAlias.getNullable("organization_alias")) + organizationAlias.getOptional("organization_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedBy(): Optional = Optional.ofNullable(updatedBy.getNullable("updated_by")) + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") /** * Returns the raw JSON value of [budgetId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt index f1d3b100..d0d1724b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt @@ -137,14 +137,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -152,27 +151,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationAlias(): Optional = - Optional.ofNullable(organizationAlias.getNullable("organization_alias")) + fun organizationAlias(): Optional = organizationAlias.getOptional("organization_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * Returns the raw JSON value of [budgetId]. @@ -681,21 +678,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -705,20 +701,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -1123,7 +1118,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -1132,13 +1127,13 @@ private constructor( * server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -1146,7 +1141,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -1524,22 +1519,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -1549,20 +1542,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -2018,68 +2010,63 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmModelTable(): Optional = - Optional.ofNullable(llmModelTable.getNullable("llm_model_table")) + fun llmModelTable(): Optional = llmModelTable.getOptional("llm_model_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = - Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -2087,44 +2074,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. @@ -2866,8 +2852,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun modelAliases(): Optional = - Optional.ofNullable(modelAliases.getNullable("model_aliases")) + fun modelAliases(): Optional = modelAliases.getOptional("model_aliases") /** * Returns the raw JSON value of [createdBy]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt index e32fc3c7..a6608e84 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt @@ -137,14 +137,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -152,27 +151,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationAlias(): Optional = - Optional.ofNullable(organizationAlias.getNullable("organization_alias")) + fun organizationAlias(): Optional = organizationAlias.getOptional("organization_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * Returns the raw JSON value of [budgetId]. @@ -681,21 +678,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -705,20 +701,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -1123,7 +1118,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -1132,13 +1127,13 @@ private constructor( * server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -1146,7 +1141,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -1524,22 +1519,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -1549,20 +1542,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -2018,68 +2010,63 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmModelTable(): Optional = - Optional.ofNullable(llmModelTable.getNullable("llm_model_table")) + fun llmModelTable(): Optional = llmModelTable.getOptional("llm_model_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = - Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -2087,44 +2074,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. @@ -2866,8 +2852,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun modelAliases(): Optional = - Optional.ofNullable(modelAliases.getNullable("model_aliases")) + fun modelAliases(): Optional = modelAliases.getOptional("model_aliases") /** * Returns the raw JSON value of [createdBy]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt index a825c525..34e2dabb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt @@ -37,7 +37,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun providers(): Optional = Optional.ofNullable(providers.getNullable("providers")) + fun providers(): Optional = providers.getOptional("providers") /** * Returns the raw JSON value of [providers]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt index 9964e1ab..47888231 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt @@ -348,14 +348,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun messages(): Optional> = - Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional> = messages.getOptional("messages") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = model.getOptional("model") /** * Returns the raw JSON value of [messages]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt index c768a33a..3573a9be 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt @@ -123,13 +123,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endTime(): Optional = Optional.ofNullable(endTime.getNullable("endTime")) + fun endTime(): Optional = endTime.getOptional("endTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun messages(): Optional = Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional = messages.getOptional("messages") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -141,38 +141,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun response(): Optional = Optional.ofNullable(response.getNullable("response")) + fun response(): Optional = response.getOptional("response") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startTime(): Optional = Optional.ofNullable(startTime.getNullable("startTime")) + fun startTime(): Optional = startTime.getOptional("startTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiBase(): Optional = Optional.ofNullable(apiBase.getNullable("api_base")) + fun apiBase(): Optional = apiBase.getOptional("api_base") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheHit(): Optional = Optional.ofNullable(cacheHit.getNullable("cache_hit")) + fun cacheHit(): Optional = cacheHit.getOptional("cache_hit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheKey(): Optional = Optional.ofNullable(cacheKey.getNullable("cache_key")) + fun cacheKey(): Optional = cacheKey.getOptional("cache_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -180,14 +179,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = model.getOptional("model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") @JsonProperty("request_tags") @ExcludeMissing fun _requestTags(): JsonValue = requestTags @@ -196,25 +194,25 @@ private constructor( * server responded with an unexpected value). */ fun requesterIpAddress(): Optional = - Optional.ofNullable(requesterIpAddress.getNullable("requester_ip_address")) + requesterIpAddress.getOptional("requester_ip_address") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun totalTokens(): Optional = Optional.ofNullable(totalTokens.getNullable("total_tokens")) + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun user(): Optional = Optional.ofNullable(user.getNullable("user")) + fun user(): Optional = user.getOptional("user") /** * Returns the raw JSON value of [apiKey]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt index 5a01976c..fe53cfae 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt @@ -123,13 +123,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endTime(): Optional = Optional.ofNullable(endTime.getNullable("endTime")) + fun endTime(): Optional = endTime.getOptional("endTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun messages(): Optional = Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional = messages.getOptional("messages") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -141,38 +141,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun response(): Optional = Optional.ofNullable(response.getNullable("response")) + fun response(): Optional = response.getOptional("response") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startTime(): Optional = Optional.ofNullable(startTime.getNullable("startTime")) + fun startTime(): Optional = startTime.getOptional("startTime") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun apiBase(): Optional = Optional.ofNullable(apiBase.getNullable("api_base")) + fun apiBase(): Optional = apiBase.getOptional("api_base") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheHit(): Optional = Optional.ofNullable(cacheHit.getNullable("cache_hit")) + fun cacheHit(): Optional = cacheHit.getOptional("cache_hit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cacheKey(): Optional = Optional.ofNullable(cacheKey.getNullable("cache_key")) + fun cacheKey(): Optional = cacheKey.getOptional("cache_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -180,14 +179,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = model.getOptional("model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") @JsonProperty("request_tags") @ExcludeMissing fun _requestTags(): JsonValue = requestTags @@ -196,25 +194,25 @@ private constructor( * server responded with an unexpected value). */ fun requesterIpAddress(): Optional = - Optional.ofNullable(requesterIpAddress.getNullable("requester_ip_address")) + requesterIpAddress.getOptional("requester_ip_address") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun totalTokens(): Optional = Optional.ofNullable(totalTokens.getNullable("total_tokens")) + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun user(): Optional = Optional.ofNullable(user.getNullable("user")) + fun user(): Optional = user.getOptional("user") /** * Returns the raw JSON value of [apiKey]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt index b516b7b1..a1379bfb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt @@ -43,13 +43,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [role]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt index 8530b6f8..70c435af 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt @@ -368,8 +368,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudgetInTeam(): Optional = - Optional.ofNullable(maxBudgetInTeam.getNullable("max_budget_in_team")) + fun maxBudgetInTeam(): Optional = maxBudgetInTeam.getOptional("max_budget_in_team") /** * Returns the raw JSON value of [member]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt index b4a9c9ad..4978542a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt @@ -152,67 +152,63 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmModelTable(): Optional = - Optional.ofNullable(llmModelTable.getNullable("llm_model_table")) + fun llmModelTable(): Optional = llmModelTable.getOptional("llm_model_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -220,44 +216,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. @@ -1066,7 +1061,7 @@ private constructor( * server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is @@ -1339,22 +1334,20 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -1364,20 +1357,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -1820,21 +1812,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -1848,57 +1838,56 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun organizationMemberships(): Optional> = - Optional.ofNullable(organizationMemberships.getNullable("organization_memberships")) + organizationMemberships.getOptional("organization_memberships") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun ssoUserId(): Optional = - Optional.ofNullable(ssoUserId.getNullable("sso_user_id")) + fun ssoUserId(): Optional = ssoUserId.getOptional("sso_user_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [userId]. @@ -2522,8 +2511,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun budgetId(): Optional = - Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") /** * Represents user-controllable params for a LLM_BudgetTable record @@ -2532,13 +2520,13 @@ private constructor( * the server responded with an unexpected value). */ fun llmBudgetTable(): Optional = - Optional.ofNullable(llmBudgetTable.getNullable("llm_budget_table")) + llmBudgetTable.getOptional("llm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user @@ -2546,8 +2534,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userRole(): Optional = - Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [createdAt]. @@ -2937,21 +2924,20 @@ private constructor( * if the server responded with an unexpected value). */ fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun maxBudget(): Optional = - Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("model_max_budget") @ExcludeMissing @@ -2961,22 +2947,19 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun rpmLimit(): Optional = - Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun softBudget(): Optional = - Optional.ofNullable(softBudget.getNullable("soft_budget")) + fun softBudget(): Optional = softBudget.getOptional("soft_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun tpmLimit(): Optional = - Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [budgetDuration]. @@ -3396,8 +3379,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelAliases(): Optional = - Optional.ofNullable(modelAliases.getNullable("model_aliases")) + fun modelAliases(): Optional = modelAliases.getOptional("model_aliases") /** * Returns the raw JSON value of [createdBy]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt index b34443bf..b59dcc58 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt @@ -819,47 +819,44 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = - Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -869,44 +866,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [admins]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt index e03eeabd..be784342 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt @@ -129,67 +129,63 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun admins(): Optional> = Optional.ofNullable(admins.getNullable("admins")) + fun admins(): Optional> = admins.getOptional("admins") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetResetAt(): Optional = - Optional.ofNullable(budgetResetAt.getNullable("budget_reset_at")) + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdAt(): Optional = - Optional.ofNullable(createdAt.getNullable("created_at")) + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmModelTable(): Optional = - Optional.ofNullable(llmModelTable.getNullable("llm_model_table")) + fun llmModelTable(): Optional = llmModelTable.getOptional("llm_model_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun members(): Optional> = Optional.ofNullable(members.getNullable("members")) + fun members(): Optional> = members.getOptional("members") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun membersWithRoles(): Optional> = - Optional.ofNullable(membersWithRoles.getNullable("members_with_roles")) + membersWithRoles.getOptional("members_with_roles") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -197,44 +193,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelId(): Optional = Optional.ofNullable(modelId.getNullable("model_id")) + fun modelId(): Optional = modelId.getOptional("model_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. @@ -958,8 +953,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun modelAliases(): Optional = - Optional.ofNullable(modelAliases.getNullable("model_aliases")) + fun modelAliases(): Optional = modelAliases.getOptional("model_aliases") /** * Returns the raw JSON value of [createdBy]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt index ab62ab6b..dc78a7b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt @@ -336,13 +336,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [teamId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt index af2927f9..e47f1551 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt @@ -399,26 +399,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudgetInTeam(): Optional = - Optional.ofNullable(maxBudgetInTeam.getNullable("max_budget_in_team")) + fun maxBudgetInTeam(): Optional = maxBudgetInTeam.getOptional("max_budget_in_team") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun role(): Optional = Optional.ofNullable(role.getNullable("role")) + fun role(): Optional = role.getOptional("role") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [teamId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt index 08014a18..cbb239de 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt @@ -52,14 +52,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudgetInTeam(): Optional = - Optional.ofNullable(maxBudgetInTeam.getNullable("max_budget_in_team")) + fun maxBudgetInTeam(): Optional = maxBudgetInTeam.getOptional("max_budget_in_team") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * Returns the raw JSON value of [teamId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt index 60733ae5..74d8d82c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt @@ -731,27 +731,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -761,38 +759,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organizationId(): Optional = - Optional.ofNullable(organizationId.getNullable("organization_id")) + fun organizationId(): Optional = organizationId.getOptional("organization_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamAlias(): Optional = Optional.ofNullable(teamAlias.getNullable("team_alias")) + fun teamAlias(): Optional = teamAlias.getOptional("team_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * Returns the raw JSON value of [teamId]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt index bee18451..2e04e928 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt @@ -418,8 +418,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun callbackType(): Optional = - Optional.ofNullable(callbackType.getNullable("callback_type")) + fun callbackType(): Optional = callbackType.getOptional("callback_type") /** * Returns the raw JSON value of [callbackName]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt index d9c33440..70be65fb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt @@ -1075,27 +1075,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun autoCreateKey(): Optional = - Optional.ofNullable(autoCreateKey.getNullable("auto_create_key")) + fun autoCreateKey(): Optional = autoCreateKey.getOptional("auto_create_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -1103,33 +1101,32 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -1149,7 +1146,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -1157,62 +1154,61 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun sendInviteEmail(): Optional = - Optional.ofNullable(sendInviteEmail.getNullable("send_invite_email")) + fun sendInviteEmail(): Optional = sendInviteEmail.getOptional("send_invite_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userAlias(): Optional = Optional.ofNullable(userAlias.getNullable("user_alias")) + fun userAlias(): Optional = userAlias.getOptional("user_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [allowedCacheControls]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt index e751d62c..0e7a4485 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt @@ -166,7 +166,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun expires(): Optional = Optional.ofNullable(expires.getNullable("expires")) + fun expires(): Optional = expires.getOptional("expires") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -178,7 +178,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun token(): Optional = Optional.ofNullable(token.getNullable("token")) + fun token(): Optional = token.getOptional("token") @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases @@ -187,26 +187,25 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetId(): Optional = Optional.ofNullable(budgetId.getNullable("budget_id")) + fun budgetId(): Optional = budgetId.getOptional("budget_id") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -214,39 +213,37 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun createdBy(): Optional = Optional.ofNullable(createdBy.getNullable("created_by")) + fun createdBy(): Optional = createdBy.getOptional("created_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun enforcedParams(): Optional> = - Optional.ofNullable(enforcedParams.getNullable("enforced_params")) + fun enforcedParams(): Optional> = enforcedParams.getOptional("enforced_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyName(): Optional = Optional.ofNullable(keyName.getNullable("key_name")) + fun keyName(): Optional = keyName.getOptional("key_name") @JsonProperty("llm_budget_table") @ExcludeMissing @@ -256,14 +253,14 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -279,7 +276,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -287,73 +284,73 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + fun tags(): Optional> = tags.getOptional("tags") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teams(): Optional> = Optional.ofNullable(teams.getNullable("teams")) + fun teams(): Optional> = teams.getOptional("teams") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tokenId(): Optional = Optional.ofNullable(tokenId.getNullable("token_id")) + fun tokenId(): Optional = tokenId.getOptional("token_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedBy(): Optional = Optional.ofNullable(updatedBy.getNullable("updated_by")) + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userAlias(): Optional = Optional.ofNullable(userAlias.getNullable("user_alias")) + fun userAlias(): Optional = userAlias.getOptional("user_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [expires]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt index 1166df9d..159b5572 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt @@ -938,20 +938,19 @@ private constructor( * server responded with an unexpected value). */ fun allowedCacheControls(): Optional> = - Optional.ofNullable(allowedCacheControls.getNullable("allowed_cache_controls")) + allowedCacheControls.getOptional("allowed_cache_controls") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun blocked(): Optional = Optional.ofNullable(blocked.getNullable("blocked")) + fun blocked(): Optional = blocked.getOptional("blocked") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = - Optional.ofNullable(budgetDuration.getNullable("budget_duration")) + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config @@ -959,33 +958,32 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + fun duration(): Optional = duration.getOptional("duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun guardrails(): Optional> = - Optional.ofNullable(guardrails.getNullable("guardrails")) + fun guardrails(): Optional> = guardrails.getOptional("guardrails") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun keyAlias(): Optional = Optional.ofNullable(keyAlias.getNullable("key_alias")) + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = Optional.ofNullable(maxBudget.getNullable("max_budget")) + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun maxParallelRequests(): Optional = - Optional.ofNullable(maxParallelRequests.getNullable("max_parallel_requests")) + maxParallelRequests.getOptional("max_parallel_requests") @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata @@ -1005,13 +1003,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun models(): Optional> = Optional.ofNullable(models.getNullable("models")) + fun models(): Optional> = models.getOptional("models") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun password(): Optional = Optional.ofNullable(password.getNullable("password")) + fun password(): Optional = password.getOptional("password") @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions @@ -1019,43 +1017,43 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpmLimit(): Optional = Optional.ofNullable(rpmLimit.getNullable("rpm_limit")) + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun spend(): Optional = Optional.ofNullable(spend.getNullable("spend")) + fun spend(): Optional = spend.getOptional("spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun teamId(): Optional = Optional.ofNullable(teamId.getNullable("team_id")) + fun teamId(): Optional = teamId.getOptional("team_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpmLimit(): Optional = Optional.ofNullable(tpmLimit.getNullable("tpm_limit")) + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userEmail(): Optional = Optional.ofNullable(userEmail.getNullable("user_email")) + fun userEmail(): Optional = userEmail.getOptional("user_email") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + fun userId(): Optional = userId.getOptional("user_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userRole(): Optional = Optional.ofNullable(userRole.getNullable("user_role")) + fun userRole(): Optional = userRole.getOptional("user_role") /** * Returns the raw JSON value of [allowedCacheControls]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt index 04b16b59..78d00730 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt @@ -329,14 +329,13 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun messages(): Optional> = - Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional> = messages.getOptional("messages") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) + fun prompt(): Optional = prompt.getOptional("prompt") /** * Returns the raw JSON value of [model]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt index 8695f360..2c103b1f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt @@ -43,14 +43,14 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = Optional.ofNullable(error.getNullable("error")) + fun error(): Optional = error.getOptional("error") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun rawRequestApiBase(): Optional = - Optional.ofNullable(rawRequestApiBase.getNullable("raw_request_api_base")) + rawRequestApiBase.getOptional("raw_request_api_base") @JsonProperty("raw_request_body") @ExcludeMissing From becb670d92fab9e105289da811f8b2ce3c63d776 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 03:20:37 +0000 Subject: [PATCH 11/75] fix(client): return `Optional` instead of `Optional` (#19) docs: add comments to `JsonField` classes --- .../main/kotlin/ai/hanzo/api/core/Values.kt | 237 ++++++++++++++++-- 1 file changed, 218 insertions(+), 19 deletions(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt index fe3fe016..0e5ad6e4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt @@ -29,30 +29,51 @@ import java.io.InputStream import java.util.Objects import java.util.Optional +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ @JsonDeserialize(using = JsonField.Deserializer::class) sealed class JsonField { + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ fun isMissing(): Boolean = this is JsonMissing + /** Whether this field is explicitly set to `null`. */ fun isNull(): Boolean = this is JsonNull - fun asKnown(): Optional = - when (this) { - is KnownValue -> Optional.of(value) - else -> Optional.empty() - } + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return an empty `Optional`, otherwise the returned `Optional` is given - * a `JsonValue`. + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. */ - fun asUnknown(): Optional = - when (this) { - is JsonValue -> Optional.of(this) - else -> Optional.empty() - } + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ fun asBoolean(): Optional = when (this) { is JsonBoolean -> Optional.of(value) @@ -60,6 +81,12 @@ sealed class JsonField { else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ fun asNumber(): Optional = when (this) { is JsonNumber -> Optional.of(value) @@ -67,6 +94,12 @@ sealed class JsonField { else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ fun asString(): Optional = when (this) { is JsonString -> Optional.of(value) @@ -77,6 +110,12 @@ sealed class JsonField { fun asStringOrThrow(): String = asString().orElseThrow { HanzoInvalidDataException("Value is not a string") } + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ fun asArray(): Optional> = when (this) { is JsonArray -> Optional.of(values) @@ -95,6 +134,12 @@ sealed class JsonField { else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ fun asObject(): Optional> = when (this) { is JsonObject -> Optional.of(values) @@ -132,7 +177,13 @@ sealed class JsonField { } @JvmSynthetic - internal fun getOptional(name: String): Optional<@UnsafeVariance T> = + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = when (this) { is KnownValue -> Optional.of(value) is JsonMissing, @@ -147,21 +198,33 @@ sealed class JsonField { is JsonValue -> this } - @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + @JvmSynthetic internal fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + /** Returns the result of calling the [visitor] method corresponding to this field's state. */ fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) is JsonValue -> accept(visitor as JsonValue.Visitor) } + /** + * An interface that defines how to map each possible state of a `JsonField` to a value of + * type [R]. + */ interface Visitor : JsonValue.Visitor { + fun visitKnown(value: T): R = visitDefault() } companion object { + + /** Returns a [JsonField] containing the given "known" [value]. */ @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + /** + * Returns a [JsonField] containing the given "known" [value], or [JsonNull] if [value] is + * null. + */ @JvmStatic fun ofNullable(value: T?): JsonField = when (value) { @@ -176,6 +239,7 @@ sealed class JsonField { * annotation. */ class IsMissing { + override fun equals(other: Any?): Boolean = other is JsonMissing override fun hashCode(): Int = Objects.hash() @@ -197,6 +261,12 @@ sealed class JsonField { } } +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ @JsonDeserialize(using = JsonValue.Deserializer::class) sealed class JsonValue : JsonField() { @@ -204,6 +274,7 @@ sealed class JsonValue : JsonField() { fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ fun accept(visitor: Visitor): R = when (this) { is JsonMissing -> visitor.visitMissing() @@ -215,7 +286,12 @@ sealed class JsonValue : JsonField() { is JsonObject -> visitor.visitObject(values) } + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ interface Visitor { + fun visitNull(): R = visitDefault() fun visitMissing(): R = visitDefault() @@ -230,15 +306,52 @@ sealed class JsonValue : JsonField() { fun visitObject(values: Map): R = visitDefault() - fun visitDefault(): R { - throw RuntimeException("Unexpected value") - } + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") } companion object { private val JSON_MAPPER = jsonMapper() + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ @JvmStatic fun from(value: Any?): JsonValue = when (value) { @@ -247,6 +360,11 @@ sealed class JsonValue : JsonField() { else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) } + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ @JvmStatic fun fromJsonNode(node: JsonNode): JsonValue = when (node.nodeType) { @@ -268,12 +386,19 @@ sealed class JsonValue : JsonField() { } class Deserializer : BaseDeserializer(JsonValue::class) { + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() } } +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `JsonField`. + */ class KnownValue private constructor( @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T @@ -292,44 +417,59 @@ private constructor( override fun toString() = value.contentToString() companion object { + + /** Returns a [KnownValue] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) } } +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ @JsonSerialize(using = JsonMissing.Serializer::class) class JsonMissing : JsonValue() { override fun toString() = "" companion object { + private val INSTANCE: JsonMissing = JsonMissing() + /** Returns the singleton instance of [JsonMissing]. */ @JvmStatic fun of() = INSTANCE } class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( value: JsonMissing, generator: JsonGenerator, provider: SerializerProvider, ) { - throw RuntimeException("JsonMissing cannot be serialized") + throw IllegalStateException("JsonMissing cannot be serialized") } } } +/** A [JsonValue] representing a JSON `null` value. */ @JsonSerialize(using = NullSerializer::class) class JsonNull : JsonValue() { override fun toString() = "null" companion object { + private val INSTANCE: JsonNull = JsonNull() + /** Returns the singleton instance of [JsonMissing]. */ @JsonCreator @JvmStatic fun of() = INSTANCE } } +/** A [JsonValue] representing a JSON boolean value. */ class JsonBoolean private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean @@ -348,14 +488,18 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) } } +/** A [JsonValue] representing a JSON number value. */ class JsonNumber private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number ) : JsonValue() { + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -369,10 +513,13 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) } } +/** A [JsonValue] representing a JSON string value. */ class JsonString private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String @@ -391,10 +538,13 @@ private constructor( override fun toString() = value companion object { + + /** Returns a [JsonString] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) } } +/** A [JsonValue] representing a JSON array value. */ class JsonArray private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -415,10 +565,13 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonArray] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } +/** A [JsonValue] representing a JSON object value. */ class JsonObject private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -439,32 +592,62 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonObject] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: Map) = JsonObject(values.toImmutable()) } } +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ @JacksonAnnotationsInside @JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) annotation class ExcludeMissing +/** A class representing a field in a `multipart/form-data` request. */ class MultipartField private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ @get:JvmName("contentType") val contentType: String, private val filename: String?, ) { companion object { + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ @JvmStatic fun of(value: T?) = builder().value(value).build() + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ @JvmStatic fun of(value: JsonField) = builder().value(value).build() + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ @JvmStatic fun builder() = Builder() } + /** Returns the filename directive that will be included in the serialized field. */ fun filename(): Optional = Optional.ofNullable(filename) @JvmSynthetic @@ -486,8 +669,24 @@ private constructor( fun filename(filename: String?) = apply { this.filename = filename } + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ fun filename(filename: Optional) = filename(filename.orElse(null)) + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): MultipartField { val value = checkRequired("value", value) return MultipartField( From 4dc5520842ee6f01676aa386177d8924430fc3fa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 03:31:36 +0000 Subject: [PATCH 12/75] docs: swap examples used in readme (#20) docs: document how to forcibly omit required field --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f4d674b8..9bcadc09 100644 --- a/README.md +++ b/README.md @@ -449,6 +449,20 @@ JsonValue complexValue = JsonValue.from(Map.of( )); ``` +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. + +To forcibly omit a required parameter or property, pass [`JsonMissing`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Values.kt): + +```java +import ai.hanzo.api.core.JsonMissing; +import ai.hanzo.api.models.ClientGetHomeParams; +import ai.hanzo.api.models.openai.OpenAICreateParams; + +ClientGetHomeParams params = OpenAICreateParams.builder() + .endpoint(JsonMissing.of()) + .build(); +``` + ### Response properties To access undocumented response properties, call the `_additionalProperties()` method: From f78cf68558f7749e083b48869da2c01d91561691 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 03:27:52 +0000 Subject: [PATCH 13/75] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 53107a1b..bb9fef09 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-ec4be99f95dc46e9442eb60f233b2bff271d6f5bf57d7c61a52bc4804f55bbd1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-ec4be99f95dc46e9442eb60f233b2bff271d6f5bf57d7c61a52bc4804f55bbd1.yml openapi_spec_hash: 87bc62c36bb6028ffd1f3e54a2809099 config_hash: 830747463ff4d018b5633ce511e88558 From 7b40d13ad642b0db4f872cf54cb0e75a8fb5fc1c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 03:55:30 +0000 Subject: [PATCH 14/75] feat(client): support setting base URL via env var --- README.md | 17 +++++++++-------- .../api/client/okhttp/HanzoOkHttpClient.kt | 8 ++------ .../api/client/okhttp/HanzoOkHttpClientAsync.kt | 8 ++------ .../kotlin/ai/hanzo/api/core/ClientOptions.kt | 7 ++++++- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9bcadc09..5b7b56d1 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; -// Configures using the `HANZO_API_KEY` environment variable +// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClient client = HanzoOkHttpClient.fromEnv(); ClientGetHomeResponse response = client.getHome(); @@ -67,7 +67,7 @@ Configure the client using environment variables: import ai.hanzo.api.client.HanzoClient; import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; -// Configures using the `HANZO_API_KEY` environment variable +// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClient client = HanzoOkHttpClient.fromEnv(); ``` @@ -89,7 +89,7 @@ import ai.hanzo.api.client.HanzoClient; import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; HanzoClient client = HanzoOkHttpClient.builder() - // Configures using the `HANZO_API_KEY` environment variable + // Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables .fromEnv() .apiKey("My API Key") .build(); @@ -97,9 +97,10 @@ HanzoClient client = HanzoOkHttpClient.builder() See this table for the available options: -| Setter | Environment variable | Required | Default value | -| -------- | -------------------- | -------- | ------------- | -| `apiKey` | `HANZO_API_KEY` | true | - | +| Setter | Environment variable | Required | Default value | +| --------- | -------------------- | -------- | ------------------------ | +| `apiKey` | `HANZO_API_KEY` | true | - | +| `baseUrl` | `HANZO_BASE_URL` | true | `"https://api.hanzo.ai"` | > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -130,7 +131,7 @@ import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; import java.util.concurrent.CompletableFuture; -// Configures using the `HANZO_API_KEY` environment variable +// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClient client = HanzoOkHttpClient.fromEnv(); CompletableFuture response = client.async().getHome(); @@ -145,7 +146,7 @@ import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; import java.util.concurrent.CompletableFuture; -// Configures using the `HANZO_API_KEY` environment variable +// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClientAsync client = HanzoOkHttpClientAsync.fromEnv(); CompletableFuture response = client.getHome(); diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt index 1965d611..77b25cb0 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt @@ -27,16 +27,12 @@ class HanzoOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) } - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -169,7 +165,7 @@ class HanzoOkHttpClient private constructor() { clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt index 68a77b16..01a34f83 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt @@ -27,16 +27,12 @@ class HanzoOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) } - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -169,7 +165,7 @@ class HanzoOkHttpClientAsync private constructor() { clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt index e67044be..9921cadd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt @@ -186,7 +186,12 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun fromEnv() = apply { System.getenv("HANZO_API_KEY")?.let { apiKey(it) } } + fun baseUrl(): String = baseUrl + + fun fromEnv() = apply { + System.getenv("HANZO_BASE_URL")?.let { baseUrl(it) } + System.getenv("HANZO_API_KEY")?.let { apiKey(it) } + } /** * Returns an immutable instance of [ClientOptions]. From 1eddeb17b64eb80f6db6969d181c8f48ec9a08a6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 04:01:31 +0000 Subject: [PATCH 15/75] chore(internal): expand CI branch coverage --- .github/workflows/ci.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94046873..5a6ae118 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,18 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'preview-head/**' + - 'preview-base/**' + - 'preview/**' jobs: lint: name: lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 @@ -34,7 +34,6 @@ jobs: test: name: test runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 From 21f5b79e8a12fb75bb6ea91fc46173f4fed1fc8f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 04:11:06 +0000 Subject: [PATCH 16/75] fix(client): bump to better jackson version --- hanzo-java-core/build.gradle.kts | 12 ++++++------ .../src/main/kotlin/ai/hanzo/api/core/Check.kt | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hanzo-java-core/build.gradle.kts b/hanzo-java-core/build.gradle.kts index ba424864..78e32327 100644 --- a/hanzo-java-core/build.gradle.kts +++ b/hanzo-java-core/build.gradle.kts @@ -17,14 +17,14 @@ configurations.all { } dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.18.1") - api("com.fasterxml.jackson.core:jackson-databind:2.18.1") + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") api("com.google.errorprone:error_prone_annotations:2.33.0") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt index 48b8a942..5f417c5b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt @@ -47,6 +47,7 @@ internal fun checkMaxLength(name: String, value: String, maxLength: Int): String internal fun checkJacksonVersionCompatibility() { val incompatibleJacksonVersions = RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] when { it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> it to "incompatible major version" @@ -55,6 +56,7 @@ internal fun checkJacksonVersionCompatibility() { it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> it to "patch version too low" + badVersionReason != null -> it to badVersionReason else -> null } } @@ -77,6 +79,8 @@ Double-check that you are depending on compatible Jackson versions. } private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") private val RUNTIME_JACKSON_VERSIONS: List = listOf( com.fasterxml.jackson.core.json.PackageVersion.VERSION, From c8a88d7303cd41aada70dea065bb8a51522c3373 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 04:39:56 +0000 Subject: [PATCH 17/75] chore(internal): reduce CI branch coverage --- .github/workflows/ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a6ae118..ebbaa260 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,17 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'preview-head/**' - - 'preview-base/**' - - 'preview/**' + branches: + - main + pull_request: + branches: + - main + - next jobs: lint: name: lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 From c878297f959b3215eacb52b1579d4dc0eae1f79b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 15 Apr 2025 04:52:00 +0000 Subject: [PATCH 18/75] docs: update documentation links to be more uniform --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b7b56d1..a6f61808 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.2). +The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai). Javadocs are available on [javadoc.io](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.2). From b2310d32ce73c02a5942f04fbfc66d38c6c371d7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 03:50:39 +0000 Subject: [PATCH 19/75] docs(client): update jackson compat error message --- hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt index 5f417c5b..a5d1ddab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt @@ -62,7 +62,7 @@ internal fun checkJacksonVersionCompatibility() { } check(incompatibleJacksonVersions.isEmpty()) { """ -This SDK depends on Jackson version $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: +This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: ${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" From b62faed4882e4f2a39014a11fda5297c09269a07 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 03:56:58 +0000 Subject: [PATCH 20/75] docs: explain jackson compat in readme --- README.md | 11 +++++++++++ .../src/main/kotlin/ai/hanzo/api/core/Check.kt | 2 ++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index a6f61808..0e1b70ae 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,17 @@ Or to `debug` for more verbose logging: $ export HANZO_LOG=debug ``` +## Jackson + +The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. + +The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). + +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`HanzoOkHttpClient`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt) or [`HanzoOkHttpClientAsync`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt). + +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. + ## Network options ### Retries diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt index a5d1ddab..1ec69198 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt @@ -73,6 +73,8 @@ This can happen if you are either: 2. Depending on some library that depends on different Jackson versions, potentially transitively Double-check that you are depending on compatible Jackson versions. + +See https://www.github.com/hanzoai/java-sdk#jackson for more information. """ .trimIndent() } From 668e12a649f917543d6a44810cdce0f035993afe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 03:50:39 +0000 Subject: [PATCH 21/75] perf(internal): improve compilation+test speed --- .github/workflows/publish-sonatype.yml | 2 +- .../src/main/kotlin/hanzo.kotlin.gradle.kts | 9 +-- gradle.properties | 16 +++++- .../hanzo/api/core/http/RetryingHttpClient.kt | 56 ++++++++++++------- .../ai/hanzo/api/core/PhantomReachableTest.kt | 2 +- .../ai/hanzo/api/core/http/HeadersTest.kt | 32 ----------- .../ai/hanzo/api/core/http/QueryParamsTest.kt | 32 ----------- .../api/core/http/RetryingHttpClientTest.kt | 36 ++++++++---- .../hanzo/api/services/ErrorHandlingTest.kt | 2 + .../hanzo/api/services/ServiceParamsTest.kt | 2 + 10 files changed, 85 insertions(+), 104 deletions(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 32aaa7ad..17bad012 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.HANZO_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.HANZO_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts index 3f7ee106..793cdbc4 100644 --- a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts @@ -9,7 +9,7 @@ plugins { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } compilerOptions { @@ -19,6 +19,8 @@ kotlin { // Suppress deprecation warnings because we may still reference and test deprecated members. // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. "-nowarn", + // Use as many threads as there are CPU cores on the machine for compilation. + "-Xbackend-threads=0", ) jvmTarget.set(JvmTarget.JVM_1_8) languageVersion.set(KotlinVersion.KOTLIN_1_8) @@ -34,8 +36,7 @@ configure { } } -// Run tests in parallel to some degree. tasks.withType().configureEach { - maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) - forkEvery = 100 + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } diff --git a/gradle.properties b/gradle.properties index 0c8d4ded..ff76593f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,17 @@ org.gradle.caching=true +org.gradle.configuration-cache=true org.gradle.parallel=true org.gradle.daemon=false -org.gradle.jvmargs=-Xmx4g -kotlin.daemon.jvmargs=-Xmx4g +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms1g \ + -Xmx4g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=256m \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt index 8c020af5..6bc34a62 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt @@ -23,6 +23,7 @@ import kotlin.math.pow class RetryingHttpClient private constructor( private val httpClient: HttpClient, + private val sleeper: Sleeper, private val clock: Clock, private val maxRetries: Int, private val idempotencyHeader: String?, @@ -62,10 +63,10 @@ private constructor( null } - val backoffMillis = getRetryBackoffMillis(retries, response) + val backoffDuration = getRetryBackoffDuration(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() - Thread.sleep(backoffMillis.toMillis()) + sleeper.sleep(backoffDuration) } } @@ -111,10 +112,10 @@ private constructor( } } - val backoffMillis = getRetryBackoffMillis(retries, response) + val backoffDuration = getRetryBackoffDuration(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() - return sleepAsync(backoffMillis.toMillis()).thenCompose { + return sleeper.sleepAsync(backoffDuration).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } } @@ -179,7 +180,7 @@ private constructor( // retried. throwable is IOException || throwable is HanzoIoException - private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After response @@ -226,33 +227,40 @@ private constructor( companion object { - private val TIMER = Timer("RetryingHttpClient", true) - - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis, - ) - return future - } - @JvmStatic fun builder() = Builder() } class Builder internal constructor() { private var httpClient: HttpClient? = null + private var sleeper: Sleeper = + object : Sleeper { + + private val timer = Timer("RetryingHttpClient", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + } private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun clock(clock: Clock) = apply { this.clock = clock } fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } @@ -262,9 +270,17 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), + sleeper, clock, maxRetries, idempotencyHeader, ) } + + internal interface Sleeper { + + fun sleep(duration: Duration) + + fun sleepAsync(duration: Duration): CompletableFuture + } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/PhantomReachableTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/PhantomReachableTest.kt index 5777390b..4873e575 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/PhantomReachableTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/PhantomReachableTest.kt @@ -20,7 +20,7 @@ internal class PhantomReachableTest { assertThat(closed).isFalse() System.gc() - Thread.sleep(3000) + Thread.sleep(100) assertThat(closed).isTrue() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/HeadersTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/HeadersTest.kt index 29fc78dc..25aaefd6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/HeadersTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/HeadersTest.kt @@ -1,8 +1,6 @@ package ai.hanzo.api.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -241,34 +239,4 @@ internal class HeadersTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun namesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - val headerNamesCopy = headers.names().toSet() - - val throwable = catchThrowable { - (headers.names() as MutableSet).add("another name") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.names()).isEqualTo(headerNamesCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - assumeThat(headers.size).isNotEqualTo(0) - val name = headers.names().first() - val headerValuesCopy = headers.values(name).toList() - - val throwable = catchThrowable { - (headers.values(name) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.values(name)).isEqualTo(headerValuesCopy) - } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/QueryParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/QueryParamsTest.kt index 0094b4c3..277375f4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/QueryParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/QueryParamsTest.kt @@ -1,8 +1,6 @@ package ai.hanzo.api.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -179,34 +177,4 @@ internal class QueryParamsTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun keysAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - val queryParamKeysCopy = queryParams.keys().toSet() - - val throwable = catchThrowable { - (queryParams.keys() as MutableSet).add("another key") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.keys()).isEqualTo(queryParamKeysCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - assumeThat(queryParams.size).isNotEqualTo(0) - val key = queryParams.keys().first() - val queryParamValuesCopy = queryParams.values(key).toList() - - val throwable = catchThrowable { - (queryParams.values(key) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.values(key)).isEqualTo(queryParamValuesCopy) - } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt index 8fda859d..72ebdb82 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt @@ -7,13 +7,16 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import java.io.InputStream +import java.time.Duration import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.parallel.ResourceLock import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class RetryingHttpClientTest { private var openResponseCount = 0 @@ -24,6 +27,7 @@ internal class RetryingHttpClientTest { val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() httpClient = object : HttpClient { + override fun execute( request: HttpRequest, requestOptions: RequestOptions, @@ -40,6 +44,7 @@ internal class RetryingHttpClientTest { private fun trackClose(response: HttpResponse): HttpResponse { openResponseCount++ return object : HttpResponse { + private var isClosed = false override fun statusCode(): Int = response.statusCode() @@ -66,7 +71,7 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() + val retryingClient = retryingHttpClientBuilder().build() val response = retryingClient.execute( @@ -88,11 +93,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) ) val retryingClient = - RetryingHttpClient.builder() - .httpClient(httpClient) - .maxRetries(2) - .idempotencyHeader("X-Some-Header") - .build() + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() val response = retryingClient.execute( @@ -134,8 +135,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = retryingClient.execute( @@ -181,8 +181,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = retryingClient.execute( @@ -220,8 +219,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() val response = retryingClient.execute( @@ -234,6 +232,20 @@ internal class RetryingHttpClientTest { assertNoResponseLeaks() } + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt index a42afd95..5d64ae50 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt @@ -28,8 +28,10 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class ErrorHandlingTest { companion object { diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt index d5a2c865..832da4d1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt @@ -17,8 +17,10 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class ServiceParamsTest { private lateinit var client: HanzoClient From e43d6381ec86c1c7372e03fede163b2bd4fa673a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 04:02:21 +0000 Subject: [PATCH 22/75] docs: explain http client customization --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 0e1b70ae..55805c54 100644 --- a/README.md +++ b/README.md @@ -378,6 +378,42 @@ HanzoClient client = HanzoOkHttpClient.builder() .build(); ``` +### Custom HTTP client + +The SDK consists of three artifacts: + +- `hanzo-java-core` + - Contains core SDK logic + - Does not depend on [OkHttp](https://square.github.io/okhttp) + - Exposes [`HanzoClient`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt), [`HanzoClientAsync`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt), [`HanzoClientImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt), and [`HanzoClientAsyncImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt), all of which can work with any HTTP client +- `hanzo-java-client-okhttp` + - Depends on [OkHttp](https://square.github.io/okhttp) + - Exposes [`HanzoOkHttpClient`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt) and [`HanzoOkHttpClientAsync`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt), which provide a way to construct [`HanzoClientImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt) and [`HanzoClientAsyncImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt), respectively, using OkHttp +- `hanzo-java` + - Depends on and exposes the APIs of both `hanzo-java-core` and `hanzo-java-client-okhttp` + - Does not have its own logic + +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. + +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) + +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. + +To use a customized `OkHttpClient`: + +1. Replace your [`hanzo-java` dependency](#installation) with `hanzo-java-core` +2. Copy `hanzo-java-client-okhttp`'s [`OkHttpClient`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`HanzoClientImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt) or [`HanzoClientAsyncImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt), similarly to [`HanzoOkHttpClient`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt) or [`HanzoOkHttpClientAsync`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt), using your customized client + +### Completely custom HTTP client + +To use a completely custom HTTP client: + +1. Replace your [`hanzo-java` dependency](#installation) with `hanzo-java-core` +2. Write a class that implements the [`HttpClient`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpClient.kt) interface +3. Construct [`HanzoClientImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt) or [`HanzoClientAsyncImpl`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt), similarly to [`HanzoOkHttpClient`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt) or [`HanzoOkHttpClientAsync`](hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt), using your new client class + ## Undocumented API functionality The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. From 271120209107485ef828f66150c6b32c14db9d2f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 05:14:42 +0000 Subject: [PATCH 23/75] chore(ci): add timeout thresholds for CI jobs --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebbaa260..9051fdd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ on: jobs: lint: + timeout-minutes: 10 name: lint runs-on: ubuntu-latest steps: @@ -30,6 +31,7 @@ jobs: - name: Run lints run: ./scripts/lint test: + timeout-minutes: 10 name: test runs-on: ubuntu-latest steps: From 0b6be6fc53010ddef052f0142400aa2599225a26 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 03:09:51 +0000 Subject: [PATCH 24/75] chore(internal): codegen related update --- .github/workflows/ci.yml | 17 +++++++++-------- .github/workflows/publish-sonatype.yml | 2 +- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9051fdd2..145d33ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,19 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: timeout-minutes: 10 name: lint - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 + steps: - uses: actions/checkout@v4 @@ -33,7 +34,7 @@ jobs: test: timeout-minutes: 10 name: test - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 17bad012..b36bcc50 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -11,7 +11,7 @@ on: jobs: publish: name: publish - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 6de875a6..8f965c45 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -8,7 +8,7 @@ on: jobs: release_doctor: name: release doctor - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 if: github.repository == 'hanzoai/java-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: From 76c8fa1b7cc7a685bbc0326773579dee3120a678 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 03:12:59 +0000 Subject: [PATCH 25/75] chore(ci): only use depot for staging repos --- .github/workflows/ci.yml | 4 ++-- .github/workflows/publish-sonatype.yml | 2 +- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 145d33ab..d386dfd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: lint: timeout-minutes: 10 name: lint - runs-on: depot-ubuntu-24.04 + runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -34,7 +34,7 @@ jobs: test: timeout-minutes: 10 name: test - runs-on: depot-ubuntu-24.04 + runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index b36bcc50..17bad012 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -11,7 +11,7 @@ on: jobs: publish: name: publish - runs-on: depot-ubuntu-24.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 8f965c45..6de875a6 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -8,7 +8,7 @@ on: jobs: release_doctor: name: release doctor - runs-on: depot-ubuntu-24.04 + runs-on: ubuntu-latest if: github.repository == 'hanzoai/java-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: From afd652a14b550ae68fc192379c2649f3dea63601 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 03:15:52 +0000 Subject: [PATCH 26/75] fix(client): add missing convenience methods chore(internal): use `byteInputStream()` in tests --- .../transcriptions/TranscriptionCreateParamsTest.kt | 7 ++++--- .../hanzo/api/models/files/FileCreateParamsTest.kt | 12 ++++++------ .../hanzo/api/services/async/FileServiceAsyncTest.kt | 2 +- .../async/audio/TranscriptionServiceAsyncTest.kt | 2 +- .../hanzo/api/services/blocking/FileServiceTest.kt | 2 +- .../blocking/audio/TranscriptionServiceTest.kt | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt index cd391f79..a9acdc4b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt @@ -13,13 +13,14 @@ internal class TranscriptionCreateParamsTest { @Disabled("skipped: tests are disabled for the time being") @Test fun create() { - TranscriptionCreateParams.builder().file("some content".toByteArray()).build() + TranscriptionCreateParams.builder().file("some content".byteInputStream()).build() } @Disabled("skipped: tests are disabled for the time being") @Test fun body() { - val params = TranscriptionCreateParams.builder().file("some content".toByteArray()).build() + val params = + TranscriptionCreateParams.builder().file("some content".byteInputStream()).build() val body = params._body() @@ -32,7 +33,7 @@ internal class TranscriptionCreateParamsTest { InputStream::class.java, ) .isEqualTo( - mapOf("file" to MultipartField.of("some content".toByteArray())).mapValues { + mapOf("file" to MultipartField.of("some content".byteInputStream())).mapValues { (_, field) -> field.map { (it as? ByteArray)?.inputStream() ?: it } } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt index 76e20e4e..4acf2c58 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt @@ -15,7 +15,7 @@ internal class FileCreateParamsTest { fun create() { FileCreateParams.builder() .provider("provider") - .file("some content".toByteArray()) + .file("some content".byteInputStream()) .purpose("purpose") .customLlmProvider("custom_llm_provider") .build() @@ -27,7 +27,7 @@ internal class FileCreateParamsTest { val params = FileCreateParams.builder() .provider("provider") - .file("some content".toByteArray()) + .file("some content".byteInputStream()) .purpose("purpose") .build() @@ -42,7 +42,7 @@ internal class FileCreateParamsTest { val params = FileCreateParams.builder() .provider("provider") - .file("some content".toByteArray()) + .file("some content".byteInputStream()) .purpose("purpose") .customLlmProvider("custom_llm_provider") .build() @@ -59,7 +59,7 @@ internal class FileCreateParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".toByteArray()), + "file" to MultipartField.of("some content".byteInputStream()), "purpose" to MultipartField.of("purpose"), "custom_llm_provider" to MultipartField.of("custom_llm_provider"), ) @@ -75,7 +75,7 @@ internal class FileCreateParamsTest { val params = FileCreateParams.builder() .provider("provider") - .file("some content".toByteArray()) + .file("some content".byteInputStream()) .purpose("purpose") .build() @@ -91,7 +91,7 @@ internal class FileCreateParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".toByteArray()), + "file" to MultipartField.of("some content".byteInputStream()), "purpose" to MultipartField.of("purpose"), ) .mapValues { (_, field) -> diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt index cf775af2..56a33885 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt @@ -29,7 +29,7 @@ internal class FileServiceAsyncTest { fileServiceAsync.create( FileCreateParams.builder() .provider("provider") - .file("some content".toByteArray()) + .file("some content".byteInputStream()) .purpose("purpose") .customLlmProvider("custom_llm_provider") .build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt index 2ba1cdd5..4668c528 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt @@ -24,7 +24,7 @@ internal class TranscriptionServiceAsyncTest { val transcriptionFuture = transcriptionServiceAsync.create( - TranscriptionCreateParams.builder().file("some content".toByteArray()).build() + TranscriptionCreateParams.builder().file("some content".byteInputStream()).build() ) val transcription = transcriptionFuture.get() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt index e6513cf0..9d3e836c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt @@ -29,7 +29,7 @@ internal class FileServiceTest { fileService.create( FileCreateParams.builder() .provider("provider") - .file("some content".toByteArray()) + .file("some content".byteInputStream()) .purpose("purpose") .customLlmProvider("custom_llm_provider") .build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt index 0749f867..4bfcd79f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt @@ -24,7 +24,7 @@ internal class TranscriptionServiceTest { val transcription = transcriptionService.create( - TranscriptionCreateParams.builder().file("some content".toByteArray()).build() + TranscriptionCreateParams.builder().file("some content".byteInputStream()).build() ) transcription.validate() From 2bcbac55db86820f67047c1be46898513970bee8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 03:21:23 +0000 Subject: [PATCH 27/75] chore(internal): java 17 -> 21 on ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d386dfd8..db2f03ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -44,7 +44,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle From 5c62cf3a190d7fc3d2c0def9b589c7dceb0bb025 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 2 May 2025 04:09:00 +0000 Subject: [PATCH 28/75] chore(internal): update java toolchain --- buildSrc/src/main/kotlin/hanzo.java.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/hanzo.java.gradle.kts b/buildSrc/src/main/kotlin/hanzo.java.gradle.kts index e39d9ac6..dfbacb86 100644 --- a/buildSrc/src/main/kotlin/hanzo.java.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.java.gradle.kts @@ -21,7 +21,7 @@ configure { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } sourceCompatibility = JavaVersion.VERSION_1_8 From 2548d2575aaab0c2dbcf87b9df3e9d04cd2f9f25 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 06:04:08 +0000 Subject: [PATCH 29/75] chore(internal): remove flaky `-Xbackend-threads=0` option --- buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts index 793cdbc4..7408acaa 100644 --- a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts @@ -19,8 +19,6 @@ kotlin { // Suppress deprecation warnings because we may still reference and test deprecated members. // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. "-nowarn", - // Use as many threads as there are CPU cores on the machine for compilation. - "-Xbackend-threads=0", ) jvmTarget.set(JvmTarget.JVM_1_8) languageVersion.set(KotlinVersion.KOTLIN_1_8) From 4f35e180123ecba96578a2eab86af922115cd005 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 05:18:56 +0000 Subject: [PATCH 30/75] feat(client): allow providing some params positionally --- .../main/kotlin/ai/hanzo/api/core/Check.kt | 3 + .../models/anthropic/AnthropicCreateParams.kt | 33 +- .../models/anthropic/AnthropicDeleteParams.kt | 33 +- .../models/anthropic/AnthropicModifyParams.kt | 33 +- .../anthropic/AnthropicRetrieveParams.kt | 34 +- .../models/anthropic/AnthropicUpdateParams.kt | 33 +- .../assemblyai/AssemblyaiCreateParams.kt | 33 +- .../assemblyai/AssemblyaiDeleteParams.kt | 33 +- .../assemblyai/AssemblyaiPatchParams.kt | 33 +- .../assemblyai/AssemblyaiRetrieveParams.kt | 34 +- .../assemblyai/AssemblyaiUpdateParams.kt | 33 +- .../assistants/AssistantDeleteParams.kt | 33 +- .../hanzo/api/models/azure/AzureCallParams.kt | 38 +- .../api/models/azure/AzureCreateParams.kt | 33 +- .../api/models/azure/AzureDeleteParams.kt | 33 +- .../api/models/azure/AzurePatchParams.kt | 33 +- .../api/models/azure/AzureUpdateParams.kt | 33 +- .../batches/BatchCancelWithProviderParams.kt | 16 +- .../batches/BatchCreateWithProviderParams.kt | 29 +- .../batches/BatchListWithProviderParams.kt | 28 +- .../api/models/batches/BatchRetrieveParams.kt | 32 +- .../BatchRetrieveWithProviderParams.kt | 17 +- .../batches/cancel/CancelCancelParams.kt | 32 +- .../api/models/bedrock/BedrockCreateParams.kt | 33 +- .../api/models/bedrock/BedrockDeleteParams.kt | 33 +- .../api/models/bedrock/BedrockPatchParams.kt | 33 +- .../models/bedrock/BedrockRetrieveParams.kt | 34 +- .../api/models/bedrock/BedrockUpdateParams.kt | 33 +- .../api/models/cohere/CohereCreateParams.kt | 33 +- .../api/models/cohere/CohereDeleteParams.kt | 33 +- .../api/models/cohere/CohereModifyParams.kt | 33 +- .../api/models/cohere/CohereRetrieveParams.kt | 38 +- .../api/models/cohere/CohereUpdateParams.kt | 33 +- .../PassThroughEndpointUpdateParams.kt | 29 +- .../credentials/CredentialDeleteParams.kt | 34 +- .../models/engines/EngineCompleteParams.kt | 33 +- .../api/models/engines/EngineEmbedParams.kt | 33 +- .../models/engines/chat/ChatCompleteParams.kt | 33 +- .../euassemblyai/EuAssemblyaiCreateParams.kt | 33 +- .../euassemblyai/EuAssemblyaiDeleteParams.kt | 33 +- .../euassemblyai/EuAssemblyaiPatchParams.kt | 33 +- .../EuAssemblyaiRetrieveParams.kt | 30 +- .../euassemblyai/EuAssemblyaiUpdateParams.kt | 33 +- .../api/models/files/FileCreateParams.kt | 16 +- .../api/models/files/FileDeleteParams.kt | 16 +- .../hanzo/api/models/files/FileListParams.kt | 32 +- .../api/models/files/FileRetrieveParams.kt | 17 +- .../files/content/ContentRetrieveParams.kt | 17 +- .../finetuning/jobs/JobRetrieveParams.kt | 18 +- .../jobs/cancel/CancelCreateParams.kt | 34 +- .../api/models/gemini/GeminiCreateParams.kt | 33 +- .../api/models/gemini/GeminiDeleteParams.kt | 33 +- .../api/models/gemini/GeminiPatchParams.kt | 33 +- .../api/models/gemini/GeminiRetrieveParams.kt | 38 +- .../api/models/gemini/GeminiUpdateParams.kt | 33 +- .../models/key/KeyRegenerateByKeyParams.kt | 32 +- .../models/langfuse/LangfuseCreateParams.kt | 33 +- .../models/langfuse/LangfuseDeleteParams.kt | 33 +- .../models/langfuse/LangfusePatchParams.kt | 33 +- .../models/langfuse/LangfuseRetrieveParams.kt | 34 +- .../models/langfuse/LangfuseUpdateParams.kt | 33 +- .../model/update/UpdatePartialParams.kt | 17 +- .../api/models/openai/OpenAICreateParams.kt | 33 +- .../api/models/openai/OpenAIDeleteParams.kt | 33 +- .../api/models/openai/OpenAIPatchParams.kt | 33 +- .../api/models/openai/OpenAIRetrieveParams.kt | 38 +- .../api/models/openai/OpenAIUpdateParams.kt | 33 +- .../deployments/DeploymentCompleteParams.kt | 33 +- .../deployments/DeploymentEmbedParams.kt | 33 +- .../deployments/chat/ChatCompleteParams.kt | 33 +- .../models/responses/ResponseDeleteParams.kt | 33 +- .../responses/ResponseRetrieveParams.kt | 34 +- .../inputitems/InputItemListParams.kt | 34 +- .../models/team/TeamDisableLoggingParams.kt | 33 +- .../models/team/callback/CallbackAddParams.kt | 15 +- .../team/callback/CallbackRetrieveParams.kt | 38 +- .../models/threads/ThreadRetrieveParams.kt | 38 +- .../threads/messages/MessageCreateParams.kt | 33 +- .../threads/messages/MessageListParams.kt | 38 +- .../models/threads/runs/RunCreateParams.kt | 33 +- .../models/vertexai/VertexAiCreateParams.kt | 33 +- .../models/vertexai/VertexAiDeleteParams.kt | 33 +- .../models/vertexai/VertexAiPatchParams.kt | 33 +- .../models/vertexai/VertexAiRetrieveParams.kt | 34 +- .../models/vertexai/VertexAiUpdateParams.kt | 33 +- .../services/async/AnthropicServiceAsync.kt | 318 +++++++++++++++-- .../async/AnthropicServiceAsyncImpl.kt | 17 + .../services/async/AssemblyaiServiceAsync.kt | 318 +++++++++++++++-- .../async/AssemblyaiServiceAsyncImpl.kt | 17 + .../services/async/AssistantServiceAsync.kt | 66 +++- .../async/AssistantServiceAsyncImpl.kt | 5 + .../api/services/async/AzureServiceAsync.kt | 314 +++++++++++++++-- .../services/async/AzureServiceAsyncImpl.kt | 17 + .../api/services/async/BatchServiceAsync.kt | 259 +++++++++++++- .../services/async/BatchServiceAsyncImpl.kt | 17 + .../api/services/async/BedrockServiceAsync.kt | 318 +++++++++++++++-- .../services/async/BedrockServiceAsyncImpl.kt | 17 + .../api/services/async/CohereServiceAsync.kt | 315 +++++++++++++++-- .../services/async/CohereServiceAsyncImpl.kt | 17 + .../services/async/CredentialServiceAsync.kt | 66 +++- .../async/CredentialServiceAsyncImpl.kt | 5 + .../api/services/async/EngineServiceAsync.kt | 126 ++++++- .../services/async/EngineServiceAsyncImpl.kt | 8 + .../async/EuAssemblyaiServiceAsync.kt | 327 ++++++++++++++++-- .../async/EuAssemblyaiServiceAsyncImpl.kt | 17 + .../api/services/async/FileServiceAsync.kt | 151 +++++++- .../services/async/FileServiceAsyncImpl.kt | 14 + .../api/services/async/GeminiServiceAsync.kt | 315 +++++++++++++++-- .../services/async/GeminiServiceAsyncImpl.kt | 17 + .../api/services/async/KeyServiceAsync.kt | 66 +++- .../api/services/async/KeyServiceAsyncImpl.kt | 5 + .../services/async/LangfuseServiceAsync.kt | 318 +++++++++++++++-- .../async/LangfuseServiceAsyncImpl.kt | 17 + .../api/services/async/OpenAIServiceAsync.kt | 315 +++++++++++++++-- .../services/async/OpenAIServiceAsyncImpl.kt | 17 + .../services/async/ResponseServiceAsync.kt | 129 ++++++- .../async/ResponseServiceAsyncImpl.kt | 8 + .../api/services/async/TeamServiceAsync.kt | 66 +++- .../services/async/TeamServiceAsyncImpl.kt | 5 + .../api/services/async/ThreadServiceAsync.kt | 63 +++- .../services/async/ThreadServiceAsyncImpl.kt | 5 + .../services/async/VertexAiServiceAsync.kt | 318 +++++++++++++++-- .../async/VertexAiServiceAsyncImpl.kt | 17 + .../async/batches/CancelServiceAsync.kt | 63 +++- .../async/batches/CancelServiceAsyncImpl.kt | 5 + .../config/PassThroughEndpointServiceAsync.kt | 66 +++- .../PassThroughEndpointServiceAsyncImpl.kt | 5 + .../async/engines/ChatServiceAsync.kt | 63 +++- .../async/engines/ChatServiceAsyncImpl.kt | 5 + .../async/files/ContentServiceAsync.kt | 31 ++ .../async/files/ContentServiceAsyncImpl.kt | 5 + .../async/finetuning/JobServiceAsync.kt | 32 ++ .../async/finetuning/JobServiceAsyncImpl.kt | 5 + .../finetuning/jobs/CancelServiceAsync.kt | 66 +++- .../finetuning/jobs/CancelServiceAsyncImpl.kt | 5 + .../async/model/UpdateServiceAsync.kt | 31 ++ .../async/model/UpdateServiceAsyncImpl.kt | 5 + .../async/openai/DeploymentServiceAsync.kt | 129 ++++++- .../openai/DeploymentServiceAsyncImpl.kt | 8 + .../openai/deployments/ChatServiceAsync.kt | 63 +++- .../deployments/ChatServiceAsyncImpl.kt | 5 + .../async/responses/InputItemServiceAsync.kt | 63 +++- .../responses/InputItemServiceAsyncImpl.kt | 5 + .../async/team/CallbackServiceAsync.kt | 92 ++++- .../async/team/CallbackServiceAsyncImpl.kt | 8 + .../async/threads/MessageServiceAsync.kt | 126 ++++++- .../async/threads/MessageServiceAsyncImpl.kt | 8 + .../services/async/threads/RunServiceAsync.kt | 63 +++- .../async/threads/RunServiceAsyncImpl.kt | 5 + .../api/services/blocking/AnthropicService.kt | 300 ++++++++++++++-- .../services/blocking/AnthropicServiceImpl.kt | 17 + .../services/blocking/AssemblyaiService.kt | 299 ++++++++++++++-- .../blocking/AssemblyaiServiceImpl.kt | 17 + .../api/services/blocking/AssistantService.kt | 60 +++- .../services/blocking/AssistantServiceImpl.kt | 5 + .../api/services/blocking/AzureService.kt | 281 ++++++++++++++- .../api/services/blocking/AzureServiceImpl.kt | 17 + .../api/services/blocking/BatchService.kt | 247 ++++++++++++- .../api/services/blocking/BatchServiceImpl.kt | 17 + .../api/services/blocking/BedrockService.kt | 291 ++++++++++++++-- .../services/blocking/BedrockServiceImpl.kt | 17 + .../api/services/blocking/CohereService.kt | 288 +++++++++++++-- .../services/blocking/CohereServiceImpl.kt | 17 + .../services/blocking/CredentialService.kt | 60 +++- .../blocking/CredentialServiceImpl.kt | 5 + .../api/services/blocking/EngineService.kt | 113 +++++- .../services/blocking/EngineServiceImpl.kt | 8 + .../services/blocking/EuAssemblyaiService.kt | 300 ++++++++++++++-- .../blocking/EuAssemblyaiServiceImpl.kt | 17 + .../api/services/blocking/FileService.kt | 131 ++++++- .../api/services/blocking/FileServiceImpl.kt | 14 + .../api/services/blocking/GeminiService.kt | 286 ++++++++++++++- .../services/blocking/GeminiServiceImpl.kt | 17 + .../hanzo/api/services/blocking/KeyService.kt | 63 +++- .../api/services/blocking/KeyServiceImpl.kt | 5 + .../api/services/blocking/LangfuseService.kt | 294 ++++++++++++++-- .../services/blocking/LangfuseServiceImpl.kt | 17 + .../api/services/blocking/OpenAIService.kt | 286 ++++++++++++++- .../services/blocking/OpenAIServiceImpl.kt | 17 + .../api/services/blocking/ResponseService.kt | 120 ++++++- .../services/blocking/ResponseServiceImpl.kt | 8 + .../api/services/blocking/TeamService.kt | 60 +++- .../api/services/blocking/TeamServiceImpl.kt | 5 + .../api/services/blocking/ThreadService.kt | 60 +++- .../services/blocking/ThreadServiceImpl.kt | 5 + .../api/services/blocking/VertexAiService.kt | 294 ++++++++++++++-- .../services/blocking/VertexAiServiceImpl.kt | 17 + .../blocking/batches/CancelService.kt | 57 ++- .../blocking/batches/CancelServiceImpl.kt | 5 + .../config/PassThroughEndpointService.kt | 63 +++- .../config/PassThroughEndpointServiceImpl.kt | 5 + .../services/blocking/engines/ChatService.kt | 57 ++- .../blocking/engines/ChatServiceImpl.kt | 5 + .../services/blocking/files/ContentService.kt | 28 ++ .../blocking/files/ContentServiceImpl.kt | 5 + .../blocking/finetuning/JobService.kt | 29 ++ .../blocking/finetuning/JobServiceImpl.kt | 5 + .../blocking/finetuning/jobs/CancelService.kt | 60 +++- .../finetuning/jobs/CancelServiceImpl.kt | 5 + .../services/blocking/model/UpdateService.kt | 27 ++ .../blocking/model/UpdateServiceImpl.kt | 5 + .../blocking/openai/DeploymentService.kt | 117 ++++++- .../blocking/openai/DeploymentServiceImpl.kt | 8 + .../openai/deployments/ChatService.kt | 57 ++- .../openai/deployments/ChatServiceImpl.kt | 5 + .../blocking/responses/InputItemService.kt | 59 +++- .../responses/InputItemServiceImpl.kt | 5 + .../services/blocking/team/CallbackService.kt | 85 ++++- .../blocking/team/CallbackServiceImpl.kt | 8 + .../blocking/threads/MessageService.kt | 113 +++++- .../blocking/threads/MessageServiceImpl.kt | 8 + .../services/blocking/threads/RunService.kt | 55 ++- .../blocking/threads/RunServiceImpl.kt | 5 + .../async/AnthropicServiceAsyncTest.kt | 30 +- .../async/AssemblyaiServiceAsyncTest.kt | 30 +- .../async/AssistantServiceAsyncTest.kt | 6 +- .../services/async/AzureServiceAsyncTest.kt | 20 +- .../services/async/BatchServiceAsyncTest.kt | 6 +- .../services/async/BedrockServiceAsyncTest.kt | 22 +- .../services/async/CohereServiceAsyncTest.kt | 20 +- .../async/CredentialServiceAsyncTest.kt | 6 +- .../services/async/EngineServiceAsyncTest.kt | 8 +- .../async/EuAssemblyaiServiceAsyncTest.kt | 30 +- .../services/async/GeminiServiceAsyncTest.kt | 20 +- .../async/LangfuseServiceAsyncTest.kt | 22 +- .../services/async/OpenAIServiceAsyncTest.kt | 20 +- .../async/ResponseServiceAsyncTest.kt | 12 +- .../services/async/TeamServiceAsyncTest.kt | 6 +- .../services/async/ThreadServiceAsyncTest.kt | 6 +- .../async/VertexAiServiceAsyncTest.kt | 22 +- .../PassThroughEndpointServiceAsyncTest.kt | 6 +- .../async/engines/ChatServiceAsyncTest.kt | 4 +- .../finetuning/jobs/CancelServiceAsyncTest.kt | 6 +- .../openai/DeploymentServiceAsyncTest.kt | 10 +- .../deployments/ChatServiceAsyncTest.kt | 4 +- .../responses/InputItemServiceAsyncTest.kt | 6 +- .../async/team/CallbackServiceAsyncTest.kt | 6 +- .../async/threads/MessageServiceAsyncTest.kt | 8 +- .../async/threads/RunServiceAsyncTest.kt | 4 +- .../services/blocking/AnthropicServiceTest.kt | 22 +- .../blocking/AssemblyaiServiceTest.kt | 22 +- .../services/blocking/AssistantServiceTest.kt | 6 +- .../api/services/blocking/AzureServiceTest.kt | 15 +- .../api/services/blocking/BatchServiceTest.kt | 6 +- .../services/blocking/BedrockServiceTest.kt | 20 +- .../services/blocking/CohereServiceTest.kt | 17 +- .../blocking/CredentialServiceTest.kt | 6 +- .../services/blocking/EngineServiceTest.kt | 6 +- .../blocking/EuAssemblyaiServiceTest.kt | 30 +- .../services/blocking/GeminiServiceTest.kt | 16 +- .../services/blocking/LangfuseServiceTest.kt | 20 +- .../services/blocking/OpenAIServiceTest.kt | 16 +- .../services/blocking/ResponseServiceTest.kt | 10 +- .../api/services/blocking/TeamServiceTest.kt | 4 +- .../services/blocking/ThreadServiceTest.kt | 4 +- .../services/blocking/VertexAiServiceTest.kt | 20 +- .../config/PassThroughEndpointServiceTest.kt | 6 +- .../blocking/engines/ChatServiceTest.kt | 3 +- .../finetuning/jobs/CancelServiceTest.kt | 6 +- .../blocking/openai/DeploymentServiceTest.kt | 8 +- .../openai/deployments/ChatServiceTest.kt | 3 +- .../responses/InputItemServiceTest.kt | 4 +- .../blocking/team/CallbackServiceTest.kt | 4 +- .../blocking/threads/MessageServiceTest.kt | 8 +- .../blocking/threads/RunServiceTest.kt | 3 +- 265 files changed, 10873 insertions(+), 2731 deletions(-) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt index 1ec69198..56ae907e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Check.kt @@ -5,6 +5,9 @@ package ai.hanzo.api.core import com.fasterxml.jackson.core.Version import com.fasterxml.jackson.core.util.VersionUtil +fun checkRequired(name: String, condition: Boolean) = + check(condition) { "`$name` is required, but was not set" } + fun checkRequired(name: String, value: T?): T = checkNotNull(value) { "`$name` is required, but was not set" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt index 9d3b5a16..758222c9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ class AnthropicCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AnthropicCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AnthropicCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AnthropicCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = anthropicCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [AnthropicCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AnthropicCreateParams = AnthropicCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt index bca28e9d..592975c5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ class AnthropicDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AnthropicDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AnthropicDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AnthropicDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = anthropicDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [AnthropicDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AnthropicDeleteParams = AnthropicDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt index 09baea8f..9c5c087a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ class AnthropicModifyParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AnthropicModifyParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AnthropicModifyParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AnthropicModifyParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = anthropicModifyParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [AnthropicModifyParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AnthropicModifyParams = AnthropicModifyParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt index 36e2ccf9..10e8ba21 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ class AnthropicRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AnthropicRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AnthropicRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AnthropicRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = anthropicRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,17 +154,10 @@ private constructor( * Returns an immutable instance of [AnthropicRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AnthropicRetrieveParams = AnthropicRetrieveParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -173,7 +165,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt index 1c94785e..88734d67 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ class AnthropicUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AnthropicUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AnthropicUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AnthropicUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = anthropicUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [AnthropicUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AnthropicUpdateParams = AnthropicUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt index b98f49f6..87a8fdb5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class AssemblyaiCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AssemblyaiCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AssemblyaiCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssemblyaiCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( assemblyaiCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [AssemblyaiCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AssemblyaiCreateParams = AssemblyaiCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt index bddacc4f..a46b00e7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class AssemblyaiDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AssemblyaiDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AssemblyaiDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssemblyaiDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( assemblyaiDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [AssemblyaiDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AssemblyaiDeleteParams = AssemblyaiDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt index 3c1b195e..822d3eac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class AssemblyaiPatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AssemblyaiPatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AssemblyaiPatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssemblyaiPatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = assemblyaiPatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [AssemblyaiPatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AssemblyaiPatchParams = AssemblyaiPatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParams.kt index 8b6664e8..97157272 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class AssemblyaiRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AssemblyaiRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AssemblyaiRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssemblyaiRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = assemblyaiRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,17 +154,10 @@ private constructor( * Returns an immutable instance of [AssemblyaiRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AssemblyaiRetrieveParams = AssemblyaiRetrieveParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -173,7 +165,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt index 118e71b2..0f7d0324 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class AssemblyaiUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AssemblyaiUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AssemblyaiUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssemblyaiUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( assemblyaiUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [AssemblyaiUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AssemblyaiUpdateParams = AssemblyaiUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt index aef03dc0..9586b5f1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.assistants import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Delete assistant @@ -18,13 +18,13 @@ import java.util.Optional */ class AssistantDeleteParams private constructor( - private val assistantId: String, + private val assistantId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun assistantId(): String = assistantId + fun assistantId(): Optional = Optional.ofNullable(assistantId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AssistantDeleteParams]. - * - * The following fields are required: - * ```java - * .assistantId() - * ``` - */ + @JvmStatic fun none(): AssistantDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssistantDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = assistantDeleteParams.additionalBodyProperties.toMutableMap() } - fun assistantId(assistantId: String) = apply { this.assistantId = assistantId } + fun assistantId(assistantId: String?) = apply { this.assistantId = assistantId } + + /** Alias for calling [Builder.assistantId] with `assistantId.orElse(null)`. */ + fun assistantId(assistantId: Optional) = assistantId(assistantId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [AssistantDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .assistantId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AssistantDeleteParams = AssistantDeleteParams( - checkRequired("assistantId", assistantId), + assistantId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> assistantId + 0 -> assistantId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt index c2ef1aec..a29101e7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call any azure endpoint using the proxy. @@ -15,12 +16,12 @@ import java.util.Objects */ class AzureCallParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -30,14 +31,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AzureCallParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AzureCallParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AzureCallParams]. */ @JvmStatic fun builder() = Builder() } @@ -55,7 +51,10 @@ private constructor( additionalQueryParams = azureCallParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -159,25 +158,14 @@ private constructor( * Returns an immutable instance of [AzureCallParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AzureCallParams = - AzureCallParams( - checkRequired("endpoint", endpoint), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + AzureCallParams(endpoint, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt index 52385c48..6f19a08a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call any azure endpoint using the proxy. @@ -18,13 +18,13 @@ import java.util.Optional */ class AzureCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AzureCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AzureCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AzureCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = azureCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [AzureCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AzureCreateParams = AzureCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt index cdd37018..12e8793b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call any azure endpoint using the proxy. @@ -18,13 +18,13 @@ import java.util.Optional */ class AzureDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AzureDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AzureDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AzureDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = azureDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [AzureDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AzureDeleteParams = AzureDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt index 3f173e68..e8a71112 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call any azure endpoint using the proxy. @@ -18,13 +18,13 @@ import java.util.Optional */ class AzurePatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AzurePatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AzurePatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AzurePatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = azurePatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [AzurePatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AzurePatchParams = AzurePatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt index d583f0e2..af3f6d89 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call any azure endpoint using the proxy. @@ -18,13 +18,13 @@ import java.util.Optional */ class AzureUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AzureUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): AzureUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AzureUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = azureUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [AzureUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AzureUpdateParams = AzureUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt index 15de1c2c..ef867cd5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParams.kt @@ -10,6 +10,7 @@ import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Cancel a batch. This is the equivalent of POST @@ -27,7 +28,7 @@ import java.util.Optional class BatchCancelWithProviderParams private constructor( private val provider: String, - private val batchId: String, + private val batchId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -35,7 +36,7 @@ private constructor( fun provider(): String = provider - fun batchId(): String = batchId + fun batchId(): Optional = Optional.ofNullable(batchId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -54,7 +55,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .batchId() * ``` */ @JvmStatic fun builder() = Builder() @@ -81,7 +81,10 @@ private constructor( fun provider(provider: String) = apply { this.provider = provider } - fun batchId(batchId: String) = apply { this.batchId = batchId } + fun batchId(batchId: String?) = apply { this.batchId = batchId } + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -211,7 +214,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .batchId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -219,7 +221,7 @@ private constructor( fun build(): BatchCancelWithProviderParams = BatchCancelWithProviderParams( checkRequired("provider", provider), - checkRequired("batchId", batchId), + batchId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -232,7 +234,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> provider - 1 -> batchId + 1 -> batchId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt index 23ce7afd..b5e3ad87 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create large batches of API requests for asynchronous processing. This is the equivalent of POST @@ -28,13 +28,13 @@ import java.util.Optional */ class BatchCreateWithProviderParams private constructor( - private val provider: String, + private val provider: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun provider(): String = provider + fun provider(): Optional = Optional.ofNullable(provider) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -46,14 +46,11 @@ private constructor( companion object { + @JvmStatic fun none(): BatchCreateWithProviderParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [BatchCreateWithProviderParams]. - * - * The following fields are required: - * ```java - * .provider() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -75,7 +72,10 @@ private constructor( batchCreateWithProviderParams.additionalBodyProperties.toMutableMap() } - fun provider(provider: String) = apply { this.provider = provider } + fun provider(provider: String?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional) = provider(provider.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -201,17 +201,10 @@ private constructor( * Returns an immutable instance of [BatchCreateWithProviderParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .provider() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BatchCreateWithProviderParams = BatchCreateWithProviderParams( - checkRequired("provider", provider), + provider, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -223,7 +216,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> provider + 0 -> provider ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt index 39c41b71..1f7f4a8a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt @@ -3,7 +3,6 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects @@ -22,14 +21,14 @@ import kotlin.jvm.optionals.getOrNull */ class BatchListWithProviderParams private constructor( - private val provider: String, + private val provider: String?, private val after: String?, private val limit: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun provider(): String = provider + fun provider(): Optional = Optional.ofNullable(provider) fun after(): Optional = Optional.ofNullable(after) @@ -43,13 +42,10 @@ private constructor( companion object { + @JvmStatic fun none(): BatchListWithProviderParams = builder().build() + /** * Returns a mutable builder for constructing an instance of [BatchListWithProviderParams]. - * - * The following fields are required: - * ```java - * .provider() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -72,7 +68,10 @@ private constructor( additionalQueryParams = batchListWithProviderParams.additionalQueryParams.toBuilder() } - fun provider(provider: String) = apply { this.provider = provider } + fun provider(provider: String?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional) = provider(provider.getOrNull()) fun after(after: String?) = apply { this.after = after } @@ -193,17 +192,10 @@ private constructor( * Returns an immutable instance of [BatchListWithProviderParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .provider() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BatchListWithProviderParams = BatchListWithProviderParams( - checkRequired("provider", provider), + provider, after, limit, additionalHeaders.build(), @@ -213,7 +205,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> provider + 0 -> provider ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParams.kt index 69301720..208f9d05 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParams.kt @@ -3,7 +3,6 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects @@ -22,14 +21,14 @@ import kotlin.jvm.optionals.getOrNull */ class BatchRetrieveParams private constructor( - private val batchId: String, + private val batchId: String?, private val provider: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** The ID of the batch to retrieve */ - fun batchId(): String = batchId + fun batchId(): Optional = Optional.ofNullable(batchId) fun provider(): Optional = Optional.ofNullable(provider) @@ -41,14 +40,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BatchRetrieveParams]. - * - * The following fields are required: - * ```java - * .batchId() - * ``` - */ + @JvmStatic fun none(): BatchRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BatchRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -69,7 +63,10 @@ private constructor( } /** The ID of the batch to retrieve */ - fun batchId(batchId: String) = apply { this.batchId = batchId } + fun batchId(batchId: String?) = apply { this.batchId = batchId } + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) fun provider(provider: String?) = apply { this.provider = provider } @@ -178,17 +175,10 @@ private constructor( * Returns an immutable instance of [BatchRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .batchId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BatchRetrieveParams = BatchRetrieveParams( - checkRequired("batchId", batchId), + batchId, provider, additionalHeaders.build(), additionalQueryParams.build(), @@ -197,7 +187,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> batchId + 0 -> batchId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParams.kt index bb20e7eb..ab2e592f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParams.kt @@ -7,6 +7,8 @@ import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Retrieves a batch. This is the equivalent of GET https://api.openai.com/v1/batches/{batch_id} @@ -21,7 +23,7 @@ import java.util.Objects class BatchRetrieveWithProviderParams private constructor( private val provider: String, - private val batchId: String, + private val batchId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -29,7 +31,7 @@ private constructor( fun provider(): String = provider /** The ID of the batch to retrieve */ - fun batchId(): String = batchId + fun batchId(): Optional = Optional.ofNullable(batchId) fun _additionalHeaders(): Headers = additionalHeaders @@ -46,7 +48,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .batchId() * ``` */ @JvmStatic fun builder() = Builder() @@ -73,7 +74,10 @@ private constructor( fun provider(provider: String) = apply { this.provider = provider } /** The ID of the batch to retrieve */ - fun batchId(batchId: String) = apply { this.batchId = batchId } + fun batchId(batchId: String?) = apply { this.batchId = batchId } + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -181,7 +185,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .batchId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -189,7 +192,7 @@ private constructor( fun build(): BatchRetrieveWithProviderParams = BatchRetrieveWithProviderParams( checkRequired("provider", provider), - checkRequired("batchId", batchId), + batchId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -198,7 +201,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> provider - 1 -> batchId + 1 -> batchId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt index b9bf4ebf..65802fdc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParams.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.models.batches.cancel import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable @@ -27,14 +26,14 @@ import kotlin.jvm.optionals.getOrNull */ class CancelCancelParams private constructor( - private val batchId: String, + private val batchId: String?, private val provider: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun batchId(): String = batchId + fun batchId(): Optional = Optional.ofNullable(batchId) fun provider(): Optional = Optional.ofNullable(provider) @@ -48,14 +47,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CancelCancelParams]. - * - * The following fields are required: - * ```java - * .batchId() - * ``` - */ + @JvmStatic fun none(): CancelCancelParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CancelCancelParams]. */ @JvmStatic fun builder() = Builder() } @@ -77,7 +71,10 @@ private constructor( additionalBodyProperties = cancelCancelParams.additionalBodyProperties.toMutableMap() } - fun batchId(batchId: String) = apply { this.batchId = batchId } + fun batchId(batchId: String?) = apply { this.batchId = batchId } + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) fun provider(provider: String?) = apply { this.provider = provider } @@ -208,17 +205,10 @@ private constructor( * Returns an immutable instance of [CancelCancelParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .batchId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CancelCancelParams = CancelCancelParams( - checkRequired("batchId", batchId), + batchId, provider, additionalHeaders.build(), additionalQueryParams.build(), @@ -231,7 +221,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> batchId + 0 -> batchId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt index 8e6fb92a..ce3ee4ff 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ class BedrockCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BedrockCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): BedrockCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BedrockCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = bedrockCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [BedrockCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BedrockCreateParams = BedrockCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt index 8c3d7671..d07d384f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ class BedrockDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BedrockDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): BedrockDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BedrockDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = bedrockDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [BedrockDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BedrockDeleteParams = BedrockDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt index d552d132..ca2ba002 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ class BedrockPatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BedrockPatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): BedrockPatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BedrockPatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = bedrockPatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [BedrockPatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BedrockPatchParams = BedrockPatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt index e62cb853..2b638156 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ class BedrockRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BedrockRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): BedrockRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BedrockRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = bedrockRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,17 +154,10 @@ private constructor( * Returns an immutable instance of [BedrockRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BedrockRetrieveParams = BedrockRetrieveParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -173,7 +165,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt index f36cf979..0603fa8f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ class BedrockUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BedrockUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): BedrockUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BedrockUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = bedrockUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [BedrockUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): BedrockUpdateParams = BedrockUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt index 4f3f27b4..66a59e19 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ class CohereCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CohereCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): CohereCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CohereCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = cohereCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [CohereCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CohereCreateParams = CohereCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt index 6f085f7f..e7ff1d4c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ class CohereDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CohereDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): CohereDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CohereDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = cohereDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [CohereDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CohereDeleteParams = CohereDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt index 3da1e6bf..8fe79879 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ class CohereModifyParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CohereModifyParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): CohereModifyParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CohereModifyParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = cohereModifyParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [CohereModifyParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CohereModifyParams = CohereModifyParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt index 3a142dcd..14430976 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ class CohereRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CohereRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): CohereRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CohereRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = cohereRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [CohereRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CohereRetrieveParams = - CohereRetrieveParams( - checkRequired("endpoint", endpoint), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + CohereRetrieveParams(endpoint, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt index 5f8578ac..9165a5fd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ class CohereUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CohereUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): CohereUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CohereUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = cohereUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [CohereUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CohereUpdateParams = CohereUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt index aa20dbcc..e220c644 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Update a pass-through endpoint */ class PassThroughEndpointUpdateParams private constructor( - private val endpointId: String, + private val endpointId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpointId(): String = endpointId + fun endpointId(): Optional = Optional.ofNullable(endpointId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,11 @@ private constructor( companion object { + @JvmStatic fun none(): PassThroughEndpointUpdateParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [PassThroughEndpointUpdateParams]. - * - * The following fields are required: - * ```java - * .endpointId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -63,7 +60,10 @@ private constructor( passThroughEndpointUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpointId(endpointId: String) = apply { this.endpointId = endpointId } + fun endpointId(endpointId: String?) = apply { this.endpointId = endpointId } + + /** Alias for calling [Builder.endpointId] with `endpointId.orElse(null)`. */ + fun endpointId(endpointId: Optional) = endpointId(endpointId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +189,10 @@ private constructor( * Returns an immutable instance of [PassThroughEndpointUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpointId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams( - checkRequired("endpointId", endpointId), + endpointId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +204,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpointId + 0 -> endpointId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt index 750c822f..ae000b01 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.credentials import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [BETA] endpoint. This might change unexpectedly. */ class CredentialDeleteParams private constructor( - private val credentialName: String, + private val credentialName: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun credentialName(): String = credentialName + fun credentialName(): Optional = Optional.ofNullable(credentialName) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CredentialDeleteParams]. - * - * The following fields are required: - * ```java - * .credentialName() - * ``` - */ + @JvmStatic fun none(): CredentialDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CredentialDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,11 @@ private constructor( credentialDeleteParams.additionalBodyProperties.toMutableMap() } - fun credentialName(credentialName: String) = apply { this.credentialName = credentialName } + fun credentialName(credentialName: String?) = apply { this.credentialName = credentialName } + + /** Alias for calling [Builder.credentialName] with `credentialName.orElse(null)`. */ + fun credentialName(credentialName: Optional) = + credentialName(credentialName.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +185,10 @@ private constructor( * Returns an immutable instance of [CredentialDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .credentialName() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CredentialDeleteParams = CredentialDeleteParams( - checkRequired("credentialName", credentialName), + credentialName, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +200,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> credentialName + 0 -> credentialName ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt index c6ea2ef2..f3b57db0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.engines import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Follows the exact same API spec as `OpenAI's Completions API @@ -29,13 +29,13 @@ import java.util.Optional */ class EngineCompleteParams private constructor( - private val model: String, + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun model(): String = model + fun model(): Optional = Optional.ofNullable(model) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -47,14 +47,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EngineCompleteParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ + @JvmStatic fun none(): EngineCompleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EngineCompleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -74,7 +69,10 @@ private constructor( additionalBodyProperties = engineCompleteParams.additionalBodyProperties.toMutableMap() } - fun model(model: String) = apply { this.model = model } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -200,17 +198,10 @@ private constructor( * Returns an immutable instance of [EngineCompleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .model() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EngineCompleteParams = EngineCompleteParams( - checkRequired("model", model), + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -222,7 +213,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> model + 0 -> model ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt index 9805df55..f7319d37 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.engines import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Follows the exact same API spec as `OpenAI's Embeddings API @@ -27,13 +27,13 @@ import java.util.Optional */ class EngineEmbedParams private constructor( - private val model: String, + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun model(): String = model + fun model(): Optional = Optional.ofNullable(model) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -45,14 +45,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EngineEmbedParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ + @JvmStatic fun none(): EngineEmbedParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EngineEmbedParams]. */ @JvmStatic fun builder() = Builder() } @@ -72,7 +67,10 @@ private constructor( additionalBodyProperties = engineEmbedParams.additionalBodyProperties.toMutableMap() } - fun model(model: String) = apply { this.model = model } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -198,17 +196,10 @@ private constructor( * Returns an immutable instance of [EngineEmbedParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .model() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EngineEmbedParams = EngineEmbedParams( - checkRequired("model", model), + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -220,7 +211,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> model + 0 -> model ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt index 9a460364..1d76e0ec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.engines.chat import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Follows the exact same API spec as `OpenAI's Chat API @@ -32,13 +32,13 @@ import java.util.Optional */ class ChatCompleteParams private constructor( - private val model: String, + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun model(): String = model + fun model(): Optional = Optional.ofNullable(model) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -50,14 +50,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ChatCompleteParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ + @JvmStatic fun none(): ChatCompleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ChatCompleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -77,7 +72,10 @@ private constructor( additionalBodyProperties = chatCompleteParams.additionalBodyProperties.toMutableMap() } - fun model(model: String) = apply { this.model = model } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -203,17 +201,10 @@ private constructor( * Returns an immutable instance of [ChatCompleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .model() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ChatCompleteParams = ChatCompleteParams( - checkRequired("model", model), + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -225,7 +216,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> model + 0 -> model ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt index 0d62eba3..ccdd5f49 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class EuAssemblyaiCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EuAssemblyaiCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): EuAssemblyaiCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EuAssemblyaiCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( euAssemblyaiCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [EuAssemblyaiCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EuAssemblyaiCreateParams = EuAssemblyaiCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt index 6ce811e3..fb8f42fc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class EuAssemblyaiDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EuAssemblyaiDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): EuAssemblyaiDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EuAssemblyaiDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( euAssemblyaiDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [EuAssemblyaiDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt index 812b73b1..4489afb4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class EuAssemblyaiPatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EuAssemblyaiPatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): EuAssemblyaiPatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EuAssemblyaiPatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( euAssemblyaiPatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [EuAssemblyaiPatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EuAssemblyaiPatchParams = EuAssemblyaiPatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParams.kt index e9c64259..4f2b9772 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class EuAssemblyaiRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,13 +27,10 @@ private constructor( companion object { + @JvmStatic fun none(): EuAssemblyaiRetrieveParams = builder().build() + /** * Returns a mutable builder for constructing an instance of [EuAssemblyaiRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -51,7 +49,10 @@ private constructor( additionalQueryParams = euAssemblyaiRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,17 +156,10 @@ private constructor( * Returns an immutable instance of [EuAssemblyaiRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -173,7 +167,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt index f09079e0..74dfcb4c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Assemblyai Proxy Route */ class EuAssemblyaiUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EuAssemblyaiUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): EuAssemblyaiUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EuAssemblyaiUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +55,10 @@ private constructor( euAssemblyaiUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -186,17 +184,10 @@ private constructor( * Returns an immutable instance of [EuAssemblyaiUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -208,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt index 473f3659..74a79ceb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt @@ -17,6 +17,7 @@ import java.util.Objects import java.util.Optional import kotlin.io.path.inputStream import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull /** * Upload a file that can be used across - Assistants API, Batch API This is the equivalent of POST @@ -33,13 +34,13 @@ import kotlin.io.path.name */ class FileCreateParams private constructor( - private val provider: String, + private val provider: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun provider(): String = provider + fun provider(): Optional = Optional.ofNullable(provider) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -94,7 +95,6 @@ private constructor( * * The following fields are required: * ```java - * .provider() * .file() * .purpose() * ``` @@ -118,7 +118,10 @@ private constructor( additionalQueryParams = fileCreateParams.additionalQueryParams.toBuilder() } - fun provider(provider: String) = apply { this.provider = provider } + fun provider(provider: String?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional) = provider(provider.getOrNull()) /** * Sets the entire request body. @@ -276,7 +279,6 @@ private constructor( * * The following fields are required: * ```java - * .provider() * .file() * .purpose() * ``` @@ -285,7 +287,7 @@ private constructor( */ fun build(): FileCreateParams = FileCreateParams( - checkRequired("provider", provider), + provider, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -302,7 +304,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> provider + 0 -> provider ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt index e2536fb0..4eb92e77 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteParams.kt @@ -10,6 +10,7 @@ import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Deletes a specified file. that can be used across - Assistants API, Batch API This is the @@ -27,7 +28,7 @@ import java.util.Optional class FileDeleteParams private constructor( private val provider: String, - private val fileId: String, + private val fileId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -35,7 +36,7 @@ private constructor( fun provider(): String = provider - fun fileId(): String = fileId + fun fileId(): Optional = Optional.ofNullable(fileId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -53,7 +54,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .fileId() * ``` */ @JvmStatic fun builder() = Builder() @@ -79,7 +79,10 @@ private constructor( fun provider(provider: String) = apply { this.provider = provider } - fun fileId(fileId: String) = apply { this.fileId = fileId } + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -209,7 +212,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .fileId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -217,7 +219,7 @@ private constructor( fun build(): FileDeleteParams = FileDeleteParams( checkRequired("provider", provider), - checkRequired("fileId", fileId), + fileId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -230,7 +232,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> provider - 1 -> fileId + 1 -> fileId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt index 2175dc89..328d9db6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt @@ -3,7 +3,6 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects @@ -25,13 +24,13 @@ import kotlin.jvm.optionals.getOrNull */ class FileListParams private constructor( - private val provider: String, + private val provider: String?, private val purpose: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun provider(): String = provider + fun provider(): Optional = Optional.ofNullable(provider) fun purpose(): Optional = Optional.ofNullable(purpose) @@ -43,14 +42,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [FileListParams]. - * - * The following fields are required: - * ```java - * .provider() - * ``` - */ + @JvmStatic fun none(): FileListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FileListParams]. */ @JvmStatic fun builder() = Builder() } @@ -70,7 +64,10 @@ private constructor( additionalQueryParams = fileListParams.additionalQueryParams.toBuilder() } - fun provider(provider: String) = apply { this.provider = provider } + fun provider(provider: String?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional) = provider(provider.getOrNull()) fun purpose(purpose: String?) = apply { this.purpose = purpose } @@ -179,17 +176,10 @@ private constructor( * Returns an immutable instance of [FileListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .provider() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): FileListParams = FileListParams( - checkRequired("provider", provider), + provider, purpose, additionalHeaders.build(), additionalQueryParams.build(), @@ -198,7 +188,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> provider + 0 -> provider ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveParams.kt index 1a84f53b..d6cfc075 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveParams.kt @@ -7,6 +7,8 @@ import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Returns information about a specific file. that can be used across - Assistants API, Batch API @@ -24,14 +26,14 @@ import java.util.Objects class FileRetrieveParams private constructor( private val provider: String, - private val fileId: String, + private val fileId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun provider(): String = provider - fun fileId(): String = fileId + fun fileId(): Optional = Optional.ofNullable(fileId) fun _additionalHeaders(): Headers = additionalHeaders @@ -47,7 +49,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .fileId() * ``` */ @JvmStatic fun builder() = Builder() @@ -71,7 +72,10 @@ private constructor( fun provider(provider: String) = apply { this.provider = provider } - fun fileId(fileId: String) = apply { this.fileId = fileId } + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -179,7 +183,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .fileId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -187,7 +190,7 @@ private constructor( fun build(): FileRetrieveParams = FileRetrieveParams( checkRequired("provider", provider), - checkRequired("fileId", fileId), + fileId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -196,7 +199,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> provider - 1 -> fileId + 1 -> fileId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParams.kt index c74a4c27..b837e2cf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParams.kt @@ -7,6 +7,8 @@ import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Returns information about a specific file. that can be used across - Assistants API, Batch API @@ -25,14 +27,14 @@ import java.util.Objects class ContentRetrieveParams private constructor( private val provider: String, - private val fileId: String, + private val fileId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun provider(): String = provider - fun fileId(): String = fileId + fun fileId(): Optional = Optional.ofNullable(fileId) fun _additionalHeaders(): Headers = additionalHeaders @@ -48,7 +50,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .fileId() * ``` */ @JvmStatic fun builder() = Builder() @@ -72,7 +73,10 @@ private constructor( fun provider(provider: String) = apply { this.provider = provider } - fun fileId(fileId: String) = apply { this.fileId = fileId } + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -180,7 +184,6 @@ private constructor( * The following fields are required: * ```java * .provider() - * .fileId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -188,7 +191,7 @@ private constructor( fun build(): ContentRetrieveParams = ContentRetrieveParams( checkRequired("provider", provider), - checkRequired("fileId", fileId), + fileId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -197,7 +200,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> provider - 1 -> fileId + 1 -> fileId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt index 3a5e6500..9acc6993 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt @@ -11,6 +11,8 @@ import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Retrieves a fine-tuning job. This is the equivalent of GET @@ -22,13 +24,13 @@ import java.util.Objects */ class JobRetrieveParams private constructor( - private val fineTuningJobId: String, + private val fineTuningJobId: String?, private val customLlmProvider: CustomLlmProvider, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun fineTuningJobId(): String = fineTuningJobId + fun fineTuningJobId(): Optional = Optional.ofNullable(fineTuningJobId) fun customLlmProvider(): CustomLlmProvider = customLlmProvider @@ -45,7 +47,6 @@ private constructor( * * The following fields are required: * ```java - * .fineTuningJobId() * .customLlmProvider() * ``` */ @@ -68,10 +69,14 @@ private constructor( additionalQueryParams = jobRetrieveParams.additionalQueryParams.toBuilder() } - fun fineTuningJobId(fineTuningJobId: String) = apply { + fun fineTuningJobId(fineTuningJobId: String?) = apply { this.fineTuningJobId = fineTuningJobId } + /** Alias for calling [Builder.fineTuningJobId] with `fineTuningJobId.orElse(null)`. */ + fun fineTuningJobId(fineTuningJobId: Optional) = + fineTuningJobId(fineTuningJobId.getOrNull()) + fun customLlmProvider(customLlmProvider: CustomLlmProvider) = apply { this.customLlmProvider = customLlmProvider } @@ -181,7 +186,6 @@ private constructor( * * The following fields are required: * ```java - * .fineTuningJobId() * .customLlmProvider() * ``` * @@ -189,7 +193,7 @@ private constructor( */ fun build(): JobRetrieveParams = JobRetrieveParams( - checkRequired("fineTuningJobId", fineTuningJobId), + fineTuningJobId, checkRequired("customLlmProvider", customLlmProvider), additionalHeaders.build(), additionalQueryParams.build(), @@ -198,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> fineTuningJobId + 0 -> fineTuningJobId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt index ee50a826..86ca6c52 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.finetuning.jobs.cancel import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Cancel a fine-tuning job. @@ -23,13 +23,13 @@ import java.util.Optional */ class CancelCreateParams private constructor( - private val fineTuningJobId: String, + private val fineTuningJobId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun fineTuningJobId(): String = fineTuningJobId + fun fineTuningJobId(): Optional = Optional.ofNullable(fineTuningJobId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -41,14 +41,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CancelCreateParams]. - * - * The following fields are required: - * ```java - * .fineTuningJobId() - * ``` - */ + @JvmStatic fun none(): CancelCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CancelCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -68,10 +63,14 @@ private constructor( additionalBodyProperties = cancelCreateParams.additionalBodyProperties.toMutableMap() } - fun fineTuningJobId(fineTuningJobId: String) = apply { + fun fineTuningJobId(fineTuningJobId: String?) = apply { this.fineTuningJobId = fineTuningJobId } + /** Alias for calling [Builder.fineTuningJobId] with `fineTuningJobId.orElse(null)`. */ + fun fineTuningJobId(fineTuningJobId: Optional) = + fineTuningJobId(fineTuningJobId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -196,17 +195,10 @@ private constructor( * Returns an immutable instance of [CancelCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .fineTuningJobId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CancelCreateParams = CancelCreateParams( - checkRequired("fineTuningJobId", fineTuningJobId), + fineTuningJobId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -218,7 +210,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> fineTuningJobId + 0 -> fineTuningJobId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt index 2958e148..cdd5caa1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ class GeminiCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GeminiCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): GeminiCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [GeminiCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = geminiCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [GeminiCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): GeminiCreateParams = GeminiCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt index 28940b6a..3b708bf5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ class GeminiDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GeminiDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): GeminiDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [GeminiDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = geminiDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [GeminiDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): GeminiDeleteParams = GeminiDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt index 7efc0bf2..05e55e45 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ class GeminiPatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GeminiPatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): GeminiPatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [GeminiPatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = geminiPatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [GeminiPatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): GeminiPatchParams = GeminiPatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt index 4c9acaa9..f7e2b092 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ class GeminiRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GeminiRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): GeminiRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [GeminiRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = geminiRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [GeminiRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): GeminiRetrieveParams = - GeminiRetrieveParams( - checkRequired("endpoint", endpoint), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + GeminiRetrieveParams(endpoint, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt index 87af4b47..8f18ccbe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ class GeminiUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GeminiUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): GeminiUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [GeminiUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = geminiUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [GeminiUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): GeminiUpdateParams = GeminiUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt index f9b3a7f7..018b7764 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.immutableEmptyMap @@ -61,14 +60,14 @@ import kotlin.jvm.optionals.getOrNull */ class KeyRegenerateByKeyParams private constructor( - private val pathKey: String, + private val pathKey: String?, private val llmChangedBy: String?, private val regenerateKeyRequest: RegenerateKeyRequest?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun pathKey(): String = pathKey + fun pathKey(): Optional = Optional.ofNullable(pathKey) /** * The llm-changed-by header enables tracking of actions performed by authorized users on behalf @@ -90,14 +89,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [KeyRegenerateByKeyParams]. - * - * The following fields are required: - * ```java - * .pathKey() - * ``` - */ + @JvmStatic fun none(): KeyRegenerateByKeyParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [KeyRegenerateByKeyParams]. */ @JvmStatic fun builder() = Builder() } @@ -119,7 +113,10 @@ private constructor( additionalQueryParams = keyRegenerateByKeyParams.additionalQueryParams.toBuilder() } - fun pathKey(pathKey: String) = apply { this.pathKey = pathKey } + fun pathKey(pathKey: String?) = apply { this.pathKey = pathKey } + + /** Alias for calling [Builder.pathKey] with `pathKey.orElse(null)`. */ + fun pathKey(pathKey: Optional) = pathKey(pathKey.getOrNull()) /** * The llm-changed-by header enables tracking of actions performed by authorized users on @@ -243,17 +240,10 @@ private constructor( * Returns an immutable instance of [KeyRegenerateByKeyParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .pathKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): KeyRegenerateByKeyParams = KeyRegenerateByKeyParams( - checkRequired("pathKey", pathKey), + pathKey, llmChangedBy, regenerateKeyRequest, additionalHeaders.build(), @@ -265,7 +255,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> pathKey + 0 -> pathKey ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt index 5028eaa0..6da0aac7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class LangfuseCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [LangfuseCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): LangfuseCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LangfuseCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = langfuseCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [LangfuseCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): LangfuseCreateParams = LangfuseCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt index 0a9ff26a..61fb9cb3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class LangfuseDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [LangfuseDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): LangfuseDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LangfuseDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = langfuseDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [LangfuseDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): LangfuseDeleteParams = LangfuseDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt index 06cc2c2c..cd417e4d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class LangfusePatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [LangfusePatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): LangfusePatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LangfusePatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = langfusePatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [LangfusePatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): LangfusePatchParams = LangfusePatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt index 6c6d92a5..49fd19f2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. @@ -15,12 +16,12 @@ import java.util.Objects */ class LangfuseRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -30,14 +31,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [LangfuseRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): LangfuseRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LangfuseRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -55,7 +51,10 @@ private constructor( additionalQueryParams = langfuseRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -159,17 +158,10 @@ private constructor( * Returns an immutable instance of [LangfuseRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): LangfuseRetrieveParams = LangfuseRetrieveParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -177,7 +169,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt index 44de2678..b24b1648 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class LangfuseUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [LangfuseUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): LangfuseUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LangfuseUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = langfuseUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [LangfuseUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): LangfuseUpdateParams = LangfuseUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt index ebaea00e..6e5b028f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParams.kt @@ -8,6 +8,8 @@ import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * PATCH Endpoint for partial model updates. @@ -24,13 +26,13 @@ import java.util.Objects */ class UpdatePartialParams private constructor( - private val modelId: String, + private val modelId: String?, private val updateDeployment: UpdateDeployment, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun modelId(): String = modelId + fun modelId(): Optional = Optional.ofNullable(modelId) fun updateDeployment(): UpdateDeployment = updateDeployment @@ -50,7 +52,6 @@ private constructor( * * The following fields are required: * ```java - * .modelId() * .updateDeployment() * ``` */ @@ -73,7 +74,10 @@ private constructor( additionalQueryParams = updatePartialParams.additionalQueryParams.toBuilder() } - fun modelId(modelId: String) = apply { this.modelId = modelId } + fun modelId(modelId: String?) = apply { this.modelId = modelId } + + /** Alias for calling [Builder.modelId] with `modelId.orElse(null)`. */ + fun modelId(modelId: Optional) = modelId(modelId.getOrNull()) fun updateDeployment(updateDeployment: UpdateDeployment) = apply { this.updateDeployment = updateDeployment @@ -184,7 +188,6 @@ private constructor( * * The following fields are required: * ```java - * .modelId() * .updateDeployment() * ``` * @@ -192,7 +195,7 @@ private constructor( */ fun build(): UpdatePartialParams = UpdatePartialParams( - checkRequired("modelId", modelId), + modelId, checkRequired("updateDeployment", updateDeployment), additionalHeaders.build(), additionalQueryParams.build(), @@ -203,7 +206,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> modelId + 0 -> modelId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt index 8b8b99dd..0e10f7b2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ class OpenAICreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAICreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): OpenAICreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OpenAICreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = openaiCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [OpenAICreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): OpenAICreateParams = OpenAICreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt index 59abc202..e8f49c3a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ class OpenAIDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAIDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): OpenAIDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OpenAIDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = openaiDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [OpenAIDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): OpenAIDeleteParams = OpenAIDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt index a4445277..09b50d10 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ class OpenAIPatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAIPatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): OpenAIPatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OpenAIPatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = openaiPatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [OpenAIPatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): OpenAIPatchParams = OpenAIPatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParams.kt index aa20c155..dd291b57 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParams.kt @@ -3,20 +3,21 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ class OpenAIRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAIRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): OpenAIRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OpenAIRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = openaiRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [OpenAIRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): OpenAIRetrieveParams = - OpenAIRetrieveParams( - checkRequired("endpoint", endpoint), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + OpenAIRetrieveParams(endpoint, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt index 6983da52..02fdc568 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParams.kt @@ -4,23 +4,23 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ class OpenAIUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAIUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): OpenAIUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OpenAIUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -59,7 +54,10 @@ private constructor( additionalBodyProperties = openaiUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -185,17 +183,10 @@ private constructor( * Returns an immutable instance of [OpenAIUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): OpenAIUpdateParams = OpenAIUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -207,7 +198,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt index 11b074ff..3e26229a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.openai.deployments import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Follows the exact same API spec as `OpenAI's Completions API @@ -29,13 +29,13 @@ import java.util.Optional */ class DeploymentCompleteParams private constructor( - private val model: String, + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun model(): String = model + fun model(): Optional = Optional.ofNullable(model) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -47,14 +47,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [DeploymentCompleteParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ + @JvmStatic fun none(): DeploymentCompleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentCompleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -75,7 +70,10 @@ private constructor( deploymentCompleteParams.additionalBodyProperties.toMutableMap() } - fun model(model: String) = apply { this.model = model } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -201,17 +199,10 @@ private constructor( * Returns an immutable instance of [DeploymentCompleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .model() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): DeploymentCompleteParams = DeploymentCompleteParams( - checkRequired("model", model), + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -223,7 +214,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> model + 0 -> model ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt index cad94bf3..392aacfd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.openai.deployments import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Follows the exact same API spec as `OpenAI's Embeddings API @@ -27,13 +27,13 @@ import java.util.Optional */ class DeploymentEmbedParams private constructor( - private val model: String, + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun model(): String = model + fun model(): Optional = Optional.ofNullable(model) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -45,14 +45,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [DeploymentEmbedParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ + @JvmStatic fun none(): DeploymentEmbedParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DeploymentEmbedParams]. */ @JvmStatic fun builder() = Builder() } @@ -72,7 +67,10 @@ private constructor( additionalBodyProperties = deploymentEmbedParams.additionalBodyProperties.toMutableMap() } - fun model(model: String) = apply { this.model = model } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -198,17 +196,10 @@ private constructor( * Returns an immutable instance of [DeploymentEmbedParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .model() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): DeploymentEmbedParams = DeploymentEmbedParams( - checkRequired("model", model), + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -220,7 +211,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> model + 0 -> model ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt index 7d553ad7..a10afbc2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.openai.deployments.chat import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Follows the exact same API spec as `OpenAI's Chat API @@ -32,13 +32,13 @@ import java.util.Optional */ class ChatCompleteParams private constructor( - private val model: String, + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun model(): String = model + fun model(): Optional = Optional.ofNullable(model) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -50,14 +50,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ChatCompleteParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ + @JvmStatic fun none(): ChatCompleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ChatCompleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -77,7 +72,10 @@ private constructor( additionalBodyProperties = chatCompleteParams.additionalBodyProperties.toMutableMap() } - fun model(model: String) = apply { this.model = model } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -203,17 +201,10 @@ private constructor( * Returns an immutable instance of [ChatCompleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .model() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ChatCompleteParams = ChatCompleteParams( - checkRequired("model", model), + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -225,7 +216,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> model + 0 -> model ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt index 97fba8a0..60af777d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.responses import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Delete a response by ID. @@ -23,13 +23,13 @@ import java.util.Optional */ class ResponseDeleteParams private constructor( - private val responseId: String, + private val responseId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun responseId(): String = responseId + fun responseId(): Optional = Optional.ofNullable(responseId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -41,14 +41,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ResponseDeleteParams]. - * - * The following fields are required: - * ```java - * .responseId() - * ``` - */ + @JvmStatic fun none(): ResponseDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ResponseDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -68,7 +63,10 @@ private constructor( additionalBodyProperties = responseDeleteParams.additionalBodyProperties.toMutableMap() } - fun responseId(responseId: String) = apply { this.responseId = responseId } + fun responseId(responseId: String?) = apply { this.responseId = responseId } + + /** Alias for calling [Builder.responseId] with `responseId.orElse(null)`. */ + fun responseId(responseId: Optional) = responseId(responseId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -194,17 +192,10 @@ private constructor( * Returns an immutable instance of [ResponseDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .responseId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ResponseDeleteParams = ResponseDeleteParams( - checkRequired("responseId", responseId), + responseId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -216,7 +207,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> responseId + 0 -> responseId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParams.kt index 19496d9a..c14a93c6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.responses import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Get a response by ID. @@ -20,12 +21,12 @@ import java.util.Objects */ class ResponseRetrieveParams private constructor( - private val responseId: String, + private val responseId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun responseId(): String = responseId + fun responseId(): Optional = Optional.ofNullable(responseId) fun _additionalHeaders(): Headers = additionalHeaders @@ -35,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ResponseRetrieveParams]. - * - * The following fields are required: - * ```java - * .responseId() - * ``` - */ + @JvmStatic fun none(): ResponseRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ResponseRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +56,10 @@ private constructor( additionalQueryParams = responseRetrieveParams.additionalQueryParams.toBuilder() } - fun responseId(responseId: String) = apply { this.responseId = responseId } + fun responseId(responseId: String?) = apply { this.responseId = responseId } + + /** Alias for calling [Builder.responseId] with `responseId.orElse(null)`. */ + fun responseId(responseId: Optional) = responseId(responseId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -164,17 +163,10 @@ private constructor( * Returns an immutable instance of [ResponseRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .responseId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ResponseRetrieveParams = ResponseRetrieveParams( - checkRequired("responseId", responseId), + responseId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -182,7 +174,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> responseId + 0 -> responseId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParams.kt index 2ff6b97e..4d6da863 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.responses.inputitems import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Get input items for a response. @@ -20,12 +21,12 @@ import java.util.Objects */ class InputItemListParams private constructor( - private val responseId: String, + private val responseId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun responseId(): String = responseId + fun responseId(): Optional = Optional.ofNullable(responseId) fun _additionalHeaders(): Headers = additionalHeaders @@ -35,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InputItemListParams]. - * - * The following fields are required: - * ```java - * .responseId() - * ``` - */ + @JvmStatic fun none(): InputItemListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InputItemListParams]. */ @JvmStatic fun builder() = Builder() } @@ -60,7 +56,10 @@ private constructor( additionalQueryParams = inputItemListParams.additionalQueryParams.toBuilder() } - fun responseId(responseId: String) = apply { this.responseId = responseId } + fun responseId(responseId: String?) = apply { this.responseId = responseId } + + /** Alias for calling [Builder.responseId] with `responseId.orElse(null)`. */ + fun responseId(responseId: Optional) = responseId(responseId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -164,17 +163,10 @@ private constructor( * Returns an immutable instance of [InputItemListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .responseId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): InputItemListParams = InputItemListParams( - checkRequired("responseId", responseId), + responseId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -182,7 +174,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> responseId + 0 -> responseId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt index cd1b73ca..307621b7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Disable all logging callbacks for a team @@ -24,13 +24,13 @@ import java.util.Optional */ class TeamDisableLoggingParams private constructor( - private val teamId: String, + private val teamId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun teamId(): String = teamId + fun teamId(): Optional = Optional.ofNullable(teamId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -42,14 +42,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [TeamDisableLoggingParams]. - * - * The following fields are required: - * ```java - * .teamId() - * ``` - */ + @JvmStatic fun none(): TeamDisableLoggingParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TeamDisableLoggingParams]. */ @JvmStatic fun builder() = Builder() } @@ -70,7 +65,10 @@ private constructor( teamDisableLoggingParams.additionalBodyProperties.toMutableMap() } - fun teamId(teamId: String) = apply { this.teamId = teamId } + fun teamId(teamId: String?) = apply { this.teamId = teamId } + + /** Alias for calling [Builder.teamId] with `teamId.orElse(null)`. */ + fun teamId(teamId: Optional) = teamId(teamId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -196,17 +194,10 @@ private constructor( * Returns an immutable instance of [TeamDisableLoggingParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .teamId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): TeamDisableLoggingParams = TeamDisableLoggingParams( - checkRequired("teamId", teamId), + teamId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -218,7 +209,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> teamId + 0 -> teamId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt index 2e04e928..c585f97d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt @@ -62,14 +62,14 @@ import kotlin.jvm.optionals.getOrNull */ class CallbackAddParams private constructor( - private val teamId: String, + private val teamId: String?, private val llmChangedBy: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun teamId(): String = teamId + fun teamId(): Optional = Optional.ofNullable(teamId) /** * The llm-changed-by header enables tracking of actions performed by authorized users on behalf @@ -131,7 +131,6 @@ private constructor( * * The following fields are required: * ```java - * .teamId() * .callbackName() * .callbackVars() * ``` @@ -157,7 +156,10 @@ private constructor( additionalQueryParams = callbackAddParams.additionalQueryParams.toBuilder() } - fun teamId(teamId: String) = apply { this.teamId = teamId } + fun teamId(teamId: String?) = apply { this.teamId = teamId } + + /** Alias for calling [Builder.teamId] with `teamId.orElse(null)`. */ + fun teamId(teamId: Optional) = teamId(teamId.getOrNull()) /** * The llm-changed-by header enables tracking of actions performed by authorized users on @@ -346,7 +348,6 @@ private constructor( * * The following fields are required: * ```java - * .teamId() * .callbackName() * .callbackVars() * ``` @@ -355,7 +356,7 @@ private constructor( */ fun build(): CallbackAddParams = CallbackAddParams( - checkRequired("teamId", teamId), + teamId, llmChangedBy, body.build(), additionalHeaders.build(), @@ -367,7 +368,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> teamId + 0 -> teamId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParams.kt index 7113709f..59166beb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.team.callback import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Get the success/failure callbacks and variables for a team @@ -28,12 +29,12 @@ import java.util.Objects */ class CallbackRetrieveParams private constructor( - private val teamId: String, + private val teamId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun teamId(): String = teamId + fun teamId(): Optional = Optional.ofNullable(teamId) fun _additionalHeaders(): Headers = additionalHeaders @@ -43,14 +44,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CallbackRetrieveParams]. - * - * The following fields are required: - * ```java - * .teamId() - * ``` - */ + @JvmStatic fun none(): CallbackRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CallbackRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -68,7 +64,10 @@ private constructor( additionalQueryParams = callbackRetrieveParams.additionalQueryParams.toBuilder() } - fun teamId(teamId: String) = apply { this.teamId = teamId } + fun teamId(teamId: String?) = apply { this.teamId = teamId } + + /** Alias for calling [Builder.teamId] with `teamId.orElse(null)`. */ + fun teamId(teamId: Optional) = teamId(teamId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -172,25 +171,14 @@ private constructor( * Returns an immutable instance of [CallbackRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .teamId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CallbackRetrieveParams = - CallbackRetrieveParams( - checkRequired("teamId", teamId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + CallbackRetrieveParams(teamId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> teamId + 0 -> teamId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParams.kt index 10bedf7f..7cbbd464 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.threads import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Retrieves a thread. @@ -15,12 +16,12 @@ import java.util.Objects */ class ThreadRetrieveParams private constructor( - private val threadId: String, + private val threadId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun threadId(): String = threadId + fun threadId(): Optional = Optional.ofNullable(threadId) fun _additionalHeaders(): Headers = additionalHeaders @@ -30,14 +31,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ThreadRetrieveParams]. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - */ + @JvmStatic fun none(): ThreadRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ThreadRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -55,7 +51,10 @@ private constructor( additionalQueryParams = threadRetrieveParams.additionalQueryParams.toBuilder() } - fun threadId(threadId: String) = apply { this.threadId = threadId } + fun threadId(threadId: String?) = apply { this.threadId = threadId } + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -159,25 +158,14 @@ private constructor( * Returns an immutable instance of [ThreadRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ThreadRetrieveParams = - ThreadRetrieveParams( - checkRequired("threadId", threadId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + ThreadRetrieveParams(threadId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> threadId + 0 -> threadId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt index f46a0982..4d0adec2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.threads.messages import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a message. @@ -18,13 +18,13 @@ import java.util.Optional */ class MessageCreateParams private constructor( - private val threadId: String, + private val threadId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun threadId(): String = threadId + fun threadId(): Optional = Optional.ofNullable(threadId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [MessageCreateParams]. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - */ + @JvmStatic fun none(): MessageCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = messageCreateParams.additionalBodyProperties.toMutableMap() } - fun threadId(threadId: String) = apply { this.threadId = threadId } + fun threadId(threadId: String?) = apply { this.threadId = threadId } + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [MessageCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): MessageCreateParams = MessageCreateParams( - checkRequired("threadId", threadId), + threadId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> threadId + 0 -> threadId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListParams.kt index eeeed6af..ec0ae6d1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.threads.messages import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Returns a list of messages for a given thread. @@ -15,12 +16,12 @@ import java.util.Objects */ class MessageListParams private constructor( - private val threadId: String, + private val threadId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun threadId(): String = threadId + fun threadId(): Optional = Optional.ofNullable(threadId) fun _additionalHeaders(): Headers = additionalHeaders @@ -30,14 +31,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [MessageListParams]. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - */ + @JvmStatic fun none(): MessageListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageListParams]. */ @JvmStatic fun builder() = Builder() } @@ -55,7 +51,10 @@ private constructor( additionalQueryParams = messageListParams.additionalQueryParams.toBuilder() } - fun threadId(threadId: String) = apply { this.threadId = threadId } + fun threadId(threadId: String?) = apply { this.threadId = threadId } + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -159,25 +158,14 @@ private constructor( * Returns an immutable instance of [MessageListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): MessageListParams = - MessageListParams( - checkRequired("threadId", threadId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + MessageListParams(threadId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> threadId + 0 -> threadId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt index 3539cbb9..d2e528fe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.threads.runs import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a run. @@ -18,13 +18,13 @@ import java.util.Optional */ class RunCreateParams private constructor( - private val threadId: String, + private val threadId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun threadId(): String = threadId + fun threadId(): Optional = Optional.ofNullable(threadId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [RunCreateParams]. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - */ + @JvmStatic fun none(): RunCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = runCreateParams.additionalBodyProperties.toMutableMap() } - fun threadId(threadId: String) = apply { this.threadId = threadId } + fun threadId(threadId: String?) = apply { this.threadId = threadId } + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [RunCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .threadId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): RunCreateParams = RunCreateParams( - checkRequired("threadId", threadId), + threadId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> threadId + 0 -> threadId ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt index f164a447..977f7d57 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call LLM proxy via Vertex AI SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class VertexAiCreateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [VertexAiCreateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): VertexAiCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VertexAiCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = vertexAiCreateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [VertexAiCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): VertexAiCreateParams = VertexAiCreateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt index 33233b61..edc2427d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call LLM proxy via Vertex AI SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class VertexAiDeleteParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [VertexAiDeleteParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): VertexAiDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VertexAiDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = vertexAiDeleteParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [VertexAiDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): VertexAiDeleteParams = VertexAiDeleteParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt index ee65e055..76d018cb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call LLM proxy via Vertex AI SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class VertexAiPatchParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [VertexAiPatchParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): VertexAiPatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VertexAiPatchParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = vertexAiPatchParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [VertexAiPatchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): VertexAiPatchParams = VertexAiPatchParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParams.kt index 99ead48c..6b834d51 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParams.kt @@ -3,10 +3,11 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call LLM proxy via Vertex AI SDK. @@ -15,12 +16,12 @@ import java.util.Objects */ class VertexAiRetrieveParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalHeaders(): Headers = additionalHeaders @@ -30,14 +31,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [VertexAiRetrieveParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): VertexAiRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VertexAiRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -55,7 +51,10 @@ private constructor( additionalQueryParams = vertexAiRetrieveParams.additionalQueryParams.toBuilder() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -159,17 +158,10 @@ private constructor( * Returns an immutable instance of [VertexAiRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): VertexAiRetrieveParams = VertexAiRetrieveParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -177,7 +169,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt index f7bf1bee..9c50aba1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParams.kt @@ -4,12 +4,12 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Call LLM proxy via Vertex AI SDK. @@ -18,13 +18,13 @@ import java.util.Optional */ class VertexAiUpdateParams private constructor( - private val endpoint: String, + private val endpoint: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun endpoint(): String = endpoint + fun endpoint(): Optional = Optional.ofNullable(endpoint) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [VertexAiUpdateParams]. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - */ + @JvmStatic fun none(): VertexAiUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VertexAiUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = vertexAiUpdateParams.additionalBodyProperties.toMutableMap() } - fun endpoint(endpoint: String) = apply { this.endpoint = endpoint } + fun endpoint(endpoint: String?) = apply { this.endpoint = endpoint } + + /** Alias for calling [Builder.endpoint] with `endpoint.orElse(null)`. */ + fun endpoint(endpoint: Optional) = endpoint(endpoint.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [VertexAiUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endpoint() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): VertexAiUpdateParams = VertexAiUpdateParams( - checkRequired("endpoint", endpoint), + endpoint, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> endpoint + 0 -> endpoint ?: "" else -> "" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt index 9492244c..a49ccb0d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt @@ -25,8 +25,22 @@ interface AnthropicServiceAsync { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun create(params: AnthropicCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, AnthropicCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,9 +48,35 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: AnthropicCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, AnthropicCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun retrieve(params: AnthropicRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, AnthropicRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + ): CompletableFuture = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -44,9 +84,34 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: AnthropicRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, AnthropicRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun update(params: AnthropicUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, AnthropicUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -54,9 +119,34 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: AnthropicUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, AnthropicUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun delete(params: AnthropicDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, AnthropicDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -64,9 +154,34 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: AnthropicDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, AnthropicDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun modify(params: AnthropicModifyParams): CompletableFuture = - modify(params, RequestOptions.none()) + fun modify(endpoint: String): CompletableFuture = + modify(endpoint, AnthropicModifyParams.none()) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + ): CompletableFuture = modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ fun modify( @@ -74,6 +189,17 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [modify] */ + fun modify(params: AnthropicModifyParams): CompletableFuture = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + fun modify( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + modify(endpoint, AnthropicModifyParams.none(), requestOptions) + /** * A view of [AnthropicServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -84,10 +210,25 @@ interface AnthropicServiceAsync { * as [AnthropicServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, AnthropicCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: AnthropicCreateParams + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -96,15 +237,47 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: AnthropicCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, AnthropicCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /anthropic/{endpoint}`, but is otherwise the same as * [AnthropicServiceAsync.retrieve]. */ @MustBeClosed fun retrieve( - params: AnthropicRetrieveParams + endpoint: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(endpoint, AnthropicRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -113,15 +286,45 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AnthropicRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, AnthropicRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /anthropic/{endpoint}`, but is otherwise the same as * [AnthropicServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, AnthropicUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: AnthropicUpdateParams + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -130,15 +333,45 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: AnthropicUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, AnthropicUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, AnthropicDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: AnthropicDeleteParams + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -147,15 +380,45 @@ interface AnthropicServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: AnthropicDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, AnthropicDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicServiceAsync.modify]. */ @MustBeClosed + fun modify(endpoint: String): CompletableFuture> = + modify(endpoint, AnthropicModifyParams.none()) + + /** @see [modify] */ + @MustBeClosed fun modify( - params: AnthropicModifyParams + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - modify(params, RequestOptions.none()) + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + ): CompletableFuture> = + modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ @MustBeClosed @@ -163,5 +426,20 @@ interface AnthropicServiceAsync { params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [modify] */ + @MustBeClosed + fun modify( + params: AnthropicModifyParams + ): CompletableFuture> = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + modify(endpoint, AnthropicModifyParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt index 9e8b7a8e..94739ec3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.anthropic.AnthropicRetrieveResponse import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import ai.hanzo.api.models.anthropic.AnthropicUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AnthropicServiceAsync { @@ -84,6 +86,9 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: params: AnthropicCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: params: AnthropicRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: params: AnthropicUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: params: AnthropicDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: params: AnthropicModifyParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt index 4b18bfda..fc13add3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt @@ -25,8 +25,22 @@ interface AssemblyaiServiceAsync { fun withRawResponse(): WithRawResponse /** Assemblyai Proxy Route */ - fun create(params: AssemblyaiCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, AssemblyaiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,9 +48,35 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: AssemblyaiCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, AssemblyaiCreateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun retrieve(params: AssemblyaiRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, AssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + ): CompletableFuture = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -44,9 +84,34 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: AssemblyaiRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, AssemblyaiRetrieveParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun update(params: AssemblyaiUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, AssemblyaiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -54,9 +119,34 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: AssemblyaiUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, AssemblyaiUpdateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun delete(params: AssemblyaiDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, AssemblyaiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -64,9 +154,34 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: AssemblyaiDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, AssemblyaiDeleteParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun patch(params: AssemblyaiPatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, AssemblyaiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -74,6 +189,17 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: AssemblyaiPatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, AssemblyaiPatchParams.none(), requestOptions) + /** * A view of [AssemblyaiServiceAsync] that provides access to raw HTTP responses for each * method. @@ -85,10 +211,25 @@ interface AssemblyaiServiceAsync { * as [AssemblyaiServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, AssemblyaiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: AssemblyaiCreateParams + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -97,15 +238,47 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: AssemblyaiCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, AssemblyaiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.retrieve]. */ @MustBeClosed fun retrieve( - params: AssemblyaiRetrieveParams + endpoint: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(endpoint, AssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -114,15 +287,45 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AssemblyaiRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, AssemblyaiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, AssemblyaiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: AssemblyaiUpdateParams + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -131,15 +334,45 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: AssemblyaiUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, AssemblyaiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /assemblyai/{endpoint}`, but is otherwise the * same as [AssemblyaiServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, AssemblyaiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: AssemblyaiDeleteParams + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -148,15 +381,45 @@ interface AssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: AssemblyaiDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, AssemblyaiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, AssemblyaiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: AssemblyaiPatchParams + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -164,5 +427,20 @@ interface AssemblyaiServiceAsync { params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: AssemblyaiPatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, AssemblyaiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt index 4c52a9e9..d904cb86 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveResponse import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AssemblyaiServiceAsync { @@ -84,6 +86,9 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: params: AssemblyaiCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: params: AssemblyaiRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: params: AssemblyaiUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: params: AssemblyaiDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: params: AssemblyaiPatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt index 2452963e..b83f912a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt @@ -71,8 +71,23 @@ interface AssistantServiceAsync { * API Reference docs - * https://platform.openai.com/docs/api-reference/assistants/createAssistant */ - fun delete(params: AssistantDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(assistantId: String): CompletableFuture = + delete(assistantId, AssistantDeleteParams.none()) + + /** @see [delete] */ + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) + + /** @see [delete] */ + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + ): CompletableFuture = + delete(assistantId, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -80,6 +95,17 @@ interface AssistantServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: AssistantDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + assistantId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(assistantId, AssistantDeleteParams.none(), requestOptions) + /** * A view of [AssistantServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -149,9 +175,26 @@ interface AssistantServiceAsync { */ @MustBeClosed fun delete( - params: AssistantDeleteParams + assistantId: String ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(assistantId, AssistantDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + ): CompletableFuture> = + delete(assistantId, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -159,5 +202,20 @@ interface AssistantServiceAsync { params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [delete] */ + @MustBeClosed + fun delete( + params: AssistantDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + assistantId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(assistantId, AssistantDeleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt index b13e0af6..4b18e822 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import ai.hanzo.api.models.assistants.AssistantDeleteResponse import ai.hanzo.api.models.assistants.AssistantListParams import ai.hanzo.api.models.assistants.AssistantListResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class AssistantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AssistantServiceAsync { @@ -127,6 +129,9 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: params: AssistantDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("assistantId", params.assistantId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt index d590326e..a97fb2b1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt @@ -29,8 +29,22 @@ interface AzureServiceAsync { * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun create(params: AzureCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, AzureCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -38,13 +52,38 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: AzureCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, AzureCreateParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun update(params: AzureUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, AzureUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -52,13 +91,38 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: AzureUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, AzureUpdateParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun delete(params: AzureDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, AzureDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -66,13 +130,38 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: AzureDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, AzureDeleteParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun call(params: AzureCallParams): CompletableFuture = - call(params, RequestOptions.none()) + fun call(endpoint: String): CompletableFuture = + call(endpoint, AzureCallParams.none()) + + /** @see [call] */ + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + call(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [call] */ + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + ): CompletableFuture = call(endpoint, params, RequestOptions.none()) /** @see [call] */ fun call( @@ -80,13 +169,37 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [call] */ + fun call(params: AzureCallParams): CompletableFuture = + call(params, RequestOptions.none()) + + /** @see [call] */ + fun call( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = call(endpoint, AzureCallParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun patch(params: AzurePatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, AzurePatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -94,6 +207,17 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: AzurePatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, AzurePatchParams.none(), requestOptions) + /** A view of [AzureServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -102,10 +226,25 @@ interface AzureServiceAsync { * [AzureServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, AzureCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: AzureCreateParams + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -114,15 +253,45 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: AzureCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, AzureCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, AzureUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: AzureUpdateParams + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -131,15 +300,45 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: AzureUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, AzureUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, AzureDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: AzureDeleteParams + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -148,13 +347,45 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: AzureDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, AzureDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.call]. */ @MustBeClosed - fun call(params: AzureCallParams): CompletableFuture> = - call(params, RequestOptions.none()) + fun call(endpoint: String): CompletableFuture> = + call(endpoint, AzureCallParams.none()) + + /** @see [call] */ + @MustBeClosed + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + call(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [call] */ + @MustBeClosed + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + ): CompletableFuture> = + call(endpoint, params, RequestOptions.none()) /** @see [call] */ @MustBeClosed @@ -163,15 +394,43 @@ interface AzureServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [call] */ + @MustBeClosed + fun call(params: AzureCallParams): CompletableFuture> = + call(params, RequestOptions.none()) + + /** @see [call] */ + @MustBeClosed + fun call( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + call(endpoint, AzureCallParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, AzurePatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: AzurePatchParams + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -179,5 +438,20 @@ interface AzureServiceAsync { params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: AzurePatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, AzurePatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt index fb2d9555..44bfefcc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.azure.AzurePatchResponse import ai.hanzo.api.models.azure.AzureUpdateParams import ai.hanzo.api.models.azure.AzureUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class AzureServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AzureServiceAsync { @@ -84,6 +86,9 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AzureCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AzureUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -146,6 +154,9 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AzureDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -176,6 +187,9 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AzureCallParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -205,6 +219,9 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AzurePatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt index 8e50ddf3..a448f337 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt @@ -73,8 +73,22 @@ interface BatchServiceAsync { * curl http://localhost:4000/v1/batches/batch_abc123 -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" * ``` */ - fun retrieve(params: BatchRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(batchId: String): CompletableFuture = + retrieve(batchId, BatchRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + ): CompletableFuture = retrieve(batchId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -82,6 +96,17 @@ interface BatchServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: BatchRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(batchId, BatchRetrieveParams.none(), requestOptions) + /** * Lists This is the equivalent of GET https://api.openai.com/v1/batches/ Supports Identical * Params as: https://platform.openai.com/docs/api-reference/batch/list @@ -122,6 +147,21 @@ interface BatchServiceAsync { * * ``` */ + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + ): CompletableFuture = + cancelWithProvider(batchId, params, RequestOptions.none()) + + /** @see [cancelWithProvider] */ + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancelWithProvider] */ fun cancelWithProvider( params: BatchCancelWithProviderParams ): CompletableFuture = @@ -148,10 +188,23 @@ interface BatchServiceAsync { * }' * ``` */ + fun createWithProvider(provider: String): CompletableFuture = + createWithProvider(provider, BatchCreateWithProviderParams.none()) + + /** @see [createWithProvider] */ fun createWithProvider( - params: BatchCreateWithProviderParams + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - createWithProvider(params, RequestOptions.none()) + createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [createWithProvider] */ + fun createWithProvider( + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + ): CompletableFuture = + createWithProvider(provider, params, RequestOptions.none()) /** @see [createWithProvider] */ fun createWithProvider( @@ -159,6 +212,19 @@ interface BatchServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [createWithProvider] */ + fun createWithProvider( + params: BatchCreateWithProviderParams + ): CompletableFuture = + createWithProvider(params, RequestOptions.none()) + + /** @see [createWithProvider] */ + fun createWithProvider( + provider: String, + requestOptions: RequestOptions, + ): CompletableFuture = + createWithProvider(provider, BatchCreateWithProviderParams.none(), requestOptions) + /** * Lists This is the equivalent of GET https://api.openai.com/v1/batches/ Supports Identical * Params as: https://platform.openai.com/docs/api-reference/batch/list @@ -169,10 +235,23 @@ interface BatchServiceAsync { * curl http://localhost:4000/v1/batches?limit=2 -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" * ``` */ + fun listWithProvider(provider: String): CompletableFuture = + listWithProvider(provider, BatchListWithProviderParams.none()) + + /** @see [listWithProvider] */ fun listWithProvider( - params: BatchListWithProviderParams + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - listWithProvider(params, RequestOptions.none()) + listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [listWithProvider] */ + fun listWithProvider( + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + ): CompletableFuture = + listWithProvider(provider, params, RequestOptions.none()) /** @see [listWithProvider] */ fun listWithProvider( @@ -180,6 +259,19 @@ interface BatchServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [listWithProvider] */ + fun listWithProvider( + params: BatchListWithProviderParams + ): CompletableFuture = + listWithProvider(params, RequestOptions.none()) + + /** @see [listWithProvider] */ + fun listWithProvider( + provider: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listWithProvider(provider, BatchListWithProviderParams.none(), requestOptions) + /** * Retrieves a batch. This is the equivalent of GET https://api.openai.com/v1/batches/{batch_id} * Supports Identical Params as: https://platform.openai.com/docs/api-reference/batch/retrieve @@ -190,6 +282,21 @@ interface BatchServiceAsync { * curl http://localhost:4000/v1/batches/batch_abc123 -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" * ``` */ + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + ): CompletableFuture = + retrieveWithProvider(batchId, params, RequestOptions.none()) + + /** @see [retrieveWithProvider] */ + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieveWithProvider] */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): CompletableFuture = @@ -240,10 +347,25 @@ interface BatchServiceAsync { * as [BatchServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve(batchId: String): CompletableFuture> = + retrieve(batchId, BatchRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: BatchRetrieveParams + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + ): CompletableFuture> = + retrieve(batchId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -252,6 +374,21 @@ interface BatchServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BatchRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(batchId, BatchRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /v1/batches`, but is otherwise the same as * [BatchServiceAsync.list]. @@ -286,6 +423,23 @@ interface BatchServiceAsync { * otherwise the same as [BatchServiceAsync.cancelWithProvider]. */ @MustBeClosed + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + ): CompletableFuture> = + cancelWithProvider(batchId, params, RequestOptions.none()) + + /** @see [cancelWithProvider] */ + @MustBeClosed + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancelWithProvider] */ + @MustBeClosed fun cancelWithProvider( params: BatchCancelWithProviderParams ): CompletableFuture> = @@ -304,9 +458,26 @@ interface BatchServiceAsync { */ @MustBeClosed fun createWithProvider( - params: BatchCreateWithProviderParams + provider: String ): CompletableFuture> = - createWithProvider(params, RequestOptions.none()) + createWithProvider(provider, BatchCreateWithProviderParams.none()) + + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + ): CompletableFuture> = + createWithProvider(provider, params, RequestOptions.none()) /** @see [createWithProvider] */ @MustBeClosed @@ -315,15 +486,47 @@ interface BatchServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + params: BatchCreateWithProviderParams + ): CompletableFuture> = + createWithProvider(params, RequestOptions.none()) + + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + provider: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + createWithProvider(provider, BatchCreateWithProviderParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /{provider}/v1/batches`, but is otherwise the same * as [BatchServiceAsync.listWithProvider]. */ @MustBeClosed fun listWithProvider( - params: BatchListWithProviderParams + provider: String ): CompletableFuture> = - listWithProvider(params, RequestOptions.none()) + listWithProvider(provider, BatchListWithProviderParams.none()) + + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + ): CompletableFuture> = + listWithProvider(provider, params, RequestOptions.none()) /** @see [listWithProvider] */ @MustBeClosed @@ -332,11 +535,43 @@ interface BatchServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + params: BatchListWithProviderParams + ): CompletableFuture> = + listWithProvider(params, RequestOptions.none()) + + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + provider: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listWithProvider(provider, BatchListWithProviderParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /{provider}/v1/batches/{batch_id}`, but is otherwise * the same as [BatchServiceAsync.retrieveWithProvider]. */ @MustBeClosed + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + ): CompletableFuture> = + retrieveWithProvider(batchId, params, RequestOptions.none()) + + /** @see [retrieveWithProvider] */ + @MustBeClosed + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieveWithProvider] */ + @MustBeClosed fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt index 81ca434c..2c706f13 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -32,6 +33,7 @@ import ai.hanzo.api.models.batches.BatchRetrieveWithProviderResponse import ai.hanzo.api.services.async.batches.CancelServiceAsync import ai.hanzo.api.services.async.batches.CancelServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BatchServiceAsync { @@ -145,6 +147,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie params: BatchRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -204,6 +209,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie params: BatchCancelWithProviderParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -241,6 +249,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie params: BatchCreateWithProviderParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -272,6 +283,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie params: BatchListWithProviderParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -302,6 +316,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie params: BatchRetrieveWithProviderParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt index 072e7cb3..3fa1d6ca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt @@ -25,8 +25,22 @@ interface BedrockServiceAsync { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun create(params: BedrockCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, BedrockCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,9 +48,35 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: BedrockCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, BedrockCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun retrieve(params: BedrockRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, BedrockRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + ): CompletableFuture = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -44,9 +84,34 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: BedrockRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, BedrockRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun update(params: BedrockUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, BedrockUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -54,9 +119,34 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: BedrockUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, BedrockUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun delete(params: BedrockDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, BedrockDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -64,9 +154,34 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: BedrockDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, BedrockDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun patch(params: BedrockPatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, BedrockPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -74,6 +189,17 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: BedrockPatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, BedrockPatchParams.none(), requestOptions) + /** * A view of [BedrockServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -84,10 +210,25 @@ interface BedrockServiceAsync { * [BedrockServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, BedrockCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: BedrockCreateParams + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -96,15 +237,47 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: BedrockCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, BedrockCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.retrieve]. */ @MustBeClosed fun retrieve( - params: BedrockRetrieveParams + endpoint: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(endpoint, BedrockRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -113,15 +286,45 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BedrockRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, BedrockRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, BedrockUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: BedrockUpdateParams + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -130,15 +333,45 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: BedrockUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, BedrockUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /bedrock/{endpoint}`, but is otherwise the same * as [BedrockServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, BedrockDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: BedrockDeleteParams + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -147,15 +380,45 @@ interface BedrockServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: BedrockDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, BedrockDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, BedrockPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: BedrockPatchParams + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -163,5 +426,20 @@ interface BedrockServiceAsync { params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: BedrockPatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, BedrockPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt index 395fd09d..c0e8c07c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.bedrock.BedrockRetrieveResponse import ai.hanzo.api.models.bedrock.BedrockUpdateParams import ai.hanzo.api.models.bedrock.BedrockUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class BedrockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BedrockServiceAsync { @@ -84,6 +86,9 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl params: BedrockCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl params: BedrockRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl params: BedrockUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl params: BedrockDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl params: BedrockPatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt index 266ab494..c5415081 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt @@ -25,8 +25,22 @@ interface CohereServiceAsync { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun create(params: CohereCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, CohereCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,9 +48,34 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: CohereCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, CohereCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun retrieve(params: CohereRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, CohereRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -44,9 +83,34 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: CohereRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, CohereRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun update(params: CohereUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, CohereUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -54,9 +118,34 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: CohereUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, CohereUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun delete(params: CohereDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, CohereDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -64,9 +153,34 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: CohereDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, CohereDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun modify(params: CohereModifyParams): CompletableFuture = - modify(params, RequestOptions.none()) + fun modify(endpoint: String): CompletableFuture = + modify(endpoint, CohereModifyParams.none()) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + ): CompletableFuture = modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ fun modify( @@ -74,6 +188,17 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [modify] */ + fun modify(params: CohereModifyParams): CompletableFuture = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + fun modify( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + modify(endpoint, CohereModifyParams.none(), requestOptions) + /** * A view of [CohereServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -84,10 +209,25 @@ interface CohereServiceAsync { * [CohereServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, CohereCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: CohereCreateParams + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -96,15 +236,45 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: CohereCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, CohereCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve(endpoint: String): CompletableFuture> = + retrieve(endpoint, CohereRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: CohereRetrieveParams + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -113,15 +283,45 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CohereRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, CohereRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, CohereUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: CohereUpdateParams + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -130,15 +330,45 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: CohereUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, CohereUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, CohereDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: CohereDeleteParams + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -147,15 +377,45 @@ interface CohereServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: CohereDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, CohereDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.modify]. */ @MustBeClosed + fun modify(endpoint: String): CompletableFuture> = + modify(endpoint, CohereModifyParams.none()) + + /** @see [modify] */ + @MustBeClosed fun modify( - params: CohereModifyParams + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - modify(params, RequestOptions.none()) + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + ): CompletableFuture> = + modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ @MustBeClosed @@ -163,5 +423,20 @@ interface CohereServiceAsync { params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [modify] */ + @MustBeClosed + fun modify( + params: CohereModifyParams + ): CompletableFuture> = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + modify(endpoint, CohereModifyParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt index 1cebec1d..469daad9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.cohere.CohereRetrieveResponse import ai.hanzo.api.models.cohere.CohereUpdateParams import ai.hanzo.api.models.cohere.CohereUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CohereServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CohereServiceAsync { @@ -84,6 +86,9 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CohereCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CohereRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CohereUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CohereDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CohereModifyParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt index cd2b2d7c..76b0d42c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt @@ -52,8 +52,23 @@ interface CredentialServiceAsync { list(CredentialListParams.none(), requestOptions) /** [BETA] endpoint. This might change unexpectedly. */ - fun delete(params: CredentialDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(credentialName: String): CompletableFuture = + delete(credentialName, CredentialDeleteParams.none()) + + /** @see [delete] */ + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) + + /** @see [delete] */ + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + ): CompletableFuture = + delete(credentialName, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -61,6 +76,17 @@ interface CredentialServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: CredentialDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + credentialName: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(credentialName, CredentialDeleteParams.none(), requestOptions) + /** * A view of [CredentialServiceAsync] that provides access to raw HTTP responses for each * method. @@ -119,9 +145,26 @@ interface CredentialServiceAsync { */ @MustBeClosed fun delete( - params: CredentialDeleteParams + credentialName: String ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(credentialName, CredentialDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + ): CompletableFuture> = + delete(credentialName, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -129,5 +172,20 @@ interface CredentialServiceAsync { params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [delete] */ + @MustBeClosed + fun delete( + params: CredentialDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + credentialName: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(credentialName, CredentialDeleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt index 13a3497d..f8a11537 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import ai.hanzo.api.models.credentials.CredentialDeleteResponse import ai.hanzo.api.models.credentials.CredentialListParams import ai.hanzo.api.models.credentials.CredentialListResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CredentialServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CredentialServiceAsync { @@ -127,6 +129,9 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: params: CredentialDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("credentialName", params.credentialName().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt index 6ff1d470..79a968cc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt @@ -37,8 +37,22 @@ interface EngineServiceAsync { * }' * ``` */ - fun complete(params: EngineCompleteParams): CompletableFuture = - complete(params, RequestOptions.none()) + fun complete(model: String): CompletableFuture = + complete(model, EngineCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + ): CompletableFuture = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -46,6 +60,17 @@ interface EngineServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [complete] */ + fun complete(params: EngineCompleteParams): CompletableFuture = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture = + complete(model, EngineCompleteParams.none(), requestOptions) + /** * Follows the exact same API spec as `OpenAI's Embeddings API * https://platform.openai.com/docs/api-reference/embeddings` @@ -60,8 +85,22 @@ interface EngineServiceAsync { * }' * ``` */ - fun embed(params: EngineEmbedParams): CompletableFuture = - embed(params, RequestOptions.none()) + fun embed(model: String): CompletableFuture = + embed(model, EngineEmbedParams.none()) + + /** @see [embed] */ + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + ): CompletableFuture = embed(model, params, RequestOptions.none()) /** @see [embed] */ fun embed( @@ -69,6 +108,17 @@ interface EngineServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [embed] */ + fun embed(params: EngineEmbedParams): CompletableFuture = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + fun embed( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture = + embed(model, EngineEmbedParams.none(), requestOptions) + /** * A view of [EngineServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -81,10 +131,25 @@ interface EngineServiceAsync { * same as [EngineServiceAsync.complete]. */ @MustBeClosed + fun complete(model: String): CompletableFuture> = + complete(model, EngineCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed fun complete( - params: EngineCompleteParams + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - complete(params, RequestOptions.none()) + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + ): CompletableFuture> = + complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -93,15 +158,45 @@ interface EngineServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [complete] */ + @MustBeClosed + fun complete( + params: EngineCompleteParams + ): CompletableFuture> = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + complete(model, EngineCompleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /engines/{model}/embeddings`, but is otherwise the * same as [EngineServiceAsync.embed]. */ @MustBeClosed + fun embed(model: String): CompletableFuture> = + embed(model, EngineEmbedParams.none()) + + /** @see [embed] */ + @MustBeClosed fun embed( - params: EngineEmbedParams + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - embed(params, RequestOptions.none()) + embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + ): CompletableFuture> = + embed(model, params, RequestOptions.none()) /** @see [embed] */ @MustBeClosed @@ -109,5 +204,20 @@ interface EngineServiceAsync { params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [embed] */ + @MustBeClosed + fun embed( + params: EngineEmbedParams + ): CompletableFuture> = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + embed(model, EngineEmbedParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt index 72c9de4d..b010aaf2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import ai.hanzo.api.models.engines.EngineEmbedResponse import ai.hanzo.api.services.async.engines.ChatServiceAsync import ai.hanzo.api.services.async.engines.ChatServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class EngineServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EngineServiceAsync { @@ -69,6 +71,9 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli params: EngineCompleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -100,6 +105,9 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli params: EngineEmbedParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt index 6e7c094d..ff7e56cc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt @@ -25,8 +25,23 @@ interface EuAssemblyaiServiceAsync { fun withRawResponse(): WithRawResponse /** Assemblyai Proxy Route */ - fun create(params: EuAssemblyaiCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, EuAssemblyaiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + ): CompletableFuture = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,10 +49,35 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: EuAssemblyaiCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, EuAssemblyaiCreateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: EuAssemblyaiRetrieveParams - ): CompletableFuture = retrieve(params, RequestOptions.none()) + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + ): CompletableFuture = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -45,9 +85,36 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve( + params: EuAssemblyaiRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun update(params: EuAssemblyaiUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, EuAssemblyaiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + ): CompletableFuture = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -55,9 +122,35 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: EuAssemblyaiUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, EuAssemblyaiUpdateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun delete(params: EuAssemblyaiDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, EuAssemblyaiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + ): CompletableFuture = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -65,9 +158,34 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: EuAssemblyaiDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, EuAssemblyaiDeleteParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun patch(params: EuAssemblyaiPatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, EuAssemblyaiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -75,6 +193,17 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: EuAssemblyaiPatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, EuAssemblyaiPatchParams.none(), requestOptions) + /** * A view of [EuAssemblyaiServiceAsync] that provides access to raw HTTP responses for each * method. @@ -87,9 +216,26 @@ interface EuAssemblyaiServiceAsync { */ @MustBeClosed fun create( - params: EuAssemblyaiCreateParams + endpoint: String ): CompletableFuture> = - create(params, RequestOptions.none()) + create(endpoint, EuAssemblyaiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -98,15 +244,47 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: EuAssemblyaiCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, EuAssemblyaiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.retrieve]. */ @MustBeClosed fun retrieve( - params: EuAssemblyaiRetrieveParams + endpoint: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -115,15 +293,47 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: EuAssemblyaiRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.update]. */ @MustBeClosed fun update( - params: EuAssemblyaiUpdateParams + endpoint: String ): CompletableFuture> = - update(params, RequestOptions.none()) + update(endpoint, EuAssemblyaiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -132,15 +342,47 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: EuAssemblyaiUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, EuAssemblyaiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.delete]. */ @MustBeClosed fun delete( - params: EuAssemblyaiDeleteParams + endpoint: String ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(endpoint, EuAssemblyaiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -149,15 +391,45 @@ interface EuAssemblyaiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: EuAssemblyaiDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, EuAssemblyaiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, EuAssemblyaiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: EuAssemblyaiPatchParams + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -165,5 +437,20 @@ interface EuAssemblyaiServiceAsync { params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: EuAssemblyaiPatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, EuAssemblyaiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt index 015ec023..5ea2bc85 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveResponse import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EuAssemblyaiServiceAsync { @@ -84,6 +86,9 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption params: EuAssemblyaiCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption params: EuAssemblyaiPatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt index faaa852c..ed52c7f2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt @@ -38,6 +38,18 @@ interface FileServiceAsync { * * ``` */ + fun create(provider: String, params: FileCreateParams): CompletableFuture = + create(provider, params, RequestOptions.none()) + + /** @see [create] */ + fun create( + provider: String, + params: FileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [create] */ fun create(params: FileCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -60,6 +72,20 @@ interface FileServiceAsync { * * ``` */ + fun retrieve( + fileId: String, + params: FileRetrieveParams, + ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + fileId: String, + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ fun retrieve(params: FileRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) @@ -82,8 +108,22 @@ interface FileServiceAsync { * * ``` */ - fun list(params: FileListParams): CompletableFuture = - list(params, RequestOptions.none()) + fun list(provider: String): CompletableFuture = + list(provider, FileListParams.none()) + + /** @see [list] */ + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [list] */ + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + ): CompletableFuture = list(provider, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -91,6 +131,16 @@ interface FileServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list(params: FileListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + provider: String, + requestOptions: RequestOptions, + ): CompletableFuture = list(provider, FileListParams.none(), requestOptions) + /** * Deletes a specified file. that can be used across - Assistants API, Batch API This is the * equivalent of DELETE https://api.openai.com/v1/files/{file_id} @@ -104,6 +154,18 @@ interface FileServiceAsync { * * ``` */ + fun delete(fileId: String, params: FileDeleteParams): CompletableFuture = + delete(fileId, params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + fileId: String, + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [delete] */ fun delete(params: FileDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) @@ -123,6 +185,23 @@ interface FileServiceAsync { * [FileServiceAsync.create]. */ @MustBeClosed + fun create( + provider: String, + params: FileCreateParams, + ): CompletableFuture> = + create(provider, params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + provider: String, + params: FileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed fun create( params: FileCreateParams ): CompletableFuture> = @@ -140,6 +219,23 @@ interface FileServiceAsync { * the same as [FileServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve( + fileId: String, + params: FileRetrieveParams, + ): CompletableFuture> = + retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + fileId: String, + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( params: FileRetrieveParams ): CompletableFuture> = @@ -157,8 +253,25 @@ interface FileServiceAsync { * [FileServiceAsync.list]. */ @MustBeClosed - fun list(params: FileListParams): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(provider: String): CompletableFuture> = + list(provider, FileListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + ): CompletableFuture> = + list(provider, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -167,11 +280,41 @@ interface FileServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [list] */ + @MustBeClosed + fun list(params: FileListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + provider: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(provider, FileListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /{provider}/v1/files/{file_id}`, but is otherwise * the same as [FileServiceAsync.delete]. */ @MustBeClosed + fun delete( + fileId: String, + params: FileDeleteParams, + ): CompletableFuture> = + delete(fileId, params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + fileId: String, + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed fun delete( params: FileDeleteParams ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt index cdc1322a..c9a295a4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -27,6 +28,7 @@ import ai.hanzo.api.models.files.FileRetrieveResponse import ai.hanzo.api.services.async.files.ContentServiceAsync import ai.hanzo.api.services.async.files.ContentServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : FileServiceAsync { @@ -87,6 +89,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien params: FileCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -118,6 +123,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien params: FileRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -147,6 +155,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien params: FileListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -176,6 +187,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien params: FileDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt index bdf91a17..c4411175 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt @@ -25,8 +25,22 @@ interface GeminiServiceAsync { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun create(params: GeminiCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, GeminiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,9 +48,34 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: GeminiCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, GeminiCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun retrieve(params: GeminiRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, GeminiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -44,9 +83,34 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: GeminiRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, GeminiRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun update(params: GeminiUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, GeminiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -54,9 +118,34 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: GeminiUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, GeminiUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun delete(params: GeminiDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, GeminiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -64,9 +153,34 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: GeminiDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, GeminiDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun patch(params: GeminiPatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, GeminiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -74,6 +188,17 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: GeminiPatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, GeminiPatchParams.none(), requestOptions) + /** * A view of [GeminiServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -84,10 +209,25 @@ interface GeminiServiceAsync { * [GeminiServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, GeminiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: GeminiCreateParams + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -96,15 +236,45 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: GeminiCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, GeminiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve(endpoint: String): CompletableFuture> = + retrieve(endpoint, GeminiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: GeminiRetrieveParams + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -113,15 +283,45 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: GeminiRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, GeminiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, GeminiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: GeminiUpdateParams + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -130,15 +330,45 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: GeminiUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, GeminiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, GeminiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: GeminiDeleteParams + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -147,15 +377,45 @@ interface GeminiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: GeminiDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, GeminiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, GeminiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: GeminiPatchParams + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -163,5 +423,20 @@ interface GeminiServiceAsync { params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: GeminiPatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, GeminiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt index f4f586ed..b990ac53 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.gemini.GeminiRetrieveResponse import ai.hanzo.api.models.gemini.GeminiUpdateParams import ai.hanzo.api.models.gemini.GeminiUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class GeminiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GeminiServiceAsync { @@ -84,6 +86,9 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli params: GeminiCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli params: GeminiRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli params: GeminiUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli params: GeminiDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli params: GeminiPatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt index a54fbb66..c650c5e1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt @@ -382,10 +382,23 @@ interface KeyServiceAsync { * * Note: This is an Enterprise feature. It requires a premium license to use. */ + fun regenerateByKey(pathKey: String): CompletableFuture> = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) + + /** @see [regenerateByKey] */ fun regenerateByKey( - params: KeyRegenerateByKeyParams + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - regenerateByKey(params, RequestOptions.none()) + regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) + + /** @see [regenerateByKey] */ + fun regenerateByKey( + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + ): CompletableFuture> = + regenerateByKey(pathKey, params, RequestOptions.none()) /** @see [regenerateByKey] */ fun regenerateByKey( @@ -393,6 +406,19 @@ interface KeyServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [regenerateByKey] */ + fun regenerateByKey( + params: KeyRegenerateByKeyParams + ): CompletableFuture> = + regenerateByKey(params, RequestOptions.none()) + + /** @see [regenerateByKey] */ + fun regenerateByKey( + pathKey: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none(), requestOptions) + /** * Retrieve information about a key. Parameters: key: Optional[str] = Query parameter * representing the key in the request user_api_key_dict: UserAPIKeyAuth = Dependency @@ -610,9 +636,26 @@ interface KeyServiceAsync { */ @MustBeClosed fun regenerateByKey( - params: KeyRegenerateByKeyParams + pathKey: String ): CompletableFuture>> = - regenerateByKey(params, RequestOptions.none()) + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) + + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> = + regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) + + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + ): CompletableFuture>> = + regenerateByKey(pathKey, params, RequestOptions.none()) /** @see [regenerateByKey] */ @MustBeClosed @@ -621,6 +664,21 @@ interface KeyServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + params: KeyRegenerateByKeyParams + ): CompletableFuture>> = + regenerateByKey(params, RequestOptions.none()) + + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + pathKey: String, + requestOptions: RequestOptions, + ): CompletableFuture>> = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /key/info`, but is otherwise the same as * [KeyServiceAsync.retrieveInfo]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt index 1b815bb4..55b96b63 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -36,6 +37,7 @@ import ai.hanzo.api.services.async.key.RegenerateServiceAsync import ai.hanzo.api.services.async.key.RegenerateServiceAsyncImpl import java.util.Optional import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class KeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : KeyServiceAsync { @@ -316,6 +318,9 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client params: KeyRegenerateByKeyParams, requestOptions: RequestOptions, ): CompletableFuture>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("pathKey", params.pathKey().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt index 8ed0e021..d029a633 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt @@ -29,8 +29,22 @@ interface LangfuseServiceAsync { * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun create(params: LangfuseCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, LangfuseCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -38,13 +52,39 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: LangfuseCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, LangfuseCreateParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun retrieve(params: LangfuseRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, LangfuseRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + ): CompletableFuture = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -52,13 +92,38 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: LangfuseRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, LangfuseRetrieveParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun update(params: LangfuseUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, LangfuseUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -66,13 +131,38 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: LangfuseUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, LangfuseUpdateParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun delete(params: LangfuseDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, LangfuseDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -80,13 +170,38 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: LangfuseDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, LangfuseDeleteParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun patch(params: LangfusePatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, LangfusePatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -94,6 +209,17 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: LangfusePatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, LangfusePatchParams.none(), requestOptions) + /** * A view of [LangfuseServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -104,10 +230,25 @@ interface LangfuseServiceAsync { * [LangfuseServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, LangfuseCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: LangfuseCreateParams + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -116,15 +257,47 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: LangfuseCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, LangfuseCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseServiceAsync.retrieve]. */ @MustBeClosed fun retrieve( - params: LangfuseRetrieveParams + endpoint: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(endpoint, LangfuseRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -133,15 +306,45 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: LangfuseRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, LangfuseRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, LangfuseUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: LangfuseUpdateParams + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -150,15 +353,45 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: LangfuseUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, LangfuseUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /langfuse/{endpoint}`, but is otherwise the same * as [LangfuseServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, LangfuseDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: LangfuseDeleteParams + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -167,15 +400,45 @@ interface LangfuseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: LangfuseDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, LangfuseDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /langfuse/{endpoint}`, but is otherwise the same * as [LangfuseServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, LangfusePatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: LangfusePatchParams + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -183,5 +446,20 @@ interface LangfuseServiceAsync { params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: LangfusePatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, LangfusePatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt index faeb9a76..845015ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.langfuse.LangfuseRetrieveResponse import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import ai.hanzo.api.models.langfuse.LangfuseUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LangfuseServiceAsync { @@ -84,6 +86,9 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C params: LangfuseCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C params: LangfuseRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C params: LangfuseUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C params: LangfuseDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C params: LangfusePatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt index 5a25c6bb..df653cd2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt @@ -30,8 +30,22 @@ interface OpenAIServiceAsync { /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun create(params: OpenAICreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, OpenAICreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -39,11 +53,36 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: OpenAICreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, OpenAICreateParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun retrieve(params: OpenAIRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, OpenAIRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -51,11 +90,36 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: OpenAIRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, OpenAIRetrieveParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun update(params: OpenAIUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, OpenAIUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -63,11 +127,36 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: OpenAIUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, OpenAIUpdateParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun delete(params: OpenAIDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, OpenAIDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -75,11 +164,36 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: OpenAIDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, OpenAIDeleteParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun patch(params: OpenAIPatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, OpenAIPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -87,6 +201,17 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: OpenAIPatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, OpenAIPatchParams.none(), requestOptions) + /** * A view of [OpenAIServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -99,10 +224,25 @@ interface OpenAIServiceAsync { * [OpenAIServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, OpenAICreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: OpenAICreateParams + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -111,15 +251,45 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: OpenAICreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, OpenAICreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve(endpoint: String): CompletableFuture> = + retrieve(endpoint, OpenAIRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: OpenAIRetrieveParams + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -128,15 +298,45 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: OpenAIRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, OpenAIRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, OpenAIUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: OpenAIUpdateParams + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -145,15 +345,45 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: OpenAIUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, OpenAIUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, OpenAIDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: OpenAIDeleteParams + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -162,15 +392,45 @@ interface OpenAIServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: OpenAIDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, OpenAIDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, OpenAIPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: OpenAIPatchParams + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -178,5 +438,20 @@ interface OpenAIServiceAsync { params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: OpenAIPatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, OpenAIPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt index 6ff2dc58..dd048789 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -28,6 +29,7 @@ import ai.hanzo.api.models.openai.OpenAIUpdateResponse import ai.hanzo.api.services.async.openai.DeploymentServiceAsync import ai.hanzo.api.services.async.openai.DeploymentServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : OpenAIServiceAsync { @@ -98,6 +100,9 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli params: OpenAICreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -129,6 +134,9 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli params: OpenAIRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -159,6 +167,9 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli params: OpenAIUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -190,6 +201,9 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli params: OpenAIDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -221,6 +235,9 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli params: OpenAIPatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt index 362349bf..9b35a729 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt @@ -61,8 +61,23 @@ interface ResponseServiceAsync { * curl -X GET http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer sk-1234" * ``` */ - fun retrieve(params: ResponseRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(responseId: String): CompletableFuture = + retrieve(responseId, ResponseRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + ): CompletableFuture = + retrieve(responseId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -70,6 +85,17 @@ interface ResponseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: ResponseRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + responseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(responseId, ResponseRetrieveParams.none(), requestOptions) + /** * Delete a response by ID. * @@ -80,8 +106,22 @@ interface ResponseServiceAsync { * curl -X DELETE http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer sk-1234" * ``` */ - fun delete(params: ResponseDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(responseId: String): CompletableFuture = + delete(responseId, ResponseDeleteParams.none()) + + /** @see [delete] */ + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [delete] */ + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + ): CompletableFuture = delete(responseId, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -89,6 +129,17 @@ interface ResponseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: ResponseDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + responseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(responseId, ResponseDeleteParams.none(), requestOptions) + /** * A view of [ResponseServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -131,9 +182,26 @@ interface ResponseServiceAsync { */ @MustBeClosed fun retrieve( - params: ResponseRetrieveParams + responseId: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(responseId, ResponseRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + ): CompletableFuture> = + retrieve(responseId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -142,15 +210,45 @@ interface ResponseServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ResponseRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + responseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(responseId, ResponseRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /v1/responses/{response_id}`, but is otherwise * the same as [ResponseServiceAsync.delete]. */ @MustBeClosed + fun delete(responseId: String): CompletableFuture> = + delete(responseId, ResponseDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: ResponseDeleteParams + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + ): CompletableFuture> = + delete(responseId, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -158,5 +256,20 @@ interface ResponseServiceAsync { params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [delete] */ + @MustBeClosed + fun delete( + params: ResponseDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + responseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(responseId, ResponseDeleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt index b9d77588..06a1a6e1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import ai.hanzo.api.models.responses.ResponseRetrieveResponse import ai.hanzo.api.services.async.responses.InputItemServiceAsync import ai.hanzo.api.services.async.responses.InputItemServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ResponseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ResponseServiceAsync { @@ -111,6 +113,9 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C params: ResponseRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("responseId", params.responseId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -141,6 +146,9 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C params: ResponseDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("responseId", params.responseId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt index e7d818f1..e06cc096 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt @@ -285,9 +285,23 @@ interface TeamServiceAsync { * curl -X POST 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/disable_logging' -H 'Authorization: Bearer sk-1234' * ``` */ + fun disableLogging(teamId: String): CompletableFuture = + disableLogging(teamId, TeamDisableLoggingParams.none()) + + /** @see [disableLogging] */ fun disableLogging( - params: TeamDisableLoggingParams - ): CompletableFuture = disableLogging(params, RequestOptions.none()) + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [disableLogging] */ + fun disableLogging( + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + ): CompletableFuture = + disableLogging(teamId, params, RequestOptions.none()) /** @see [disableLogging] */ fun disableLogging( @@ -295,6 +309,18 @@ interface TeamServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [disableLogging] */ + fun disableLogging( + params: TeamDisableLoggingParams + ): CompletableFuture = disableLogging(params, RequestOptions.none()) + + /** @see [disableLogging] */ + fun disableLogging( + teamId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + disableLogging(teamId, TeamDisableLoggingParams.none(), requestOptions) + /** List Available Teams */ fun listAvailable(): CompletableFuture = listAvailable(TeamListAvailableParams.none()) @@ -543,9 +569,26 @@ interface TeamServiceAsync { */ @MustBeClosed fun disableLogging( - params: TeamDisableLoggingParams + teamId: String ): CompletableFuture> = - disableLogging(params, RequestOptions.none()) + disableLogging(teamId, TeamDisableLoggingParams.none()) + + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + ): CompletableFuture> = + disableLogging(teamId, params, RequestOptions.none()) /** @see [disableLogging] */ @MustBeClosed @@ -554,6 +597,21 @@ interface TeamServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + params: TeamDisableLoggingParams + ): CompletableFuture> = + disableLogging(params, RequestOptions.none()) + + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + teamId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + disableLogging(teamId, TeamDisableLoggingParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /team/available`, but is otherwise the same as * [TeamServiceAsync.listAvailable]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt index 40db1619..948b848b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -44,6 +45,7 @@ import ai.hanzo.api.services.async.team.CallbackServiceAsyncImpl import ai.hanzo.api.services.async.team.ModelServiceAsync import ai.hanzo.api.services.async.team.ModelServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class TeamServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TeamServiceAsync { @@ -351,6 +353,9 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien params: TeamDisableLoggingParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("teamId", params.teamId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt index cf04a7f8..17c2862d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt @@ -51,8 +51,22 @@ interface ThreadServiceAsync { * * API Reference - https://platform.openai.com/docs/api-reference/threads/getThread */ - fun retrieve(params: ThreadRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(threadId: String): CompletableFuture = + retrieve(threadId, ThreadRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + ): CompletableFuture = retrieve(threadId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -60,6 +74,17 @@ interface ThreadServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: ThreadRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) + /** * A view of [ThreadServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -103,10 +128,25 @@ interface ThreadServiceAsync { * as [ThreadServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve(threadId: String): CompletableFuture> = + retrieve(threadId, ThreadRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: ThreadRetrieveParams + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + ): CompletableFuture> = + retrieve(threadId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -114,5 +154,20 @@ interface ThreadServiceAsync { params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ThreadRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt index bdf48697..36af219e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import ai.hanzo.api.services.async.threads.MessageServiceAsyncImpl import ai.hanzo.api.services.async.threads.RunServiceAsync import ai.hanzo.api.services.async.threads.RunServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ThreadServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ThreadServiceAsync { @@ -112,6 +114,9 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli params: ThreadRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt index 239fe8c9..d502f18d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt @@ -29,8 +29,22 @@ interface VertexAiServiceAsync { * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun create(params: VertexAiCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(endpoint: String): CompletableFuture = + create(endpoint, VertexAiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + ): CompletableFuture = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -38,13 +52,39 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: VertexAiCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(endpoint, VertexAiCreateParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun retrieve(params: VertexAiRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CompletableFuture = + retrieve(endpoint, VertexAiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + ): CompletableFuture = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -52,13 +92,38 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: VertexAiRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(endpoint, VertexAiRetrieveParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun update(params: VertexAiUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(endpoint: String): CompletableFuture = + update(endpoint, VertexAiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + ): CompletableFuture = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -66,13 +131,38 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: VertexAiUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpoint, VertexAiUpdateParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun delete(params: VertexAiDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CompletableFuture = + delete(endpoint, VertexAiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -80,13 +170,38 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: VertexAiDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(endpoint, VertexAiDeleteParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun patch(params: VertexAiPatchParams): CompletableFuture = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): CompletableFuture = + patch(endpoint, VertexAiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -94,6 +209,17 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [patch] */ + fun patch(params: VertexAiPatchParams): CompletableFuture = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture = + patch(endpoint, VertexAiPatchParams.none(), requestOptions) + /** * A view of [VertexAiServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -104,10 +230,25 @@ interface VertexAiServiceAsync { * as [VertexAiServiceAsync.create]. */ @MustBeClosed + fun create(endpoint: String): CompletableFuture> = + create(endpoint, VertexAiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: VertexAiCreateParams + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + ): CompletableFuture> = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -116,15 +257,47 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: VertexAiCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(endpoint, VertexAiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /vertex_ai/{endpoint}`, but is otherwise the same as * [VertexAiServiceAsync.retrieve]. */ @MustBeClosed fun retrieve( - params: VertexAiRetrieveParams + endpoint: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(endpoint, VertexAiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + ): CompletableFuture> = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -133,15 +306,45 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: VertexAiRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(endpoint, VertexAiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /vertex_ai/{endpoint}`, but is otherwise the same as * [VertexAiServiceAsync.update]. */ @MustBeClosed + fun update(endpoint: String): CompletableFuture> = + update(endpoint, VertexAiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: VertexAiUpdateParams + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - update(params, RequestOptions.none()) + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + ): CompletableFuture> = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -150,15 +353,45 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: VertexAiUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpoint, VertexAiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiServiceAsync.delete]. */ @MustBeClosed + fun delete(endpoint: String): CompletableFuture> = + delete(endpoint, VertexAiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed fun delete( - params: VertexAiDeleteParams + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - delete(params, RequestOptions.none()) + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + ): CompletableFuture> = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -167,15 +400,45 @@ interface VertexAiServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [delete] */ + @MustBeClosed + fun delete( + params: VertexAiDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(endpoint, VertexAiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiServiceAsync.patch]. */ @MustBeClosed + fun patch(endpoint: String): CompletableFuture> = + patch(endpoint, VertexAiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed fun patch( - params: VertexAiPatchParams + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - patch(params, RequestOptions.none()) + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + ): CompletableFuture> = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -183,5 +446,20 @@ interface VertexAiServiceAsync { params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [patch] */ + @MustBeClosed + fun patch( + params: VertexAiPatchParams + ): CompletableFuture> = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + patch(endpoint, VertexAiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt index 5059794a..778698e9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.vertexai.VertexAiRetrieveResponse import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import ai.hanzo.api.models.vertexai.VertexAiUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : VertexAiServiceAsync { @@ -84,6 +86,9 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C params: VertexAiCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,6 +120,9 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C params: VertexAiRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +153,9 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C params: VertexAiUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +187,9 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C params: VertexAiDeleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -207,6 +221,9 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C params: VertexAiPatchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt index d7fa66fc..ea4b6c22 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt @@ -29,8 +29,22 @@ interface CancelServiceAsync { * * ``` */ - fun cancel(params: CancelCancelParams): CompletableFuture = - cancel(params, RequestOptions.none()) + fun cancel(batchId: String): CompletableFuture = + cancel(batchId, CancelCancelParams.none()) + + /** @see [cancel] */ + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancel] */ + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + ): CompletableFuture = cancel(batchId, params, RequestOptions.none()) /** @see [cancel] */ fun cancel( @@ -38,6 +52,17 @@ interface CancelServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [cancel] */ + fun cancel(params: CancelCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(batchId, CancelCancelParams.none(), requestOptions) + /** * A view of [CancelServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -48,10 +73,25 @@ interface CancelServiceAsync { * same as [CancelServiceAsync.cancel]. */ @MustBeClosed + fun cancel(batchId: String): CompletableFuture> = + cancel(batchId, CancelCancelParams.none()) + + /** @see [cancel] */ + @MustBeClosed fun cancel( - params: CancelCancelParams + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - cancel(params, RequestOptions.none()) + cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + ): CompletableFuture> = + cancel(batchId, params, RequestOptions.none()) /** @see [cancel] */ @MustBeClosed @@ -59,5 +99,20 @@ interface CancelServiceAsync { params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + params: CancelCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(batchId, CancelCancelParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt index 79186526..7fb07ffd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.batches import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.batches.cancel.CancelCancelParams import ai.hanzo.api.models.batches.cancel.CancelCancelResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CancelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CancelServiceAsync { @@ -48,6 +50,9 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CancelCancelParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt index 77cbd7e3..63033088 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt @@ -33,9 +33,23 @@ interface PassThroughEndpointServiceAsync { ): CompletableFuture /** Update a pass-through endpoint */ + fun update(endpointId: String): CompletableFuture = + update(endpointId, PassThroughEndpointUpdateParams.none()) + + /** @see [update] */ fun update( - params: PassThroughEndpointUpdateParams - ): CompletableFuture = update(params, RequestOptions.none()) + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().endpointId(endpointId).build(), requestOptions) + + /** @see [update] */ + fun update( + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + ): CompletableFuture = + update(endpointId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -43,6 +57,18 @@ interface PassThroughEndpointServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update( + params: PassThroughEndpointUpdateParams + ): CompletableFuture = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpointId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(endpointId, PassThroughEndpointUpdateParams.none(), requestOptions) + /** * GET configured pass through endpoint. * @@ -110,9 +136,26 @@ interface PassThroughEndpointServiceAsync { */ @MustBeClosed fun update( - params: PassThroughEndpointUpdateParams + endpointId: String ): CompletableFuture> = - update(params, RequestOptions.none()) + update(endpointId, PassThroughEndpointUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().endpointId(endpointId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + ): CompletableFuture> = + update(endpointId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -121,6 +164,21 @@ interface PassThroughEndpointServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: PassThroughEndpointUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpointId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(endpointId, PassThroughEndpointUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /config/pass_through_endpoint`, but is otherwise the * same as [PassThroughEndpointServiceAsync.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt index 1a679b6f..2b45f059 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.config import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointRespons import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class PassThroughEndpointServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PassThroughEndpointServiceAsync { @@ -106,6 +108,9 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpointId", params.endpointId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt index a9221fda..413fe9de 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt @@ -35,8 +35,22 @@ interface ChatServiceAsync { * }' * ``` */ - fun complete(params: ChatCompleteParams): CompletableFuture = - complete(params, RequestOptions.none()) + fun complete(model: String): CompletableFuture = + complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): CompletableFuture = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -44,6 +58,17 @@ interface ChatServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [complete] */ + fun complete(params: ChatCompleteParams): CompletableFuture = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture = + complete(model, ChatCompleteParams.none(), requestOptions) + /** A view of [ChatServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -52,10 +77,25 @@ interface ChatServiceAsync { * otherwise the same as [ChatServiceAsync.complete]. */ @MustBeClosed + fun complete(model: String): CompletableFuture> = + complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed fun complete( - params: ChatCompleteParams + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - complete(params, RequestOptions.none()) + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): CompletableFuture> = + complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -63,5 +103,20 @@ interface ChatServiceAsync { params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [complete] */ + @MustBeClosed + fun complete( + params: ChatCompleteParams + ): CompletableFuture> = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + complete(model, ChatCompleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt index 344435f8..f99d1476 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.engines import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.engines.chat.ChatCompleteParams import ai.hanzo.api.models.engines.chat.ChatCompleteResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ChatServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ChatServiceAsync { @@ -48,6 +50,9 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien params: ChatCompleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt index 587613df..2001df85 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt @@ -30,6 +30,20 @@ interface ContentServiceAsync { * * ``` */ + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ fun retrieve(params: ContentRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) @@ -49,6 +63,23 @@ interface ContentServiceAsync { * otherwise the same as [ContentServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + ): CompletableFuture> = + retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( params: ContentRetrieveParams ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt index 5cae68fd..a46c7769 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.files import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.files.content.ContentRetrieveParams import ai.hanzo.api.models.files.content.ContentRetrieveResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ContentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ContentServiceAsync { @@ -47,6 +49,9 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl params: ContentRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt index 71959674..7b6c775b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt @@ -58,6 +58,21 @@ interface JobServiceAsync { * - `custom_llm_provider`: Name of the LLM provider * - `fine_tuning_job_id`: The ID of the fine-tuning job to retrieve. */ + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + ): CompletableFuture = + retrieve(fineTuningJobId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [retrieve] */ fun retrieve(params: JobRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) @@ -110,6 +125,23 @@ interface JobServiceAsync { * otherwise the same as [JobServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + ): CompletableFuture> = + retrieve(fineTuningJobId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( params: JobRetrieveParams ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt index 3a079607..a04562c5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.finetuning import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import ai.hanzo.api.models.finetuning.jobs.JobRetrieveResponse import ai.hanzo.api.services.async.finetuning.jobs.CancelServiceAsync import ai.hanzo.api.services.async.finetuning.jobs.CancelServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : JobServiceAsync { @@ -108,6 +110,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client params: JobRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fineTuningJobId", params.fineTuningJobId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt index 170eb82b..1b76ab28 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt @@ -26,8 +26,23 @@ interface CancelServiceAsync { * - `custom_llm_provider`: Name of the LLM provider * - `fine_tuning_job_id`: The ID of the fine-tuning job to cancel. */ - fun create(params: CancelCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(fineTuningJobId: String): CompletableFuture = + create(fineTuningJobId, CancelCreateParams.none()) + + /** @see [create] */ + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [create] */ + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + ): CompletableFuture = + create(fineTuningJobId, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -35,6 +50,17 @@ interface CancelServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: CancelCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + fineTuningJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(fineTuningJobId, CancelCreateParams.none(), requestOptions) + /** * A view of [CancelServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -46,9 +72,26 @@ interface CancelServiceAsync { */ @MustBeClosed fun create( - params: CancelCreateParams + fineTuningJobId: String ): CompletableFuture> = - create(params, RequestOptions.none()) + create(fineTuningJobId, CancelCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + ): CompletableFuture> = + create(fineTuningJobId, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -56,5 +99,20 @@ interface CancelServiceAsync { params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [create] */ + @MustBeClosed + fun create( + params: CancelCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + fineTuningJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(fineTuningJobId, CancelCreateParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt index 1bce1c18..6bfb1375 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.finetuning.jobs import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CancelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CancelServiceAsync { @@ -48,6 +50,9 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CancelCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fineTuningJobId", params.fineTuningJobId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt index ad093e64..9f9c339e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt @@ -42,6 +42,20 @@ interface UpdateServiceAsync { * Raises: ProxyException: For various error conditions including authentication and database * errors */ + fun partial( + modelId: String, + params: UpdatePartialParams, + ): CompletableFuture = partial(modelId, params, RequestOptions.none()) + + /** @see [partial] */ + fun partial( + modelId: String, + params: UpdatePartialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + partial(params.toBuilder().modelId(modelId).build(), requestOptions) + + /** @see [partial] */ fun partial(params: UpdatePartialParams): CompletableFuture = partial(params, RequestOptions.none()) @@ -76,6 +90,23 @@ interface UpdateServiceAsync { * same as [UpdateServiceAsync.partial]. */ @MustBeClosed + fun partial( + modelId: String, + params: UpdatePartialParams, + ): CompletableFuture> = + partial(modelId, params, RequestOptions.none()) + + /** @see [partial] */ + @MustBeClosed + fun partial( + modelId: String, + params: UpdatePartialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + partial(params.toBuilder().modelId(modelId).build(), requestOptions) + + /** @see [partial] */ + @MustBeClosed fun partial( params: UpdatePartialParams ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt index 2b107be5..180b515f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.model import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -20,6 +21,7 @@ import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams import ai.hanzo.api.models.model.update.UpdatePartialResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class UpdateServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : UpdateServiceAsync { @@ -87,6 +89,9 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli params: UpdatePartialParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("modelId", params.modelId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt index 50c9af3c..7a3cde97 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt @@ -37,8 +37,23 @@ interface DeploymentServiceAsync { * }' * ``` */ - fun complete(params: DeploymentCompleteParams): CompletableFuture = - complete(params, RequestOptions.none()) + fun complete(model: String): CompletableFuture = + complete(model, DeploymentCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + ): CompletableFuture = + complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -46,6 +61,17 @@ interface DeploymentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [complete] */ + fun complete(params: DeploymentCompleteParams): CompletableFuture = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture = + complete(model, DeploymentCompleteParams.none(), requestOptions) + /** * Follows the exact same API spec as `OpenAI's Embeddings API * https://platform.openai.com/docs/api-reference/embeddings` @@ -60,8 +86,22 @@ interface DeploymentServiceAsync { * }' * ``` */ - fun embed(params: DeploymentEmbedParams): CompletableFuture = - embed(params, RequestOptions.none()) + fun embed(model: String): CompletableFuture = + embed(model, DeploymentEmbedParams.none()) + + /** @see [embed] */ + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + ): CompletableFuture = embed(model, params, RequestOptions.none()) /** @see [embed] */ fun embed( @@ -69,6 +109,17 @@ interface DeploymentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [embed] */ + fun embed(params: DeploymentEmbedParams): CompletableFuture = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + fun embed( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture = + embed(model, DeploymentEmbedParams.none(), requestOptions) + /** * A view of [DeploymentServiceAsync] that provides access to raw HTTP responses for each * method. @@ -83,9 +134,26 @@ interface DeploymentServiceAsync { */ @MustBeClosed fun complete( - params: DeploymentCompleteParams + model: String ): CompletableFuture> = - complete(params, RequestOptions.none()) + complete(model, DeploymentCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + ): CompletableFuture> = + complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -94,15 +162,45 @@ interface DeploymentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [complete] */ + @MustBeClosed + fun complete( + params: DeploymentCompleteParams + ): CompletableFuture> = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + complete(model, DeploymentCompleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /openai/deployments/{model}/embeddings`, but is * otherwise the same as [DeploymentServiceAsync.embed]. */ @MustBeClosed + fun embed(model: String): CompletableFuture> = + embed(model, DeploymentEmbedParams.none()) + + /** @see [embed] */ + @MustBeClosed fun embed( - params: DeploymentEmbedParams + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - embed(params, RequestOptions.none()) + embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + ): CompletableFuture> = + embed(model, params, RequestOptions.none()) /** @see [embed] */ @MustBeClosed @@ -110,5 +208,20 @@ interface DeploymentServiceAsync { params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [embed] */ + @MustBeClosed + fun embed( + params: DeploymentEmbedParams + ): CompletableFuture> = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + embed(model, DeploymentEmbedParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt index fba6bd65..54852216 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.openai import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import ai.hanzo.api.models.openai.deployments.DeploymentEmbedResponse import ai.hanzo.api.services.async.openai.deployments.ChatServiceAsync import ai.hanzo.api.services.async.openai.deployments.ChatServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DeploymentServiceAsync { @@ -69,6 +71,9 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: params: DeploymentCompleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -100,6 +105,9 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: params: DeploymentEmbedParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt index cab8bde5..e334659d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt @@ -35,8 +35,22 @@ interface ChatServiceAsync { * }' * ``` */ - fun complete(params: ChatCompleteParams): CompletableFuture = - complete(params, RequestOptions.none()) + fun complete(model: String): CompletableFuture = + complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): CompletableFuture = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -44,6 +58,17 @@ interface ChatServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [complete] */ + fun complete(params: ChatCompleteParams): CompletableFuture = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture = + complete(model, ChatCompleteParams.none(), requestOptions) + /** A view of [ChatServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -52,10 +77,25 @@ interface ChatServiceAsync { * is otherwise the same as [ChatServiceAsync.complete]. */ @MustBeClosed + fun complete(model: String): CompletableFuture> = + complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed fun complete( - params: ChatCompleteParams + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - complete(params, RequestOptions.none()) + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): CompletableFuture> = + complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -63,5 +103,20 @@ interface ChatServiceAsync { params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [complete] */ + @MustBeClosed + fun complete( + params: ChatCompleteParams + ): CompletableFuture> = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + complete(model, ChatCompleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt index 4f2ea32d..bc82fa2a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.openai.deployments import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ChatServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ChatServiceAsync { @@ -48,6 +50,9 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien params: ChatCompleteParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt index bdff81b0..43948be3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt @@ -26,8 +26,22 @@ interface InputItemServiceAsync { * curl -X GET http://localhost:4000/v1/responses/resp_abc123/input_items -H "Authorization: Bearer sk-1234" * ``` */ - fun list(params: InputItemListParams): CompletableFuture = - list(params, RequestOptions.none()) + fun list(responseId: String): CompletableFuture = + list(responseId, InputItemListParams.none()) + + /** @see [list] */ + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [list] */ + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + ): CompletableFuture = list(responseId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -35,6 +49,17 @@ interface InputItemServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list(params: InputItemListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + responseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(responseId, InputItemListParams.none(), requestOptions) + /** * A view of [InputItemServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -45,10 +70,25 @@ interface InputItemServiceAsync { * otherwise the same as [InputItemServiceAsync.list]. */ @MustBeClosed + fun list(responseId: String): CompletableFuture> = + list(responseId, InputItemListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: InputItemListParams + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - list(params, RequestOptions.none()) + list(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + ): CompletableFuture> = + list(responseId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -56,5 +96,20 @@ interface InputItemServiceAsync { params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: InputItemListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + responseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(responseId, InputItemListParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt index 8c9cdb9a..d91aaa33 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.responses import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.responses.inputitems.InputItemListParams import ai.hanzo.api.models.responses.inputitems.InputItemListResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class InputItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InputItemServiceAsync { @@ -47,6 +49,9 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: params: InputItemListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("responseId", params.responseId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt index b5e01f4e..9ba80170 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt @@ -37,8 +37,22 @@ interface CallbackServiceAsync { * team_callback_settings_obj.failure_callback, "callback_vars": * team_callback_settings_obj.callback_vars, }, } */ - fun retrieve(params: CallbackRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(teamId: String): CompletableFuture = + retrieve(teamId, CallbackRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + ): CompletableFuture = retrieve(teamId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -46,6 +60,17 @@ interface CallbackServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: CallbackRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + teamId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(teamId, CallbackRetrieveParams.none(), requestOptions) + /** * Add a success/failure callback to a team * @@ -84,6 +109,18 @@ interface CallbackServiceAsync { * This means for the team where team_id = dbe2f686-a686-4896-864a-4c3924458709, all LLM calls * will be logged to langfuse using the public key pk-lf-xxxx1 and the secret key sk-xxxxx */ + fun add(teamId: String, params: CallbackAddParams): CompletableFuture = + add(teamId, params, RequestOptions.none()) + + /** @see [add] */ + fun add( + teamId: String, + params: CallbackAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + add(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [add] */ fun add(params: CallbackAddParams): CompletableFuture = add(params, RequestOptions.none()) @@ -103,10 +140,25 @@ interface CallbackServiceAsync { * as [CallbackServiceAsync.retrieve]. */ @MustBeClosed + fun retrieve(teamId: String): CompletableFuture> = + retrieve(teamId, CallbackRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: CallbackRetrieveParams + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + ): CompletableFuture> = + retrieve(teamId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -115,11 +167,43 @@ interface CallbackServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CallbackRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + teamId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(teamId, CallbackRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /team/{team_id}/callback`, but is otherwise the * same as [CallbackServiceAsync.add]. */ @MustBeClosed + fun add( + teamId: String, + params: CallbackAddParams, + ): CompletableFuture> = + add(teamId, params, RequestOptions.none()) + + /** @see [add] */ + @MustBeClosed + fun add( + teamId: String, + params: CallbackAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + add(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [add] */ + @MustBeClosed fun add( params: CallbackAddParams ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt index 3a806bd0..645d5736 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.team import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -20,6 +21,7 @@ import ai.hanzo.api.models.team.callback.CallbackAddResponse import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import ai.hanzo.api.models.team.callback.CallbackRetrieveResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CallbackServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CallbackServiceAsync { @@ -57,6 +59,9 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C params: CallbackRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("teamId", params.teamId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -87,6 +92,9 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C params: CallbackAddParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("teamId", params.teamId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt index be6af746..f9c8a866 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt @@ -23,8 +23,22 @@ interface MessageServiceAsync { * * API Reference - https://platform.openai.com/docs/api-reference/messages/createMessage */ - fun create(params: MessageCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(threadId: String): CompletableFuture = + create(threadId, MessageCreateParams.none()) + + /** @see [create] */ + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + ): CompletableFuture = create(threadId, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -32,13 +46,38 @@ interface MessageServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: MessageCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(threadId, MessageCreateParams.none(), requestOptions) + /** * Returns a list of messages for a given thread. * * API Reference - https://platform.openai.com/docs/api-reference/messages/listMessages */ - fun list(params: MessageListParams): CompletableFuture = - list(params, RequestOptions.none()) + fun list(threadId: String): CompletableFuture = + list(threadId, MessageListParams.none()) + + /** @see [list] */ + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [list] */ + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + ): CompletableFuture = list(threadId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -46,6 +85,17 @@ interface MessageServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list(params: MessageListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(threadId, MessageListParams.none(), requestOptions) + /** * A view of [MessageServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -56,10 +106,25 @@ interface MessageServiceAsync { * the same as [MessageServiceAsync.create]. */ @MustBeClosed + fun create(threadId: String): CompletableFuture> = + create(threadId, MessageCreateParams.none()) + + /** @see [create] */ + @MustBeClosed fun create( - params: MessageCreateParams + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - create(params, RequestOptions.none()) + create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + ): CompletableFuture> = + create(threadId, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -68,15 +133,45 @@ interface MessageServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [create] */ + @MustBeClosed + fun create( + params: MessageCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(threadId, MessageCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /v1/threads/{thread_id}/messages`, but is otherwise * the same as [MessageServiceAsync.list]. */ @MustBeClosed + fun list(threadId: String): CompletableFuture> = + list(threadId, MessageListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: MessageListParams + threadId: String, + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - list(params, RequestOptions.none()) + list(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + ): CompletableFuture> = + list(threadId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -84,5 +179,20 @@ interface MessageServiceAsync { params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: MessageListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(threadId, MessageListParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt index 45ca695a..50b8a56c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.threads import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -20,6 +21,7 @@ import ai.hanzo.api.models.threads.messages.MessageCreateResponse import ai.hanzo.api.models.threads.messages.MessageListParams import ai.hanzo.api.models.threads.messages.MessageListResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class MessageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MessageServiceAsync { @@ -57,6 +59,9 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl params: MessageCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -88,6 +93,9 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl params: MessageListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt index 3c6a76b3..aaf3ea84 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt @@ -21,8 +21,22 @@ interface RunServiceAsync { * * API Reference: https://platform.openai.com/docs/api-reference/runs/createRun */ - fun create(params: RunCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + fun create(threadId: String): CompletableFuture = + create(threadId, RunCreateParams.none()) + + /** @see [create] */ + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + ): CompletableFuture = create(threadId, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -30,6 +44,17 @@ interface RunServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [create] */ + fun create(params: RunCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(threadId, RunCreateParams.none(), requestOptions) + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -38,8 +63,25 @@ interface RunServiceAsync { * same as [RunServiceAsync.create]. */ @MustBeClosed - fun create(params: RunCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + fun create(threadId: String): CompletableFuture> = + create(threadId, RunCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + ): CompletableFuture> = + create(threadId, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -47,5 +89,18 @@ interface RunServiceAsync { params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [create] */ + @MustBeClosed + fun create(params: RunCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(threadId, RunCreateParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt index a61353b3..0d1b6e4e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.threads import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.threads.runs.RunCreateParams import ai.hanzo.api.models.threads.runs.RunCreateResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RunServiceAsync { @@ -47,6 +49,9 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client params: RunCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt index a8c8f7b5..e728987b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt @@ -24,8 +24,22 @@ interface AnthropicService { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun create(params: AnthropicCreateParams): AnthropicCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): AnthropicCreateResponse = + create(endpoint, AnthropicCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnthropicCreateResponse = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + ): AnthropicCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -33,9 +47,31 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicCreateResponse + /** @see [create] */ + fun create(params: AnthropicCreateParams): AnthropicCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): AnthropicCreateResponse = + create(endpoint, AnthropicCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun retrieve(params: AnthropicRetrieveParams): AnthropicRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): AnthropicRetrieveResponse = + retrieve(endpoint, AnthropicRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnthropicRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + ): AnthropicRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -43,9 +79,31 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: AnthropicRetrieveParams): AnthropicRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): AnthropicRetrieveResponse = + retrieve(endpoint, AnthropicRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun update(params: AnthropicUpdateParams): AnthropicUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): AnthropicUpdateResponse = + update(endpoint, AnthropicUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnthropicUpdateResponse = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + ): AnthropicUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -53,9 +111,31 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicUpdateResponse + /** @see [update] */ + fun update(params: AnthropicUpdateParams): AnthropicUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): AnthropicUpdateResponse = + update(endpoint, AnthropicUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun delete(params: AnthropicDeleteParams): AnthropicDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): AnthropicDeleteResponse = + delete(endpoint, AnthropicDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnthropicDeleteResponse = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + ): AnthropicDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -63,9 +143,31 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicDeleteResponse + /** @see [delete] */ + fun delete(params: AnthropicDeleteParams): AnthropicDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): AnthropicDeleteResponse = + delete(endpoint, AnthropicDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ - fun modify(params: AnthropicModifyParams): AnthropicModifyResponse = - modify(params, RequestOptions.none()) + fun modify(endpoint: String): AnthropicModifyResponse = + modify(endpoint, AnthropicModifyParams.none()) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnthropicModifyResponse = + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + ): AnthropicModifyResponse = modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ fun modify( @@ -73,6 +175,14 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicModifyResponse + /** @see [modify] */ + fun modify(params: AnthropicModifyParams): AnthropicModifyResponse = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + fun modify(endpoint: String, requestOptions: RequestOptions): AnthropicModifyResponse = + modify(endpoint, AnthropicModifyParams.none(), requestOptions) + /** A view of [AnthropicService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -81,8 +191,25 @@ interface AnthropicService { * as [AnthropicService.create]. */ @MustBeClosed - fun create(params: AnthropicCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, AnthropicCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AnthropicCreateParams = AnthropicCreateParams.none(), + ): HttpResponseFor = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -91,13 +218,43 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: AnthropicCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, AnthropicCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /anthropic/{endpoint}`, but is otherwise the same as * [AnthropicService.retrieve]. */ @MustBeClosed - fun retrieve(params: AnthropicRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, AnthropicRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -106,13 +263,43 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: AnthropicRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, AnthropicRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /anthropic/{endpoint}`, but is otherwise the same as * [AnthropicService.update]. */ @MustBeClosed - fun update(params: AnthropicUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, AnthropicUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AnthropicUpdateParams = AnthropicUpdateParams.none(), + ): HttpResponseFor = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -121,13 +308,43 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: AnthropicUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, AnthropicUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicService.delete]. */ @MustBeClosed - fun delete(params: AnthropicDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, AnthropicDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AnthropicDeleteParams = AnthropicDeleteParams.none(), + ): HttpResponseFor = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -136,13 +353,43 @@ interface AnthropicService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: AnthropicDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, AnthropicDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicService.modify]. */ @MustBeClosed - fun modify(params: AnthropicModifyParams): HttpResponseFor = - modify(params, RequestOptions.none()) + fun modify(endpoint: String): HttpResponseFor = + modify(endpoint, AnthropicModifyParams.none()) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + params: AnthropicModifyParams = AnthropicModifyParams.none(), + ): HttpResponseFor = + modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ @MustBeClosed @@ -150,5 +397,18 @@ interface AnthropicService { params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [modify] */ + @MustBeClosed + fun modify(params: AnthropicModifyParams): HttpResponseFor = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + modify(endpoint, AnthropicModifyParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt index c9b56fb3..8200382f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.anthropic.AnthropicRetrieveParams import ai.hanzo.api.models.anthropic.AnthropicRetrieveResponse import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import ai.hanzo.api.models.anthropic.AnthropicUpdateResponse +import kotlin.jvm.optionals.getOrNull class AnthropicServiceImpl internal constructor(private val clientOptions: ClientOptions) : AnthropicService { @@ -83,6 +85,9 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien params: AnthropicCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien params: AnthropicRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien params: AnthropicUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien params: AnthropicDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien params: AnthropicModifyParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt index a64c96af..b7393961 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt @@ -24,8 +24,22 @@ interface AssemblyaiService { fun withRawResponse(): WithRawResponse /** Assemblyai Proxy Route */ - fun create(params: AssemblyaiCreateParams): AssemblyaiCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): AssemblyaiCreateResponse = + create(endpoint, AssemblyaiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AssemblyaiCreateResponse = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + ): AssemblyaiCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -33,9 +47,31 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiCreateResponse + /** @see [create] */ + fun create(params: AssemblyaiCreateParams): AssemblyaiCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): AssemblyaiCreateResponse = + create(endpoint, AssemblyaiCreateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun retrieve(params: AssemblyaiRetrieveParams): AssemblyaiRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): AssemblyaiRetrieveResponse = + retrieve(endpoint, AssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AssemblyaiRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + ): AssemblyaiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -43,9 +79,31 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: AssemblyaiRetrieveParams): AssemblyaiRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): AssemblyaiRetrieveResponse = + retrieve(endpoint, AssemblyaiRetrieveParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun update(params: AssemblyaiUpdateParams): AssemblyaiUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): AssemblyaiUpdateResponse = + update(endpoint, AssemblyaiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AssemblyaiUpdateResponse = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + ): AssemblyaiUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -53,9 +111,31 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiUpdateResponse + /** @see [update] */ + fun update(params: AssemblyaiUpdateParams): AssemblyaiUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): AssemblyaiUpdateResponse = + update(endpoint, AssemblyaiUpdateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun delete(params: AssemblyaiDeleteParams): AssemblyaiDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): AssemblyaiDeleteResponse = + delete(endpoint, AssemblyaiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AssemblyaiDeleteResponse = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + ): AssemblyaiDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -63,9 +143,31 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiDeleteResponse + /** @see [delete] */ + fun delete(params: AssemblyaiDeleteParams): AssemblyaiDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): AssemblyaiDeleteResponse = + delete(endpoint, AssemblyaiDeleteParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun patch(params: AssemblyaiPatchParams): AssemblyaiPatchResponse = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): AssemblyaiPatchResponse = + patch(endpoint, AssemblyaiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AssemblyaiPatchResponse = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + ): AssemblyaiPatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -73,6 +175,14 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiPatchResponse + /** @see [patch] */ + fun patch(params: AssemblyaiPatchParams): AssemblyaiPatchResponse = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): AssemblyaiPatchResponse = + patch(endpoint, AssemblyaiPatchParams.none(), requestOptions) + /** A view of [AssemblyaiService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -81,8 +191,25 @@ interface AssemblyaiService { * as [AssemblyaiService.create]. */ @MustBeClosed - fun create(params: AssemblyaiCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, AssemblyaiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), + ): HttpResponseFor = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -91,14 +218,43 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: AssemblyaiCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, AssemblyaiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiService.retrieve]. */ @MustBeClosed + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, AssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: AssemblyaiRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -107,13 +263,44 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AssemblyaiRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, AssemblyaiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiService.update]. */ @MustBeClosed - fun update(params: AssemblyaiUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, AssemblyaiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), + ): HttpResponseFor = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -122,13 +309,43 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: AssemblyaiUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, AssemblyaiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /assemblyai/{endpoint}`, but is otherwise the * same as [AssemblyaiService.delete]. */ @MustBeClosed - fun delete(params: AssemblyaiDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, AssemblyaiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), + ): HttpResponseFor = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -137,13 +354,42 @@ interface AssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: AssemblyaiDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, AssemblyaiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiService.patch]. */ @MustBeClosed - fun patch(params: AssemblyaiPatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, AssemblyaiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -151,5 +397,18 @@ interface AssemblyaiService { params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: AssemblyaiPatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, AssemblyaiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt index b934fdfd..6176ea68 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveParams import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveResponse import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateResponse +import kotlin.jvm.optionals.getOrNull class AssemblyaiServiceImpl internal constructor(private val clientOptions: ClientOptions) : AssemblyaiService { @@ -83,6 +85,9 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie params: AssemblyaiCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie params: AssemblyaiRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie params: AssemblyaiUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie params: AssemblyaiDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie params: AssemblyaiPatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt index 80f4082d..582d181c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt @@ -69,8 +69,22 @@ interface AssistantService { * API Reference docs - * https://platform.openai.com/docs/api-reference/assistants/createAssistant */ - fun delete(params: AssistantDeleteParams): AssistantDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(assistantId: String): AssistantDeleteResponse = + delete(assistantId, AssistantDeleteParams.none()) + + /** @see [delete] */ + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AssistantDeleteResponse = + delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) + + /** @see [delete] */ + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + ): AssistantDeleteResponse = delete(assistantId, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -78,6 +92,14 @@ interface AssistantService { requestOptions: RequestOptions = RequestOptions.none(), ): AssistantDeleteResponse + /** @see [delete] */ + fun delete(params: AssistantDeleteParams): AssistantDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(assistantId: String, requestOptions: RequestOptions): AssistantDeleteResponse = + delete(assistantId, AssistantDeleteParams.none(), requestOptions) + /** A view of [AssistantService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -137,8 +159,25 @@ interface AssistantService { * the same as [AssistantService.delete]. */ @MustBeClosed - fun delete(params: AssistantDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(assistantId: String): HttpResponseFor = + delete(assistantId, AssistantDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + assistantId: String, + params: AssistantDeleteParams = AssistantDeleteParams.none(), + ): HttpResponseFor = + delete(assistantId, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -146,5 +185,18 @@ interface AssistantService { params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [delete] */ + @MustBeClosed + fun delete(params: AssistantDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + assistantId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(assistantId, AssistantDeleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt index 317d0d00..9fb2d8dd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import ai.hanzo.api.models.assistants.AssistantDeleteParams import ai.hanzo.api.models.assistants.AssistantDeleteResponse import ai.hanzo.api.models.assistants.AssistantListParams import ai.hanzo.api.models.assistants.AssistantListResponse +import kotlin.jvm.optionals.getOrNull class AssistantServiceImpl internal constructor(private val clientOptions: ClientOptions) : AssistantService { @@ -120,6 +122,9 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien params: AssistantDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("assistantId", params.assistantId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt index 23fe7dd5..3752e2e0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt @@ -28,8 +28,20 @@ interface AzureService { * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun create(params: AzureCreateParams): AzureCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): AzureCreateResponse = create(endpoint, AzureCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AzureCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + ): AzureCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -37,13 +49,33 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): AzureCreateResponse + /** @see [create] */ + fun create(params: AzureCreateParams): AzureCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): AzureCreateResponse = + create(endpoint, AzureCreateParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun update(params: AzureUpdateParams): AzureUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): AzureUpdateResponse = update(endpoint, AzureUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AzureUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + ): AzureUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -51,13 +83,33 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): AzureUpdateResponse + /** @see [update] */ + fun update(params: AzureUpdateParams): AzureUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): AzureUpdateResponse = + update(endpoint, AzureUpdateParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun delete(params: AzureDeleteParams): AzureDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): AzureDeleteResponse = delete(endpoint, AzureDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AzureDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + ): AzureDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -65,12 +117,33 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): AzureDeleteResponse + /** @see [delete] */ + fun delete(params: AzureDeleteParams): AzureDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): AzureDeleteResponse = + delete(endpoint, AzureDeleteParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun call(params: AzureCallParams): AzureCallResponse = call(params, RequestOptions.none()) + fun call(endpoint: String): AzureCallResponse = call(endpoint, AzureCallParams.none()) + + /** @see [call] */ + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AzureCallResponse = call(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [call] */ + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + ): AzureCallResponse = call(endpoint, params, RequestOptions.none()) /** @see [call] */ fun call( @@ -78,12 +151,32 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): AzureCallResponse + /** @see [call] */ + fun call(params: AzureCallParams): AzureCallResponse = call(params, RequestOptions.none()) + + /** @see [call] */ + fun call(endpoint: String, requestOptions: RequestOptions): AzureCallResponse = + call(endpoint, AzureCallParams.none(), requestOptions) + /** * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` */ - fun patch(params: AzurePatchParams): AzurePatchResponse = patch(params, RequestOptions.none()) + fun patch(endpoint: String): AzurePatchResponse = patch(endpoint, AzurePatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AzurePatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + ): AzurePatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -91,6 +184,13 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): AzurePatchResponse + /** @see [patch] */ + fun patch(params: AzurePatchParams): AzurePatchResponse = patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): AzurePatchResponse = + patch(endpoint, AzurePatchParams.none(), requestOptions) + /** A view of [AzureService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -99,8 +199,24 @@ interface AzureService { * [AzureService.create]. */ @MustBeClosed - fun create(params: AzureCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, AzureCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: AzureCreateParams = AzureCreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -109,13 +225,42 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: AzureCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, AzureCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /azure/{endpoint}`, but is otherwise the same as * [AzureService.update]. */ @MustBeClosed - fun update(params: AzureUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, AzureUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: AzureUpdateParams = AzureUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -124,13 +269,42 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: AzureUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, AzureUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /azure/{endpoint}`, but is otherwise the same as * [AzureService.delete]. */ @MustBeClosed - fun delete(params: AzureDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, AzureDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: AzureDeleteParams = AzureDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -139,13 +313,42 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: AzureDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, AzureDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /azure/{endpoint}`, but is otherwise the same as * [AzureService.call]. */ @MustBeClosed - fun call(params: AzureCallParams): HttpResponseFor = - call(params, RequestOptions.none()) + fun call(endpoint: String): HttpResponseFor = + call(endpoint, AzureCallParams.none()) + + /** @see [call] */ + @MustBeClosed + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + call(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [call] */ + @MustBeClosed + fun call( + endpoint: String, + params: AzureCallParams = AzureCallParams.none(), + ): HttpResponseFor = call(endpoint, params, RequestOptions.none()) /** @see [call] */ @MustBeClosed @@ -154,13 +357,42 @@ interface AzureService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [call] */ + @MustBeClosed + fun call(params: AzureCallParams): HttpResponseFor = + call(params, RequestOptions.none()) + + /** @see [call] */ + @MustBeClosed + fun call( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + call(endpoint, AzureCallParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /azure/{endpoint}`, but is otherwise the same as * [AzureService.patch]. */ @MustBeClosed - fun patch(params: AzurePatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, AzurePatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: AzurePatchParams = AzurePatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -168,5 +400,18 @@ interface AzureService { params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: AzurePatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, AzurePatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt index b814e518..1034efc3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.azure.AzurePatchParams import ai.hanzo.api.models.azure.AzurePatchResponse import ai.hanzo.api.models.azure.AzureUpdateParams import ai.hanzo.api.models.azure.AzureUpdateResponse +import kotlin.jvm.optionals.getOrNull class AzureServiceImpl internal constructor(private val clientOptions: ClientOptions) : AzureService { @@ -80,6 +82,9 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt params: AzureCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -108,6 +113,9 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt params: AzureUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -136,6 +144,9 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt params: AzureDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -163,6 +174,9 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt params: AzureCallParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -189,6 +203,9 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt params: AzurePatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt index d8a9b9a8..7f81f262 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt @@ -71,8 +71,21 @@ interface BatchService { * curl http://localhost:4000/v1/batches/batch_abc123 -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" * ``` */ - fun retrieve(params: BatchRetrieveParams): BatchRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(batchId: String): BatchRetrieveResponse = + retrieve(batchId, BatchRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchRetrieveResponse = retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + ): BatchRetrieveResponse = retrieve(batchId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -80,6 +93,14 @@ interface BatchService { requestOptions: RequestOptions = RequestOptions.none(), ): BatchRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: BatchRetrieveParams): BatchRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(batchId: String, requestOptions: RequestOptions): BatchRetrieveResponse = + retrieve(batchId, BatchRetrieveParams.none(), requestOptions) + /** * Lists This is the equivalent of GET https://api.openai.com/v1/batches/ Supports Identical * Params as: https://platform.openai.com/docs/api-reference/batch/list @@ -119,6 +140,20 @@ interface BatchService { * * ``` */ + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + ): BatchCancelWithProviderResponse = cancelWithProvider(batchId, params, RequestOptions.none()) + + /** @see [cancelWithProvider] */ + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchCancelWithProviderResponse = + cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancelWithProvider] */ fun cancelWithProvider(params: BatchCancelWithProviderParams): BatchCancelWithProviderResponse = cancelWithProvider(params, RequestOptions.none()) @@ -143,8 +178,22 @@ interface BatchService { * }' * ``` */ - fun createWithProvider(params: BatchCreateWithProviderParams): BatchCreateWithProviderResponse = - createWithProvider(params, RequestOptions.none()) + fun createWithProvider(provider: String): BatchCreateWithProviderResponse = + createWithProvider(provider, BatchCreateWithProviderParams.none()) + + /** @see [createWithProvider] */ + fun createWithProvider( + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchCreateWithProviderResponse = + createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [createWithProvider] */ + fun createWithProvider( + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + ): BatchCreateWithProviderResponse = createWithProvider(provider, params, RequestOptions.none()) /** @see [createWithProvider] */ fun createWithProvider( @@ -152,6 +201,17 @@ interface BatchService { requestOptions: RequestOptions = RequestOptions.none(), ): BatchCreateWithProviderResponse + /** @see [createWithProvider] */ + fun createWithProvider(params: BatchCreateWithProviderParams): BatchCreateWithProviderResponse = + createWithProvider(params, RequestOptions.none()) + + /** @see [createWithProvider] */ + fun createWithProvider( + provider: String, + requestOptions: RequestOptions, + ): BatchCreateWithProviderResponse = + createWithProvider(provider, BatchCreateWithProviderParams.none(), requestOptions) + /** * Lists This is the equivalent of GET https://api.openai.com/v1/batches/ Supports Identical * Params as: https://platform.openai.com/docs/api-reference/batch/list @@ -162,8 +222,22 @@ interface BatchService { * curl http://localhost:4000/v1/batches?limit=2 -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" * ``` */ - fun listWithProvider(params: BatchListWithProviderParams): BatchListWithProviderResponse = - listWithProvider(params, RequestOptions.none()) + fun listWithProvider(provider: String): BatchListWithProviderResponse = + listWithProvider(provider, BatchListWithProviderParams.none()) + + /** @see [listWithProvider] */ + fun listWithProvider( + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchListWithProviderResponse = + listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [listWithProvider] */ + fun listWithProvider( + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + ): BatchListWithProviderResponse = listWithProvider(provider, params, RequestOptions.none()) /** @see [listWithProvider] */ fun listWithProvider( @@ -171,6 +245,17 @@ interface BatchService { requestOptions: RequestOptions = RequestOptions.none(), ): BatchListWithProviderResponse + /** @see [listWithProvider] */ + fun listWithProvider(params: BatchListWithProviderParams): BatchListWithProviderResponse = + listWithProvider(params, RequestOptions.none()) + + /** @see [listWithProvider] */ + fun listWithProvider( + provider: String, + requestOptions: RequestOptions, + ): BatchListWithProviderResponse = + listWithProvider(provider, BatchListWithProviderParams.none(), requestOptions) + /** * Retrieves a batch. This is the equivalent of GET https://api.openai.com/v1/batches/{batch_id} * Supports Identical Params as: https://platform.openai.com/docs/api-reference/batch/retrieve @@ -181,6 +266,21 @@ interface BatchService { * curl http://localhost:4000/v1/batches/batch_abc123 -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" * ``` */ + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + ): BatchRetrieveWithProviderResponse = + retrieveWithProvider(batchId, params, RequestOptions.none()) + + /** @see [retrieveWithProvider] */ + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchRetrieveWithProviderResponse = + retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieveWithProvider] */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): BatchRetrieveWithProviderResponse = retrieveWithProvider(params, RequestOptions.none()) @@ -226,8 +326,24 @@ interface BatchService { * as [BatchService.retrieve]. */ @MustBeClosed - fun retrieve(params: BatchRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(batchId: String): HttpResponseFor = + retrieve(batchId, BatchRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + batchId: String, + params: BatchRetrieveParams = BatchRetrieveParams.none(), + ): HttpResponseFor = retrieve(batchId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -236,6 +352,19 @@ interface BatchService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: BatchRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + batchId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(batchId, BatchRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /v1/batches`, but is otherwise the same as * [BatchService.list]. @@ -265,6 +394,23 @@ interface BatchService { * otherwise the same as [BatchService.cancelWithProvider]. */ @MustBeClosed + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + ): HttpResponseFor = + cancelWithProvider(batchId, params, RequestOptions.none()) + + /** @see [cancelWithProvider] */ + @MustBeClosed + fun cancelWithProvider( + batchId: String, + params: BatchCancelWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancelWithProvider] */ + @MustBeClosed fun cancelWithProvider( params: BatchCancelWithProviderParams ): HttpResponseFor = @@ -282,10 +428,25 @@ interface BatchService { * as [BatchService.createWithProvider]. */ @MustBeClosed + fun createWithProvider(provider: String): HttpResponseFor = + createWithProvider(provider, BatchCreateWithProviderParams.none()) + + /** @see [createWithProvider] */ + @MustBeClosed fun createWithProvider( - params: BatchCreateWithProviderParams + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - createWithProvider(params, RequestOptions.none()) + createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + provider: String, + params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), + ): HttpResponseFor = + createWithProvider(provider, params, RequestOptions.none()) /** @see [createWithProvider] */ @MustBeClosed @@ -294,15 +455,45 @@ interface BatchService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + params: BatchCreateWithProviderParams + ): HttpResponseFor = + createWithProvider(params, RequestOptions.none()) + + /** @see [createWithProvider] */ + @MustBeClosed + fun createWithProvider( + provider: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + createWithProvider(provider, BatchCreateWithProviderParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /{provider}/v1/batches`, but is otherwise the same * as [BatchService.listWithProvider]. */ @MustBeClosed + fun listWithProvider(provider: String): HttpResponseFor = + listWithProvider(provider, BatchListWithProviderParams.none()) + + /** @see [listWithProvider] */ + @MustBeClosed fun listWithProvider( - params: BatchListWithProviderParams + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - listWithProvider(params, RequestOptions.none()) + listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + provider: String, + params: BatchListWithProviderParams = BatchListWithProviderParams.none(), + ): HttpResponseFor = + listWithProvider(provider, params, RequestOptions.none()) /** @see [listWithProvider] */ @MustBeClosed @@ -311,11 +502,43 @@ interface BatchService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + params: BatchListWithProviderParams + ): HttpResponseFor = + listWithProvider(params, RequestOptions.none()) + + /** @see [listWithProvider] */ + @MustBeClosed + fun listWithProvider( + provider: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listWithProvider(provider, BatchListWithProviderParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /{provider}/v1/batches/{batch_id}`, but is otherwise * the same as [BatchService.retrieveWithProvider]. */ @MustBeClosed + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + ): HttpResponseFor = + retrieveWithProvider(batchId, params, RequestOptions.none()) + + /** @see [retrieveWithProvider] */ + @MustBeClosed + fun retrieveWithProvider( + batchId: String, + params: BatchRetrieveWithProviderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [retrieveWithProvider] */ + @MustBeClosed fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): HttpResponseFor = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt index b37816f0..74c5540d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -31,6 +32,7 @@ import ai.hanzo.api.models.batches.BatchRetrieveWithProviderParams import ai.hanzo.api.models.batches.BatchRetrieveWithProviderResponse import ai.hanzo.api.services.blocking.batches.CancelService import ai.hanzo.api.services.blocking.batches.CancelServiceImpl +import kotlin.jvm.optionals.getOrNull class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : BatchService { @@ -138,6 +140,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt params: BatchRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -191,6 +196,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt params: BatchCancelWithProviderParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -225,6 +233,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt params: BatchCreateWithProviderParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -253,6 +264,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt params: BatchListWithProviderParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -280,6 +294,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt params: BatchRetrieveWithProviderParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt index 12f8c448..835918af 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt @@ -24,8 +24,21 @@ interface BedrockService { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun create(params: BedrockCreateParams): BedrockCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): BedrockCreateResponse = + create(endpoint, BedrockCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BedrockCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + ): BedrockCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -33,9 +46,31 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): BedrockCreateResponse + /** @see [create] */ + fun create(params: BedrockCreateParams): BedrockCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): BedrockCreateResponse = + create(endpoint, BedrockCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun retrieve(params: BedrockRetrieveParams): BedrockRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): BedrockRetrieveResponse = + retrieve(endpoint, BedrockRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BedrockRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + ): BedrockRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -43,9 +78,30 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): BedrockRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: BedrockRetrieveParams): BedrockRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): BedrockRetrieveResponse = + retrieve(endpoint, BedrockRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun update(params: BedrockUpdateParams): BedrockUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): BedrockUpdateResponse = + update(endpoint, BedrockUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BedrockUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + ): BedrockUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -53,9 +109,30 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): BedrockUpdateResponse + /** @see [update] */ + fun update(params: BedrockUpdateParams): BedrockUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): BedrockUpdateResponse = + update(endpoint, BedrockUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun delete(params: BedrockDeleteParams): BedrockDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): BedrockDeleteResponse = + delete(endpoint, BedrockDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BedrockDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + ): BedrockDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -63,9 +140,29 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): BedrockDeleteResponse + /** @see [delete] */ + fun delete(params: BedrockDeleteParams): BedrockDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): BedrockDeleteResponse = + delete(endpoint, BedrockDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ - fun patch(params: BedrockPatchParams): BedrockPatchResponse = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): BedrockPatchResponse = patch(endpoint, BedrockPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BedrockPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + ): BedrockPatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -73,6 +170,14 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): BedrockPatchResponse + /** @see [patch] */ + fun patch(params: BedrockPatchParams): BedrockPatchResponse = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): BedrockPatchResponse = + patch(endpoint, BedrockPatchParams.none(), requestOptions) + /** A view of [BedrockService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -81,8 +186,24 @@ interface BedrockService { * [BedrockService.create]. */ @MustBeClosed - fun create(params: BedrockCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, BedrockCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: BedrockCreateParams = BedrockCreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -91,13 +212,43 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: BedrockCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, BedrockCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /bedrock/{endpoint}`, but is otherwise the same as * [BedrockService.retrieve]. */ @MustBeClosed - fun retrieve(params: BedrockRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, BedrockRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: BedrockRetrieveParams = BedrockRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -106,13 +257,42 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: BedrockRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, BedrockRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /bedrock/{endpoint}`, but is otherwise the same as * [BedrockService.update]. */ @MustBeClosed - fun update(params: BedrockUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, BedrockUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: BedrockUpdateParams = BedrockUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -121,13 +301,42 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: BedrockUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, BedrockUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /bedrock/{endpoint}`, but is otherwise the same * as [BedrockService.delete]. */ @MustBeClosed - fun delete(params: BedrockDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, BedrockDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: BedrockDeleteParams = BedrockDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -136,13 +345,42 @@ interface BedrockService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: BedrockDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, BedrockDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /bedrock/{endpoint}`, but is otherwise the same as * [BedrockService.patch]. */ @MustBeClosed - fun patch(params: BedrockPatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, BedrockPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: BedrockPatchParams = BedrockPatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -150,5 +388,18 @@ interface BedrockService { params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: BedrockPatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, BedrockPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt index 75d48060..66f8820d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.bedrock.BedrockRetrieveParams import ai.hanzo.api.models.bedrock.BedrockRetrieveResponse import ai.hanzo.api.models.bedrock.BedrockUpdateParams import ai.hanzo.api.models.bedrock.BedrockUpdateResponse +import kotlin.jvm.optionals.getOrNull class BedrockServiceImpl internal constructor(private val clientOptions: ClientOptions) : BedrockService { @@ -83,6 +85,9 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO params: BedrockCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO params: BedrockRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO params: BedrockUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO params: BedrockDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO params: BedrockPatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt index df53504b..983892db 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt @@ -24,8 +24,20 @@ interface CohereService { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun create(params: CohereCreateParams): CohereCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): CohereCreateResponse = create(endpoint, CohereCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CohereCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + ): CohereCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -33,9 +45,31 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): CohereCreateResponse + /** @see [create] */ + fun create(params: CohereCreateParams): CohereCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): CohereCreateResponse = + create(endpoint, CohereCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun retrieve(params: CohereRetrieveParams): CohereRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): CohereRetrieveResponse = + retrieve(endpoint, CohereRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CohereRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + ): CohereRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -43,9 +77,29 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): CohereRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: CohereRetrieveParams): CohereRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): CohereRetrieveResponse = + retrieve(endpoint, CohereRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun update(params: CohereUpdateParams): CohereUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): CohereUpdateResponse = update(endpoint, CohereUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CohereUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + ): CohereUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -53,9 +107,29 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): CohereUpdateResponse + /** @see [update] */ + fun update(params: CohereUpdateParams): CohereUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): CohereUpdateResponse = + update(endpoint, CohereUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun delete(params: CohereDeleteParams): CohereDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): CohereDeleteResponse = delete(endpoint, CohereDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CohereDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + ): CohereDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -63,9 +137,29 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): CohereDeleteResponse + /** @see [delete] */ + fun delete(params: CohereDeleteParams): CohereDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): CohereDeleteResponse = + delete(endpoint, CohereDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ - fun modify(params: CohereModifyParams): CohereModifyResponse = - modify(params, RequestOptions.none()) + fun modify(endpoint: String): CohereModifyResponse = modify(endpoint, CohereModifyParams.none()) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CohereModifyResponse = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + ): CohereModifyResponse = modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ fun modify( @@ -73,6 +167,14 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): CohereModifyResponse + /** @see [modify] */ + fun modify(params: CohereModifyParams): CohereModifyResponse = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + fun modify(endpoint: String, requestOptions: RequestOptions): CohereModifyResponse = + modify(endpoint, CohereModifyParams.none(), requestOptions) + /** A view of [CohereService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -81,8 +183,24 @@ interface CohereService { * [CohereService.create]. */ @MustBeClosed - fun create(params: CohereCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, CohereCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: CohereCreateParams = CohereCreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -91,13 +209,43 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: CohereCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, CohereCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /cohere/{endpoint}`, but is otherwise the same as * [CohereService.retrieve]. */ @MustBeClosed - fun retrieve(params: CohereRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, CohereRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: CohereRetrieveParams = CohereRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -106,13 +254,42 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: CohereRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, CohereRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /cohere/{endpoint}`, but is otherwise the same as * [CohereService.update]. */ @MustBeClosed - fun update(params: CohereUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, CohereUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: CohereUpdateParams = CohereUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -121,13 +298,42 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: CohereUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, CohereUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /cohere/{endpoint}`, but is otherwise the same as * [CohereService.delete]. */ @MustBeClosed - fun delete(params: CohereDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, CohereDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: CohereDeleteParams = CohereDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -136,13 +342,42 @@ interface CohereService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: CohereDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, CohereDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /cohere/{endpoint}`, but is otherwise the same as * [CohereService.modify]. */ @MustBeClosed - fun modify(params: CohereModifyParams): HttpResponseFor = - modify(params, RequestOptions.none()) + fun modify(endpoint: String): HttpResponseFor = + modify(endpoint, CohereModifyParams.none()) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + params: CohereModifyParams = CohereModifyParams.none(), + ): HttpResponseFor = modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ @MustBeClosed @@ -150,5 +385,18 @@ interface CohereService { params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [modify] */ + @MustBeClosed + fun modify(params: CohereModifyParams): HttpResponseFor = + modify(params, RequestOptions.none()) + + /** @see [modify] */ + @MustBeClosed + fun modify( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + modify(endpoint, CohereModifyParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt index 7532092c..61d3387b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.cohere.CohereRetrieveParams import ai.hanzo.api.models.cohere.CohereRetrieveResponse import ai.hanzo.api.models.cohere.CohereUpdateParams import ai.hanzo.api.models.cohere.CohereUpdateResponse +import kotlin.jvm.optionals.getOrNull class CohereServiceImpl internal constructor(private val clientOptions: ClientOptions) : CohereService { @@ -83,6 +85,9 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp params: CohereCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp params: CohereRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp params: CohereUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp params: CohereDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp params: CohereModifyParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt index 959def32..9971d72a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt @@ -50,8 +50,22 @@ interface CredentialService { list(CredentialListParams.none(), requestOptions) /** [BETA] endpoint. This might change unexpectedly. */ - fun delete(params: CredentialDeleteParams): CredentialDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(credentialName: String): CredentialDeleteResponse = + delete(credentialName, CredentialDeleteParams.none()) + + /** @see [delete] */ + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CredentialDeleteResponse = + delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) + + /** @see [delete] */ + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + ): CredentialDeleteResponse = delete(credentialName, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -59,6 +73,14 @@ interface CredentialService { requestOptions: RequestOptions = RequestOptions.none(), ): CredentialDeleteResponse + /** @see [delete] */ + fun delete(params: CredentialDeleteParams): CredentialDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(credentialName: String, requestOptions: RequestOptions): CredentialDeleteResponse = + delete(credentialName, CredentialDeleteParams.none(), requestOptions) + /** A view of [CredentialService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -107,8 +129,25 @@ interface CredentialService { * the same as [CredentialService.delete]. */ @MustBeClosed - fun delete(params: CredentialDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(credentialName: String): HttpResponseFor = + delete(credentialName, CredentialDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + credentialName: String, + params: CredentialDeleteParams = CredentialDeleteParams.none(), + ): HttpResponseFor = + delete(credentialName, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -116,5 +155,18 @@ interface CredentialService { params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [delete] */ + @MustBeClosed + fun delete(params: CredentialDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + credentialName: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(credentialName, CredentialDeleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt index e5fb7be8..89e727f3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import ai.hanzo.api.models.credentials.CredentialDeleteParams import ai.hanzo.api.models.credentials.CredentialDeleteResponse import ai.hanzo.api.models.credentials.CredentialListParams import ai.hanzo.api.models.credentials.CredentialListResponse +import kotlin.jvm.optionals.getOrNull class CredentialServiceImpl internal constructor(private val clientOptions: ClientOptions) : CredentialService { @@ -120,6 +122,9 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie params: CredentialDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("credentialName", params.credentialName().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt index 6e4ecf65..14c61c87 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt @@ -36,8 +36,21 @@ interface EngineService { * }' * ``` */ - fun complete(params: EngineCompleteParams): EngineCompleteResponse = - complete(params, RequestOptions.none()) + fun complete(model: String): EngineCompleteResponse = + complete(model, EngineCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EngineCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + ): EngineCompleteResponse = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -45,6 +58,14 @@ interface EngineService { requestOptions: RequestOptions = RequestOptions.none(), ): EngineCompleteResponse + /** @see [complete] */ + fun complete(params: EngineCompleteParams): EngineCompleteResponse = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete(model: String, requestOptions: RequestOptions): EngineCompleteResponse = + complete(model, EngineCompleteParams.none(), requestOptions) + /** * Follows the exact same API spec as `OpenAI's Embeddings API * https://platform.openai.com/docs/api-reference/embeddings` @@ -59,7 +80,20 @@ interface EngineService { * }' * ``` */ - fun embed(params: EngineEmbedParams): EngineEmbedResponse = embed(params, RequestOptions.none()) + fun embed(model: String): EngineEmbedResponse = embed(model, EngineEmbedParams.none()) + + /** @see [embed] */ + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EngineEmbedResponse = embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + ): EngineEmbedResponse = embed(model, params, RequestOptions.none()) /** @see [embed] */ fun embed( @@ -67,6 +101,13 @@ interface EngineService { requestOptions: RequestOptions = RequestOptions.none(), ): EngineEmbedResponse + /** @see [embed] */ + fun embed(params: EngineEmbedParams): EngineEmbedResponse = embed(params, RequestOptions.none()) + + /** @see [embed] */ + fun embed(model: String, requestOptions: RequestOptions): EngineEmbedResponse = + embed(model, EngineEmbedParams.none(), requestOptions) + /** A view of [EngineService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -77,8 +118,24 @@ interface EngineService { * same as [EngineService.complete]. */ @MustBeClosed - fun complete(params: EngineCompleteParams): HttpResponseFor = - complete(params, RequestOptions.none()) + fun complete(model: String): HttpResponseFor = + complete(model, EngineCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: EngineCompleteParams = EngineCompleteParams.none(), + ): HttpResponseFor = complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -87,13 +144,42 @@ interface EngineService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [complete] */ + @MustBeClosed + fun complete(params: EngineCompleteParams): HttpResponseFor = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + complete(model, EngineCompleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /engines/{model}/embeddings`, but is otherwise the * same as [EngineService.embed]. */ @MustBeClosed - fun embed(params: EngineEmbedParams): HttpResponseFor = - embed(params, RequestOptions.none()) + fun embed(model: String): HttpResponseFor = + embed(model, EngineEmbedParams.none()) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + params: EngineEmbedParams = EngineEmbedParams.none(), + ): HttpResponseFor = embed(model, params, RequestOptions.none()) /** @see [embed] */ @MustBeClosed @@ -101,5 +187,18 @@ interface EngineService { params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [embed] */ + @MustBeClosed + fun embed(params: EngineEmbedParams): HttpResponseFor = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + embed(model, EngineEmbedParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt index 7292f799..2c8fef26 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import ai.hanzo.api.models.engines.EngineEmbedParams import ai.hanzo.api.models.engines.EngineEmbedResponse import ai.hanzo.api.services.blocking.engines.ChatService import ai.hanzo.api.services.blocking.engines.ChatServiceImpl +import kotlin.jvm.optionals.getOrNull class EngineServiceImpl internal constructor(private val clientOptions: ClientOptions) : EngineService { @@ -68,6 +70,9 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp params: EngineCompleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -96,6 +101,9 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp params: EngineEmbedParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt index 20410b47..299bd46d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt @@ -24,8 +24,22 @@ interface EuAssemblyaiService { fun withRawResponse(): WithRawResponse /** Assemblyai Proxy Route */ - fun create(params: EuAssemblyaiCreateParams): EuAssemblyaiCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): EuAssemblyaiCreateResponse = + create(endpoint, EuAssemblyaiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EuAssemblyaiCreateResponse = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + ): EuAssemblyaiCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -33,9 +47,31 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiCreateResponse + /** @see [create] */ + fun create(params: EuAssemblyaiCreateParams): EuAssemblyaiCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiCreateResponse = + create(endpoint, EuAssemblyaiCreateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun retrieve(params: EuAssemblyaiRetrieveParams): EuAssemblyaiRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): EuAssemblyaiRetrieveResponse = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EuAssemblyaiRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + ): EuAssemblyaiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -43,9 +79,31 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: EuAssemblyaiRetrieveParams): EuAssemblyaiRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiRetrieveResponse = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun update(params: EuAssemblyaiUpdateParams): EuAssemblyaiUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): EuAssemblyaiUpdateResponse = + update(endpoint, EuAssemblyaiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EuAssemblyaiUpdateResponse = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + ): EuAssemblyaiUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -53,9 +111,31 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiUpdateResponse + /** @see [update] */ + fun update(params: EuAssemblyaiUpdateParams): EuAssemblyaiUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiUpdateResponse = + update(endpoint, EuAssemblyaiUpdateParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun delete(params: EuAssemblyaiDeleteParams): EuAssemblyaiDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): EuAssemblyaiDeleteResponse = + delete(endpoint, EuAssemblyaiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EuAssemblyaiDeleteResponse = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + ): EuAssemblyaiDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -63,9 +143,31 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiDeleteResponse + /** @see [delete] */ + fun delete(params: EuAssemblyaiDeleteParams): EuAssemblyaiDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiDeleteResponse = + delete(endpoint, EuAssemblyaiDeleteParams.none(), requestOptions) + /** Assemblyai Proxy Route */ - fun patch(params: EuAssemblyaiPatchParams): EuAssemblyaiPatchResponse = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): EuAssemblyaiPatchResponse = + patch(endpoint, EuAssemblyaiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EuAssemblyaiPatchResponse = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + ): EuAssemblyaiPatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -73,6 +175,14 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiPatchResponse + /** @see [patch] */ + fun patch(params: EuAssemblyaiPatchParams): EuAssemblyaiPatchResponse = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiPatchResponse = + patch(endpoint, EuAssemblyaiPatchParams.none(), requestOptions) + /** * A view of [EuAssemblyaiService] that provides access to raw HTTP responses for each method. */ @@ -83,8 +193,25 @@ interface EuAssemblyaiService { * same as [EuAssemblyaiService.create]. */ @MustBeClosed - fun create(params: EuAssemblyaiCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, EuAssemblyaiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), + ): HttpResponseFor = + create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -93,14 +220,43 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: EuAssemblyaiCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, EuAssemblyaiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiService.retrieve]. */ @MustBeClosed + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: EuAssemblyaiRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -109,13 +265,44 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: EuAssemblyaiRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, EuAssemblyaiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiService.update]. */ @MustBeClosed - fun update(params: EuAssemblyaiUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, EuAssemblyaiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), + ): HttpResponseFor = + update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -124,13 +311,43 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: EuAssemblyaiUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, EuAssemblyaiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiService.delete]. */ @MustBeClosed - fun delete(params: EuAssemblyaiDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, EuAssemblyaiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), + ): HttpResponseFor = + delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -139,13 +356,43 @@ interface EuAssemblyaiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: EuAssemblyaiDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, EuAssemblyaiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiService.patch]. */ @MustBeClosed - fun patch(params: EuAssemblyaiPatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, EuAssemblyaiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), + ): HttpResponseFor = + patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -153,5 +400,18 @@ interface EuAssemblyaiService { params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: EuAssemblyaiPatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, EuAssemblyaiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt index d6ef5111..cba8d569 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveResponse import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateResponse +import kotlin.jvm.optionals.getOrNull class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: ClientOptions) : EuAssemblyaiService { @@ -83,6 +85,9 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl params: EuAssemblyaiCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl params: EuAssemblyaiPatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt index c27d81ad..d591f2bc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt @@ -37,6 +37,17 @@ interface FileService { * * ``` */ + fun create(provider: String, params: FileCreateParams): FileCreateResponse = + create(provider, params, RequestOptions.none()) + + /** @see [create] */ + fun create( + provider: String, + params: FileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileCreateResponse = create(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [create] */ fun create(params: FileCreateParams): FileCreateResponse = create(params, RequestOptions.none()) /** @see [create] */ @@ -58,6 +69,17 @@ interface FileService { * * ``` */ + fun retrieve(fileId: String, params: FileRetrieveParams): FileRetrieveResponse = + retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + fileId: String, + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ fun retrieve(params: FileRetrieveParams): FileRetrieveResponse = retrieve(params, RequestOptions.none()) @@ -80,7 +102,18 @@ interface FileService { * * ``` */ - fun list(params: FileListParams): FileListResponse = list(params, RequestOptions.none()) + fun list(provider: String): FileListResponse = list(provider, FileListParams.none()) + + /** @see [list] */ + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FileListResponse = list(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [list] */ + fun list(provider: String, params: FileListParams = FileListParams.none()): FileListResponse = + list(provider, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -88,6 +121,13 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): FileListResponse + /** @see [list] */ + fun list(params: FileListParams): FileListResponse = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(provider: String, requestOptions: RequestOptions): FileListResponse = + list(provider, FileListParams.none(), requestOptions) + /** * Deletes a specified file. that can be used across - Assistants API, Batch API This is the * equivalent of DELETE https://api.openai.com/v1/files/{file_id} @@ -101,6 +141,17 @@ interface FileService { * * ``` */ + fun delete(fileId: String, params: FileDeleteParams): FileDeleteResponse = + delete(fileId, params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + fileId: String, + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileDeleteResponse = delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [delete] */ fun delete(params: FileDeleteParams): FileDeleteResponse = delete(params, RequestOptions.none()) /** @see [delete] */ @@ -119,6 +170,22 @@ interface FileService { * [FileService.create]. */ @MustBeClosed + fun create( + provider: String, + params: FileCreateParams, + ): HttpResponseFor = create(provider, params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + provider: String, + params: FileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed fun create(params: FileCreateParams): HttpResponseFor = create(params, RequestOptions.none()) @@ -134,6 +201,22 @@ interface FileService { * the same as [FileService.retrieve]. */ @MustBeClosed + fun retrieve( + fileId: String, + params: FileRetrieveParams, + ): HttpResponseFor = retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + fileId: String, + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve(params: FileRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) @@ -149,8 +232,24 @@ interface FileService { * [FileService.list]. */ @MustBeClosed - fun list(params: FileListParams): HttpResponseFor = - list(params, RequestOptions.none()) + fun list(provider: String): HttpResponseFor = + list(provider, FileListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + provider: String, + params: FileListParams = FileListParams.none(), + ): HttpResponseFor = list(provider, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -159,11 +258,37 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [list] */ + @MustBeClosed + fun list(params: FileListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + provider: String, + requestOptions: RequestOptions, + ): HttpResponseFor = list(provider, FileListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /{provider}/v1/files/{file_id}`, but is otherwise * the same as [FileService.delete]. */ @MustBeClosed + fun delete(fileId: String, params: FileDeleteParams): HttpResponseFor = + delete(fileId, params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + fileId: String, + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed fun delete(params: FileDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt index 6382d963..ea588b1e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import ai.hanzo.api.models.files.FileRetrieveParams import ai.hanzo.api.models.files.FileRetrieveResponse import ai.hanzo.api.services.blocking.files.ContentService import ai.hanzo.api.services.blocking.files.ContentServiceImpl +import kotlin.jvm.optionals.getOrNull class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { @@ -82,6 +84,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti params: FileCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -110,6 +115,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti params: FileRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -136,6 +144,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti params: FileListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -162,6 +173,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti params: FileDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt index 0a841a42..4aa122a6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt @@ -24,8 +24,20 @@ interface GeminiService { fun withRawResponse(): WithRawResponse /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun create(params: GeminiCreateParams): GeminiCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): GeminiCreateResponse = create(endpoint, GeminiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): GeminiCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + ): GeminiCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -33,9 +45,31 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): GeminiCreateResponse + /** @see [create] */ + fun create(params: GeminiCreateParams): GeminiCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): GeminiCreateResponse = + create(endpoint, GeminiCreateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun retrieve(params: GeminiRetrieveParams): GeminiRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): GeminiRetrieveResponse = + retrieve(endpoint, GeminiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): GeminiRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + ): GeminiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -43,9 +77,29 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): GeminiRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: GeminiRetrieveParams): GeminiRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): GeminiRetrieveResponse = + retrieve(endpoint, GeminiRetrieveParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun update(params: GeminiUpdateParams): GeminiUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): GeminiUpdateResponse = update(endpoint, GeminiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): GeminiUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + ): GeminiUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -53,9 +107,29 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): GeminiUpdateResponse + /** @see [update] */ + fun update(params: GeminiUpdateParams): GeminiUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): GeminiUpdateResponse = + update(endpoint, GeminiUpdateParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun delete(params: GeminiDeleteParams): GeminiDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): GeminiDeleteResponse = delete(endpoint, GeminiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): GeminiDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + ): GeminiDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -63,8 +137,29 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): GeminiDeleteResponse + /** @see [delete] */ + fun delete(params: GeminiDeleteParams): GeminiDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): GeminiDeleteResponse = + delete(endpoint, GeminiDeleteParams.none(), requestOptions) + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ - fun patch(params: GeminiPatchParams): GeminiPatchResponse = patch(params, RequestOptions.none()) + fun patch(endpoint: String): GeminiPatchResponse = patch(endpoint, GeminiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): GeminiPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + ): GeminiPatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -72,6 +167,13 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): GeminiPatchResponse + /** @see [patch] */ + fun patch(params: GeminiPatchParams): GeminiPatchResponse = patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): GeminiPatchResponse = + patch(endpoint, GeminiPatchParams.none(), requestOptions) + /** A view of [GeminiService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -80,8 +182,24 @@ interface GeminiService { * [GeminiService.create]. */ @MustBeClosed - fun create(params: GeminiCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, GeminiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: GeminiCreateParams = GeminiCreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -90,13 +208,43 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: GeminiCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, GeminiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /gemini/{endpoint}`, but is otherwise the same as * [GeminiService.retrieve]. */ @MustBeClosed - fun retrieve(params: GeminiRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, GeminiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: GeminiRetrieveParams = GeminiRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -105,13 +253,42 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: GeminiRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, GeminiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /gemini/{endpoint}`, but is otherwise the same as * [GeminiService.update]. */ @MustBeClosed - fun update(params: GeminiUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, GeminiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: GeminiUpdateParams = GeminiUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -120,13 +297,42 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: GeminiUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, GeminiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /gemini/{endpoint}`, but is otherwise the same as * [GeminiService.delete]. */ @MustBeClosed - fun delete(params: GeminiDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, GeminiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: GeminiDeleteParams = GeminiDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -135,13 +341,42 @@ interface GeminiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: GeminiDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, GeminiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /gemini/{endpoint}`, but is otherwise the same as * [GeminiService.patch]. */ @MustBeClosed - fun patch(params: GeminiPatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, GeminiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: GeminiPatchParams = GeminiPatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -149,5 +384,18 @@ interface GeminiService { params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: GeminiPatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, GeminiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt index 62095a30..5b3a5273 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.gemini.GeminiRetrieveParams import ai.hanzo.api.models.gemini.GeminiRetrieveResponse import ai.hanzo.api.models.gemini.GeminiUpdateParams import ai.hanzo.api.models.gemini.GeminiUpdateResponse +import kotlin.jvm.optionals.getOrNull class GeminiServiceImpl internal constructor(private val clientOptions: ClientOptions) : GeminiService { @@ -83,6 +85,9 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp params: GeminiCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp params: GeminiRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp params: GeminiUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp params: GeminiDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp params: GeminiPatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt index e2baca4c..64c5e1d1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt @@ -377,8 +377,22 @@ interface KeyService { * * Note: This is an Enterprise feature. It requires a premium license to use. */ - fun regenerateByKey(params: KeyRegenerateByKeyParams): Optional = - regenerateByKey(params, RequestOptions.none()) + fun regenerateByKey(pathKey: String): Optional = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) + + /** @see [regenerateByKey] */ + fun regenerateByKey( + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional = + regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) + + /** @see [regenerateByKey] */ + fun regenerateByKey( + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + ): Optional = regenerateByKey(pathKey, params, RequestOptions.none()) /** @see [regenerateByKey] */ fun regenerateByKey( @@ -386,6 +400,17 @@ interface KeyService { requestOptions: RequestOptions = RequestOptions.none(), ): Optional + /** @see [regenerateByKey] */ + fun regenerateByKey(params: KeyRegenerateByKeyParams): Optional = + regenerateByKey(params, RequestOptions.none()) + + /** @see [regenerateByKey] */ + fun regenerateByKey( + pathKey: String, + requestOptions: RequestOptions, + ): Optional = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none(), requestOptions) + /** * Retrieve information about a key. Parameters: key: Optional[str] = Query parameter * representing the key in the request user_api_key_dict: UserAPIKeyAuth = Dependency @@ -584,10 +609,25 @@ interface KeyService { * as [KeyService.regenerateByKey]. */ @MustBeClosed + fun regenerateByKey(pathKey: String): HttpResponseFor> = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) + + /** @see [regenerateByKey] */ + @MustBeClosed fun regenerateByKey( - params: KeyRegenerateByKeyParams + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> = - regenerateByKey(params, RequestOptions.none()) + regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) + + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + pathKey: String, + params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), + ): HttpResponseFor> = + regenerateByKey(pathKey, params, RequestOptions.none()) /** @see [regenerateByKey] */ @MustBeClosed @@ -596,6 +636,21 @@ interface KeyService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + params: KeyRegenerateByKeyParams + ): HttpResponseFor> = + regenerateByKey(params, RequestOptions.none()) + + /** @see [regenerateByKey] */ + @MustBeClosed + fun regenerateByKey( + pathKey: String, + requestOptions: RequestOptions, + ): HttpResponseFor> = + regenerateByKey(pathKey, KeyRegenerateByKeyParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /key/info`, but is otherwise the same as * [KeyService.retrieveInfo]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt index 646ac395..ba1f440d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -35,6 +36,7 @@ import ai.hanzo.api.models.key.KeyUpdateResponse import ai.hanzo.api.services.blocking.key.RegenerateService import ai.hanzo.api.services.blocking.key.RegenerateServiceImpl import java.util.Optional +import kotlin.jvm.optionals.getOrNull class KeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : KeyService { @@ -291,6 +293,9 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio params: KeyRegenerateByKeyParams, requestOptions: RequestOptions, ): HttpResponseFor> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("pathKey", params.pathKey().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt index d2bc5d23..0de1955c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt @@ -28,8 +28,22 @@ interface LangfuseService { * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun create(params: LangfuseCreateParams): LangfuseCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): LangfuseCreateResponse = + create(endpoint, LangfuseCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LangfuseCreateResponse = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + ): LangfuseCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -37,13 +51,35 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseCreateResponse + /** @see [create] */ + fun create(params: LangfuseCreateParams): LangfuseCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): LangfuseCreateResponse = + create(endpoint, LangfuseCreateParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun retrieve(params: LangfuseRetrieveParams): LangfuseRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): LangfuseRetrieveResponse = + retrieve(endpoint, LangfuseRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LangfuseRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + ): LangfuseRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -51,13 +87,35 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: LangfuseRetrieveParams): LangfuseRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): LangfuseRetrieveResponse = + retrieve(endpoint, LangfuseRetrieveParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun update(params: LangfuseUpdateParams): LangfuseUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): LangfuseUpdateResponse = + update(endpoint, LangfuseUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LangfuseUpdateResponse = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + ): LangfuseUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -65,13 +123,35 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseUpdateResponse + /** @see [update] */ + fun update(params: LangfuseUpdateParams): LangfuseUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): LangfuseUpdateResponse = + update(endpoint, LangfuseUpdateParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun delete(params: LangfuseDeleteParams): LangfuseDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): LangfuseDeleteResponse = + delete(endpoint, LangfuseDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LangfuseDeleteResponse = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + ): LangfuseDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -79,13 +159,33 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseDeleteResponse + /** @see [delete] */ + fun delete(params: LangfuseDeleteParams): LangfuseDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): LangfuseDeleteResponse = + delete(endpoint, LangfuseDeleteParams.none(), requestOptions) + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) */ - fun patch(params: LangfusePatchParams): LangfusePatchResponse = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): LangfusePatchResponse = patch(endpoint, LangfusePatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LangfusePatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + ): LangfusePatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -93,6 +193,14 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): LangfusePatchResponse + /** @see [patch] */ + fun patch(params: LangfusePatchParams): LangfusePatchResponse = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): LangfusePatchResponse = + patch(endpoint, LangfusePatchParams.none(), requestOptions) + /** A view of [LangfuseService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -101,8 +209,24 @@ interface LangfuseService { * [LangfuseService.create]. */ @MustBeClosed - fun create(params: LangfuseCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, LangfuseCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: LangfuseCreateParams = LangfuseCreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -111,13 +235,43 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: LangfuseCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, LangfuseCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseService.retrieve]. */ @MustBeClosed - fun retrieve(params: LangfuseRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, LangfuseRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -126,13 +280,42 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: LangfuseRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, LangfuseRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseService.update]. */ @MustBeClosed - fun update(params: LangfuseUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, LangfuseUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: LangfuseUpdateParams = LangfuseUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -141,13 +324,42 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: LangfuseUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, LangfuseUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /langfuse/{endpoint}`, but is otherwise the same * as [LangfuseService.delete]. */ @MustBeClosed - fun delete(params: LangfuseDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, LangfuseDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: LangfuseDeleteParams = LangfuseDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -156,13 +368,42 @@ interface LangfuseService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: LangfuseDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, LangfuseDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /langfuse/{endpoint}`, but is otherwise the same * as [LangfuseService.patch]. */ @MustBeClosed - fun patch(params: LangfusePatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, LangfusePatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: LangfusePatchParams = LangfusePatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -170,5 +411,18 @@ interface LangfuseService { params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: LangfusePatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, LangfusePatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt index 895ef65b..5a4775b4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.langfuse.LangfuseRetrieveParams import ai.hanzo.api.models.langfuse.LangfuseRetrieveResponse import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import ai.hanzo.api.models.langfuse.LangfuseUpdateResponse +import kotlin.jvm.optionals.getOrNull class LangfuseServiceImpl internal constructor(private val clientOptions: ClientOptions) : LangfuseService { @@ -83,6 +85,9 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client params: LangfuseCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client params: LangfuseRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client params: LangfuseUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client params: LangfuseDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client params: LangfusePatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt index c6f9b100..7ee0a553 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt @@ -29,8 +29,20 @@ interface OpenAIService { /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun create(params: OpenAICreateParams): OpenAICreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): OpenAICreateResponse = create(endpoint, OpenAICreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OpenAICreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + ): OpenAICreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -38,11 +50,33 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): OpenAICreateResponse + /** @see [create] */ + fun create(params: OpenAICreateParams): OpenAICreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): OpenAICreateResponse = + create(endpoint, OpenAICreateParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun retrieve(params: OpenAIRetrieveParams): OpenAIRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): OpenAIRetrieveResponse = + retrieve(endpoint, OpenAIRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OpenAIRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + ): OpenAIRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -50,11 +84,31 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: OpenAIRetrieveParams): OpenAIRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): OpenAIRetrieveResponse = + retrieve(endpoint, OpenAIRetrieveParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun update(params: OpenAIUpdateParams): OpenAIUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): OpenAIUpdateResponse = update(endpoint, OpenAIUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OpenAIUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + ): OpenAIUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -62,11 +116,31 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIUpdateResponse + /** @see [update] */ + fun update(params: OpenAIUpdateParams): OpenAIUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): OpenAIUpdateResponse = + update(endpoint, OpenAIUpdateParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun delete(params: OpenAIDeleteParams): OpenAIDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): OpenAIDeleteResponse = delete(endpoint, OpenAIDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OpenAIDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + ): OpenAIDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -74,10 +148,31 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIDeleteResponse + /** @see [delete] */ + fun delete(params: OpenAIDeleteParams): OpenAIDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): OpenAIDeleteResponse = + delete(endpoint, OpenAIDeleteParams.none(), requestOptions) + /** * Simple pass-through for OpenAI. Use this if you want to directly send a request to OpenAI. */ - fun patch(params: OpenAIPatchParams): OpenAIPatchResponse = patch(params, RequestOptions.none()) + fun patch(endpoint: String): OpenAIPatchResponse = patch(endpoint, OpenAIPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OpenAIPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + ): OpenAIPatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -85,6 +180,13 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIPatchResponse + /** @see [patch] */ + fun patch(params: OpenAIPatchParams): OpenAIPatchResponse = patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): OpenAIPatchResponse = + patch(endpoint, OpenAIPatchParams.none(), requestOptions) + /** A view of [OpenAIService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -95,8 +197,24 @@ interface OpenAIService { * [OpenAIService.create]. */ @MustBeClosed - fun create(params: OpenAICreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, OpenAICreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: OpenAICreateParams = OpenAICreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -105,13 +223,43 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: OpenAICreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, OpenAICreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /openai/{endpoint}`, but is otherwise the same as * [OpenAIService.retrieve]. */ @MustBeClosed - fun retrieve(params: OpenAIRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, OpenAIRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -120,13 +268,42 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: OpenAIRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, OpenAIRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /openai/{endpoint}`, but is otherwise the same as * [OpenAIService.update]. */ @MustBeClosed - fun update(params: OpenAIUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, OpenAIUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: OpenAIUpdateParams = OpenAIUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -135,13 +312,42 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: OpenAIUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, OpenAIUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /openai/{endpoint}`, but is otherwise the same as * [OpenAIService.delete]. */ @MustBeClosed - fun delete(params: OpenAIDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, OpenAIDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: OpenAIDeleteParams = OpenAIDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -150,13 +356,42 @@ interface OpenAIService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: OpenAIDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, OpenAIDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /openai/{endpoint}`, but is otherwise the same as * [OpenAIService.patch]. */ @MustBeClosed - fun patch(params: OpenAIPatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, OpenAIPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: OpenAIPatchParams = OpenAIPatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -164,5 +399,18 @@ interface OpenAIService { params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: OpenAIPatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, OpenAIPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt index 04c9e5e2..acd96040 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -27,6 +28,7 @@ import ai.hanzo.api.models.openai.OpenAIUpdateParams import ai.hanzo.api.models.openai.OpenAIUpdateResponse import ai.hanzo.api.services.blocking.openai.DeploymentService import ai.hanzo.api.services.blocking.openai.DeploymentServiceImpl +import kotlin.jvm.optionals.getOrNull class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOptions) : OpenAIService { @@ -95,6 +97,9 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp params: OpenAICreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -123,6 +128,9 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp params: OpenAIRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -150,6 +158,9 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp params: OpenAIUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -178,6 +189,9 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp params: OpenAIDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -206,6 +220,9 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp params: OpenAIPatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt index d8ef50f6..e4f3f5c9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt @@ -59,8 +59,22 @@ interface ResponseService { * curl -X GET http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer sk-1234" * ``` */ - fun retrieve(params: ResponseRetrieveParams): ResponseRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(responseId: String): ResponseRetrieveResponse = + retrieve(responseId, ResponseRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseRetrieveResponse = + retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + ): ResponseRetrieveResponse = retrieve(responseId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -68,6 +82,14 @@ interface ResponseService { requestOptions: RequestOptions = RequestOptions.none(), ): ResponseRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: ResponseRetrieveParams): ResponseRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(responseId: String, requestOptions: RequestOptions): ResponseRetrieveResponse = + retrieve(responseId, ResponseRetrieveParams.none(), requestOptions) + /** * Delete a response by ID. * @@ -78,8 +100,22 @@ interface ResponseService { * curl -X DELETE http://localhost:4000/v1/responses/resp_abc123 -H "Authorization: Bearer sk-1234" * ``` */ - fun delete(params: ResponseDeleteParams): ResponseDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(responseId: String): ResponseDeleteResponse = + delete(responseId, ResponseDeleteParams.none()) + + /** @see [delete] */ + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseDeleteResponse = + delete(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [delete] */ + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + ): ResponseDeleteResponse = delete(responseId, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -87,6 +123,14 @@ interface ResponseService { requestOptions: RequestOptions = RequestOptions.none(), ): ResponseDeleteResponse + /** @see [delete] */ + fun delete(params: ResponseDeleteParams): ResponseDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(responseId: String, requestOptions: RequestOptions): ResponseDeleteResponse = + delete(responseId, ResponseDeleteParams.none(), requestOptions) + /** A view of [ResponseService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -122,8 +166,25 @@ interface ResponseService { * same as [ResponseService.retrieve]. */ @MustBeClosed - fun retrieve(params: ResponseRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(responseId: String): HttpResponseFor = + retrieve(responseId, ResponseRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + responseId: String, + params: ResponseRetrieveParams = ResponseRetrieveParams.none(), + ): HttpResponseFor = + retrieve(responseId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -132,13 +193,43 @@ interface ResponseService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: ResponseRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + responseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(responseId, ResponseRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /v1/responses/{response_id}`, but is otherwise * the same as [ResponseService.delete]. */ @MustBeClosed - fun delete(params: ResponseDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(responseId: String): HttpResponseFor = + delete(responseId, ResponseDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + responseId: String, + params: ResponseDeleteParams = ResponseDeleteParams.none(), + ): HttpResponseFor = + delete(responseId, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -146,5 +237,18 @@ interface ResponseService { params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [delete] */ + @MustBeClosed + fun delete(params: ResponseDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + responseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(responseId, ResponseDeleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt index c88a5ee7..4c1565d1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import ai.hanzo.api.models.responses.ResponseRetrieveParams import ai.hanzo.api.models.responses.ResponseRetrieveResponse import ai.hanzo.api.services.blocking.responses.InputItemService import ai.hanzo.api.services.blocking.responses.InputItemServiceImpl +import kotlin.jvm.optionals.getOrNull class ResponseServiceImpl internal constructor(private val clientOptions: ClientOptions) : ResponseService { @@ -105,6 +107,9 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client params: ResponseRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("responseId", params.responseId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -132,6 +137,9 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client params: ResponseDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("responseId", params.responseId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt index b455ae96..99dcd4dd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt @@ -280,8 +280,22 @@ interface TeamService { * curl -X POST 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/disable_logging' -H 'Authorization: Bearer sk-1234' * ``` */ - fun disableLogging(params: TeamDisableLoggingParams): TeamDisableLoggingResponse = - disableLogging(params, RequestOptions.none()) + fun disableLogging(teamId: String): TeamDisableLoggingResponse = + disableLogging(teamId, TeamDisableLoggingParams.none()) + + /** @see [disableLogging] */ + fun disableLogging( + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TeamDisableLoggingResponse = + disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [disableLogging] */ + fun disableLogging( + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + ): TeamDisableLoggingResponse = disableLogging(teamId, params, RequestOptions.none()) /** @see [disableLogging] */ fun disableLogging( @@ -289,6 +303,14 @@ interface TeamService { requestOptions: RequestOptions = RequestOptions.none(), ): TeamDisableLoggingResponse + /** @see [disableLogging] */ + fun disableLogging(params: TeamDisableLoggingParams): TeamDisableLoggingResponse = + disableLogging(params, RequestOptions.none()) + + /** @see [disableLogging] */ + fun disableLogging(teamId: String, requestOptions: RequestOptions): TeamDisableLoggingResponse = + disableLogging(teamId, TeamDisableLoggingParams.none(), requestOptions) + /** List Available Teams */ fun listAvailable(): TeamListAvailableResponse = listAvailable(TeamListAvailableParams.none()) @@ -517,10 +539,25 @@ interface TeamService { * the same as [TeamService.disableLogging]. */ @MustBeClosed + fun disableLogging(teamId: String): HttpResponseFor = + disableLogging(teamId, TeamDisableLoggingParams.none()) + + /** @see [disableLogging] */ + @MustBeClosed fun disableLogging( - params: TeamDisableLoggingParams + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - disableLogging(params, RequestOptions.none()) + disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + teamId: String, + params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), + ): HttpResponseFor = + disableLogging(teamId, params, RequestOptions.none()) /** @see [disableLogging] */ @MustBeClosed @@ -529,6 +566,21 @@ interface TeamService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + params: TeamDisableLoggingParams + ): HttpResponseFor = + disableLogging(params, RequestOptions.none()) + + /** @see [disableLogging] */ + @MustBeClosed + fun disableLogging( + teamId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + disableLogging(teamId, TeamDisableLoggingParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /team/available`, but is otherwise the same as * [TeamService.listAvailable]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt index b6712be8..f217ec7b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -43,6 +44,7 @@ import ai.hanzo.api.services.blocking.team.CallbackService import ai.hanzo.api.services.blocking.team.CallbackServiceImpl import ai.hanzo.api.services.blocking.team.ModelService import ai.hanzo.api.services.blocking.team.ModelServiceImpl +import kotlin.jvm.optionals.getOrNull class TeamServiceImpl internal constructor(private val clientOptions: ClientOptions) : TeamService { @@ -325,6 +327,9 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti params: TeamDisableLoggingParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("teamId", params.teamId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt index 6893c7f2..c5719534 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt @@ -49,8 +49,22 @@ interface ThreadService { * * API Reference - https://platform.openai.com/docs/api-reference/threads/getThread */ - fun retrieve(params: ThreadRetrieveParams): ThreadRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(threadId: String): ThreadRetrieveResponse = + retrieve(threadId, ThreadRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ThreadRetrieveResponse = + retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + ): ThreadRetrieveResponse = retrieve(threadId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -58,6 +72,14 @@ interface ThreadService { requestOptions: RequestOptions = RequestOptions.none(), ): ThreadRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: ThreadRetrieveParams): ThreadRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(threadId: String, requestOptions: RequestOptions): ThreadRetrieveResponse = + retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) + /** A view of [ThreadService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -95,8 +117,25 @@ interface ThreadService { * as [ThreadService.retrieve]. */ @MustBeClosed - fun retrieve(params: ThreadRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(threadId: String): HttpResponseFor = + retrieve(threadId, ThreadRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + threadId: String, + params: ThreadRetrieveParams = ThreadRetrieveParams.none(), + ): HttpResponseFor = + retrieve(threadId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -104,5 +143,18 @@ interface ThreadService { params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: ThreadRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + threadId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt index 61b612e0..59212ca4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import ai.hanzo.api.services.blocking.threads.MessageService import ai.hanzo.api.services.blocking.threads.MessageServiceImpl import ai.hanzo.api.services.blocking.threads.RunService import ai.hanzo.api.services.blocking.threads.RunServiceImpl +import kotlin.jvm.optionals.getOrNull class ThreadServiceImpl internal constructor(private val clientOptions: ClientOptions) : ThreadService { @@ -108,6 +110,9 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp params: ThreadRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt index 2efda0d6..721c0b76 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt @@ -28,8 +28,22 @@ interface VertexAiService { * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun create(params: VertexAiCreateParams): VertexAiCreateResponse = - create(params, RequestOptions.none()) + fun create(endpoint: String): VertexAiCreateResponse = + create(endpoint, VertexAiCreateParams.none()) + + /** @see [create] */ + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VertexAiCreateResponse = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + ): VertexAiCreateResponse = create(endpoint, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -37,13 +51,35 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiCreateResponse + /** @see [create] */ + fun create(params: VertexAiCreateParams): VertexAiCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(endpoint: String, requestOptions: RequestOptions): VertexAiCreateResponse = + create(endpoint, VertexAiCreateParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun retrieve(params: VertexAiRetrieveParams): VertexAiRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): VertexAiRetrieveResponse = + retrieve(endpoint, VertexAiRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VertexAiRetrieveResponse = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + ): VertexAiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -51,13 +87,35 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: VertexAiRetrieveParams): VertexAiRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(endpoint: String, requestOptions: RequestOptions): VertexAiRetrieveResponse = + retrieve(endpoint, VertexAiRetrieveParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun update(params: VertexAiUpdateParams): VertexAiUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpoint: String): VertexAiUpdateResponse = + update(endpoint, VertexAiUpdateParams.none()) + + /** @see [update] */ + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VertexAiUpdateResponse = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + ): VertexAiUpdateResponse = update(endpoint, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -65,13 +123,35 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiUpdateResponse + /** @see [update] */ + fun update(params: VertexAiUpdateParams): VertexAiUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(endpoint: String, requestOptions: RequestOptions): VertexAiUpdateResponse = + update(endpoint, VertexAiUpdateParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun delete(params: VertexAiDeleteParams): VertexAiDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): VertexAiDeleteResponse = + delete(endpoint, VertexAiDeleteParams.none()) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VertexAiDeleteResponse = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + ): VertexAiDeleteResponse = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -79,13 +159,33 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiDeleteResponse + /** @see [delete] */ + fun delete(params: VertexAiDeleteParams): VertexAiDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(endpoint: String, requestOptions: RequestOptions): VertexAiDeleteResponse = + delete(endpoint, VertexAiDeleteParams.none(), requestOptions) + /** * Call LLM proxy via Vertex AI SDK. * * [Docs](https://docs.hanzo.ai/docs/pass_through/vertex_ai) */ - fun patch(params: VertexAiPatchParams): VertexAiPatchResponse = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): VertexAiPatchResponse = patch(endpoint, VertexAiPatchParams.none()) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VertexAiPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + ): VertexAiPatchResponse = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ fun patch( @@ -93,6 +193,14 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiPatchResponse + /** @see [patch] */ + fun patch(params: VertexAiPatchParams): VertexAiPatchResponse = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + fun patch(endpoint: String, requestOptions: RequestOptions): VertexAiPatchResponse = + patch(endpoint, VertexAiPatchParams.none(), requestOptions) + /** A view of [VertexAiService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -101,8 +209,24 @@ interface VertexAiService { * as [VertexAiService.create]. */ @MustBeClosed - fun create(params: VertexAiCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(endpoint: String): HttpResponseFor = + create(endpoint, VertexAiCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + params: VertexAiCreateParams = VertexAiCreateParams.none(), + ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -111,13 +235,43 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: VertexAiCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(endpoint, VertexAiCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /vertex_ai/{endpoint}`, but is otherwise the same as * [VertexAiService.retrieve]. */ @MustBeClosed - fun retrieve(params: VertexAiRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(endpoint: String): HttpResponseFor = + retrieve(endpoint, VertexAiRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), + ): HttpResponseFor = + retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -126,13 +280,42 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: VertexAiRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(endpoint, VertexAiRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /vertex_ai/{endpoint}`, but is otherwise the same as * [VertexAiService.update]. */ @MustBeClosed - fun update(params: VertexAiUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(endpoint: String): HttpResponseFor = + update(endpoint, VertexAiUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + params: VertexAiUpdateParams = VertexAiUpdateParams.none(), + ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -141,13 +324,42 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: VertexAiUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpoint, VertexAiUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiService.delete]. */ @MustBeClosed - fun delete(params: VertexAiDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + fun delete(endpoint: String): HttpResponseFor = + delete(endpoint, VertexAiDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + params: VertexAiDeleteParams = VertexAiDeleteParams.none(), + ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -156,13 +368,42 @@ interface VertexAiService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [delete] */ + @MustBeClosed + fun delete(params: VertexAiDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(endpoint, VertexAiDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `patch /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiService.patch]. */ @MustBeClosed - fun patch(params: VertexAiPatchParams): HttpResponseFor = - patch(params, RequestOptions.none()) + fun patch(endpoint: String): HttpResponseFor = + patch(endpoint, VertexAiPatchParams.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + params: VertexAiPatchParams = VertexAiPatchParams.none(), + ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ @MustBeClosed @@ -170,5 +411,18 @@ interface VertexAiService { params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [patch] */ + @MustBeClosed + fun patch(params: VertexAiPatchParams): HttpResponseFor = + patch(params, RequestOptions.none()) + + /** @see [patch] */ + @MustBeClosed + fun patch( + endpoint: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + patch(endpoint, VertexAiPatchParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt index cf98835c..7acf5c1b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import ai.hanzo.api.models.vertexai.VertexAiRetrieveParams import ai.hanzo.api.models.vertexai.VertexAiRetrieveResponse import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import ai.hanzo.api.models.vertexai.VertexAiUpdateResponse +import kotlin.jvm.optionals.getOrNull class VertexAiServiceImpl internal constructor(private val clientOptions: ClientOptions) : VertexAiService { @@ -83,6 +85,9 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client params: VertexAiCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -111,6 +116,9 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client params: VertexAiRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -138,6 +146,9 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client params: VertexAiUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -166,6 +177,9 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client params: VertexAiDeleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -194,6 +208,9 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client params: VertexAiPatchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpoint", params.endpoint().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt index 6844665b..74483f2f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt @@ -28,8 +28,20 @@ interface CancelService { * * ``` */ - fun cancel(params: CancelCancelParams): CancelCancelResponse = - cancel(params, RequestOptions.none()) + fun cancel(batchId: String): CancelCancelResponse = cancel(batchId, CancelCancelParams.none()) + + /** @see [cancel] */ + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CancelCancelResponse = cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancel] */ + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + ): CancelCancelResponse = cancel(batchId, params, RequestOptions.none()) /** @see [cancel] */ fun cancel( @@ -37,6 +49,14 @@ interface CancelService { requestOptions: RequestOptions = RequestOptions.none(), ): CancelCancelResponse + /** @see [cancel] */ + fun cancel(params: CancelCancelParams): CancelCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel(batchId: String, requestOptions: RequestOptions): CancelCancelResponse = + cancel(batchId, CancelCancelParams.none(), requestOptions) + /** A view of [CancelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -45,8 +65,24 @@ interface CancelService { * same as [CancelService.cancel]. */ @MustBeClosed - fun cancel(params: CancelCancelParams): HttpResponseFor = - cancel(params, RequestOptions.none()) + fun cancel(batchId: String): HttpResponseFor = + cancel(batchId, CancelCancelParams.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + batchId: String, + params: CancelCancelParams = CancelCancelParams.none(), + ): HttpResponseFor = cancel(batchId, params, RequestOptions.none()) /** @see [cancel] */ @MustBeClosed @@ -54,5 +90,18 @@ interface CancelService { params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [cancel] */ + @MustBeClosed + fun cancel(params: CancelCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + batchId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(batchId, CancelCancelParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt index d2641010..b01468c5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.batches import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.batches.cancel.CancelCancelParams import ai.hanzo.api.models.batches.cancel.CancelCancelResponse +import kotlin.jvm.optionals.getOrNull class CancelServiceImpl internal constructor(private val clientOptions: ClientOptions) : CancelService { @@ -47,6 +49,9 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp params: CancelCancelParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt index 4f764a82..0ac8654b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt @@ -31,8 +31,22 @@ interface PassThroughEndpointService { ): PassThroughEndpointCreateResponse /** Update a pass-through endpoint */ - fun update(params: PassThroughEndpointUpdateParams): PassThroughEndpointUpdateResponse = - update(params, RequestOptions.none()) + fun update(endpointId: String): PassThroughEndpointUpdateResponse = + update(endpointId, PassThroughEndpointUpdateParams.none()) + + /** @see [update] */ + fun update( + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PassThroughEndpointUpdateResponse = + update(params.toBuilder().endpointId(endpointId).build(), requestOptions) + + /** @see [update] */ + fun update( + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + ): PassThroughEndpointUpdateResponse = update(endpointId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -40,6 +54,17 @@ interface PassThroughEndpointService { requestOptions: RequestOptions = RequestOptions.none(), ): PassThroughEndpointUpdateResponse + /** @see [update] */ + fun update(params: PassThroughEndpointUpdateParams): PassThroughEndpointUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + endpointId: String, + requestOptions: RequestOptions, + ): PassThroughEndpointUpdateResponse = + update(endpointId, PassThroughEndpointUpdateParams.none(), requestOptions) + /** * GET configured pass through endpoint. * @@ -104,10 +129,25 @@ interface PassThroughEndpointService { * is otherwise the same as [PassThroughEndpointService.update]. */ @MustBeClosed + fun update(endpointId: String): HttpResponseFor = + update(endpointId, PassThroughEndpointUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: PassThroughEndpointUpdateParams + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - update(params, RequestOptions.none()) + update(params.toBuilder().endpointId(endpointId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + endpointId: String, + params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), + ): HttpResponseFor = + update(endpointId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -116,6 +156,21 @@ interface PassThroughEndpointService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update( + params: PassThroughEndpointUpdateParams + ): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + endpointId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(endpointId, PassThroughEndpointUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /config/pass_through_endpoint`, but is otherwise the * same as [PassThroughEndpointService.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt index 1b8e5f04..eea09eac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.config import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListPar import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointResponse import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse +import kotlin.jvm.optionals.getOrNull class PassThroughEndpointServiceImpl internal constructor(private val clientOptions: ClientOptions) : PassThroughEndpointService { @@ -101,6 +103,9 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("endpointId", params.endpointId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt index 18436408..c0c66c05 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt @@ -34,8 +34,20 @@ interface ChatService { * }' * ``` */ - fun complete(params: ChatCompleteParams): ChatCompleteResponse = - complete(params, RequestOptions.none()) + fun complete(model: String): ChatCompleteResponse = complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ChatCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): ChatCompleteResponse = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -43,6 +55,14 @@ interface ChatService { requestOptions: RequestOptions = RequestOptions.none(), ): ChatCompleteResponse + /** @see [complete] */ + fun complete(params: ChatCompleteParams): ChatCompleteResponse = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete(model: String, requestOptions: RequestOptions): ChatCompleteResponse = + complete(model, ChatCompleteParams.none(), requestOptions) + /** A view of [ChatService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -51,8 +71,24 @@ interface ChatService { * otherwise the same as [ChatService.complete]. */ @MustBeClosed - fun complete(params: ChatCompleteParams): HttpResponseFor = - complete(params, RequestOptions.none()) + fun complete(model: String): HttpResponseFor = + complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): HttpResponseFor = complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -60,5 +96,18 @@ interface ChatService { params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [complete] */ + @MustBeClosed + fun complete(params: ChatCompleteParams): HttpResponseFor = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + complete(model, ChatCompleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt index 0d635c30..01c5f53b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.engines import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.engines.chat.ChatCompleteParams import ai.hanzo.api.models.engines.chat.ChatCompleteResponse +import kotlin.jvm.optionals.getOrNull class ChatServiceImpl internal constructor(private val clientOptions: ClientOptions) : ChatService { @@ -46,6 +48,9 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti params: ChatCompleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt index 60aea77c..da602fa6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt @@ -29,6 +29,17 @@ interface ContentService { * * ``` */ + fun retrieve(fileId: String, params: ContentRetrieveParams): ContentRetrieveResponse = + retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ContentRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ fun retrieve(params: ContentRetrieveParams): ContentRetrieveResponse = retrieve(params, RequestOptions.none()) @@ -46,6 +57,23 @@ interface ContentService { * otherwise the same as [ContentService.retrieve]. */ @MustBeClosed + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + ): HttpResponseFor = + retrieve(fileId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + fileId: String, + params: ContentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve(params: ContentRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt index c4cb2163..e4bd8ebc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.files import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -16,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.files.content.ContentRetrieveParams import ai.hanzo.api.models.files.content.ContentRetrieveResponse +import kotlin.jvm.optionals.getOrNull class ContentServiceImpl internal constructor(private val clientOptions: ClientOptions) : ContentService { @@ -46,6 +48,9 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO params: ContentRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt index 031821b2..31b1624b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt @@ -56,6 +56,18 @@ interface JobService { * - `custom_llm_provider`: Name of the LLM provider * - `fine_tuning_job_id`: The ID of the fine-tuning job to retrieve. */ + fun retrieve(fineTuningJobId: String, params: JobRetrieveParams): JobRetrieveResponse = + retrieve(fineTuningJobId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): JobRetrieveResponse = + retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [retrieve] */ fun retrieve(params: JobRetrieveParams): JobRetrieveResponse = retrieve(params, RequestOptions.none()) @@ -107,6 +119,23 @@ interface JobService { * otherwise the same as [JobService.retrieve]. */ @MustBeClosed + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + ): HttpResponseFor = + retrieve(fineTuningJobId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + fineTuningJobId: String, + params: JobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve(params: JobRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt index 798a715f..eae05661 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.finetuning import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import ai.hanzo.api.models.finetuning.jobs.JobRetrieveParams import ai.hanzo.api.models.finetuning.jobs.JobRetrieveResponse import ai.hanzo.api.services.blocking.finetuning.jobs.CancelService import ai.hanzo.api.services.blocking.finetuning.jobs.CancelServiceImpl +import kotlin.jvm.optionals.getOrNull class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -100,6 +102,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio params: JobRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fineTuningJobId", params.fineTuningJobId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt index 52d8354a..dec15ec7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt @@ -25,8 +25,22 @@ interface CancelService { * - `custom_llm_provider`: Name of the LLM provider * - `fine_tuning_job_id`: The ID of the fine-tuning job to cancel. */ - fun create(params: CancelCreateParams): CancelCreateResponse = - create(params, RequestOptions.none()) + fun create(fineTuningJobId: String): CancelCreateResponse = + create(fineTuningJobId, CancelCreateParams.none()) + + /** @see [create] */ + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CancelCreateResponse = + create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [create] */ + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + ): CancelCreateResponse = create(fineTuningJobId, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -34,6 +48,14 @@ interface CancelService { requestOptions: RequestOptions = RequestOptions.none(), ): CancelCreateResponse + /** @see [create] */ + fun create(params: CancelCreateParams): CancelCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(fineTuningJobId: String, requestOptions: RequestOptions): CancelCreateResponse = + create(fineTuningJobId, CancelCreateParams.none(), requestOptions) + /** A view of [CancelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -42,8 +64,25 @@ interface CancelService { * but is otherwise the same as [CancelService.create]. */ @MustBeClosed - fun create(params: CancelCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(fineTuningJobId: String): HttpResponseFor = + create(fineTuningJobId, CancelCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + fineTuningJobId: String, + params: CancelCreateParams = CancelCreateParams.none(), + ): HttpResponseFor = + create(fineTuningJobId, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -51,5 +90,18 @@ interface CancelService { params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [create] */ + @MustBeClosed + fun create(params: CancelCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + fineTuningJobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(fineTuningJobId, CancelCreateParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt index 92846de0..a2432999 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.finetuning.jobs import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateResponse +import kotlin.jvm.optionals.getOrNull class CancelServiceImpl internal constructor(private val clientOptions: ClientOptions) : CancelService { @@ -47,6 +49,9 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp params: CancelCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fineTuningJobId", params.fineTuningJobId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt index 6bee352e..35a030ca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt @@ -40,6 +40,17 @@ interface UpdateService { * Raises: ProxyException: For various error conditions including authentication and database * errors */ + fun partial(modelId: String, params: UpdatePartialParams): UpdatePartialResponse = + partial(modelId, params, RequestOptions.none()) + + /** @see [partial] */ + fun partial( + modelId: String, + params: UpdatePartialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UpdatePartialResponse = partial(params.toBuilder().modelId(modelId).build(), requestOptions) + + /** @see [partial] */ fun partial(params: UpdatePartialParams): UpdatePartialResponse = partial(params, RequestOptions.none()) @@ -72,6 +83,22 @@ interface UpdateService { * same as [UpdateService.partial]. */ @MustBeClosed + fun partial( + modelId: String, + params: UpdatePartialParams, + ): HttpResponseFor = partial(modelId, params, RequestOptions.none()) + + /** @see [partial] */ + @MustBeClosed + fun partial( + modelId: String, + params: UpdatePartialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + partial(params.toBuilder().modelId(modelId).build(), requestOptions) + + /** @see [partial] */ + @MustBeClosed fun partial(params: UpdatePartialParams): HttpResponseFor = partial(params, RequestOptions.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt index 476e62c9..7f63037e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.model import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -19,6 +20,7 @@ import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams import ai.hanzo.api.models.model.update.UpdatePartialResponse +import kotlin.jvm.optionals.getOrNull class UpdateServiceImpl internal constructor(private val clientOptions: ClientOptions) : UpdateService { @@ -83,6 +85,9 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp params: UpdatePartialParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("modelId", params.modelId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PATCH) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt index cf34651d..dca21507 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt @@ -36,8 +36,22 @@ interface DeploymentService { * }' * ``` */ - fun complete(params: DeploymentCompleteParams): DeploymentCompleteResponse = - complete(params, RequestOptions.none()) + fun complete(model: String): DeploymentCompleteResponse = + complete(model, DeploymentCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DeploymentCompleteResponse = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + ): DeploymentCompleteResponse = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -45,6 +59,14 @@ interface DeploymentService { requestOptions: RequestOptions = RequestOptions.none(), ): DeploymentCompleteResponse + /** @see [complete] */ + fun complete(params: DeploymentCompleteParams): DeploymentCompleteResponse = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete(model: String, requestOptions: RequestOptions): DeploymentCompleteResponse = + complete(model, DeploymentCompleteParams.none(), requestOptions) + /** * Follows the exact same API spec as `OpenAI's Embeddings API * https://platform.openai.com/docs/api-reference/embeddings` @@ -59,8 +81,20 @@ interface DeploymentService { * }' * ``` */ - fun embed(params: DeploymentEmbedParams): DeploymentEmbedResponse = - embed(params, RequestOptions.none()) + fun embed(model: String): DeploymentEmbedResponse = embed(model, DeploymentEmbedParams.none()) + + /** @see [embed] */ + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DeploymentEmbedResponse = embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + ): DeploymentEmbedResponse = embed(model, params, RequestOptions.none()) /** @see [embed] */ fun embed( @@ -68,6 +102,14 @@ interface DeploymentService { requestOptions: RequestOptions = RequestOptions.none(), ): DeploymentEmbedResponse + /** @see [embed] */ + fun embed(params: DeploymentEmbedParams): DeploymentEmbedResponse = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + fun embed(model: String, requestOptions: RequestOptions): DeploymentEmbedResponse = + embed(model, DeploymentEmbedParams.none(), requestOptions) + /** A view of [DeploymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -78,9 +120,25 @@ interface DeploymentService { * otherwise the same as [DeploymentService.complete]. */ @MustBeClosed + fun complete(model: String): HttpResponseFor = + complete(model, DeploymentCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed fun complete( - params: DeploymentCompleteParams - ): HttpResponseFor = complete(params, RequestOptions.none()) + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: DeploymentCompleteParams = DeploymentCompleteParams.none(), + ): HttpResponseFor = + complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -89,13 +147,43 @@ interface DeploymentService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [complete] */ + @MustBeClosed + fun complete( + params: DeploymentCompleteParams + ): HttpResponseFor = complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + complete(model, DeploymentCompleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /openai/deployments/{model}/embeddings`, but is * otherwise the same as [DeploymentService.embed]. */ @MustBeClosed - fun embed(params: DeploymentEmbedParams): HttpResponseFor = - embed(params, RequestOptions.none()) + fun embed(model: String): HttpResponseFor = + embed(model, DeploymentEmbedParams.none()) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + embed(params.toBuilder().model(model).build(), requestOptions) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + params: DeploymentEmbedParams = DeploymentEmbedParams.none(), + ): HttpResponseFor = embed(model, params, RequestOptions.none()) /** @see [embed] */ @MustBeClosed @@ -103,5 +191,18 @@ interface DeploymentService { params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [embed] */ + @MustBeClosed + fun embed(params: DeploymentEmbedParams): HttpResponseFor = + embed(params, RequestOptions.none()) + + /** @see [embed] */ + @MustBeClosed + fun embed( + model: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + embed(model, DeploymentEmbedParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt index 29b5820e..ae4161c2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.openai import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import ai.hanzo.api.models.openai.deployments.DeploymentEmbedParams import ai.hanzo.api.models.openai.deployments.DeploymentEmbedResponse import ai.hanzo.api.services.blocking.openai.deployments.ChatService import ai.hanzo.api.services.blocking.openai.deployments.ChatServiceImpl +import kotlin.jvm.optionals.getOrNull class DeploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : DeploymentService { @@ -68,6 +70,9 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie params: DeploymentCompleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -96,6 +101,9 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie params: DeploymentEmbedParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt index 8f32e66b..f6be7bad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt @@ -34,8 +34,20 @@ interface ChatService { * }' * ``` */ - fun complete(params: ChatCompleteParams): ChatCompleteResponse = - complete(params, RequestOptions.none()) + fun complete(model: String): ChatCompleteResponse = complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ChatCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): ChatCompleteResponse = complete(model, params, RequestOptions.none()) /** @see [complete] */ fun complete( @@ -43,6 +55,14 @@ interface ChatService { requestOptions: RequestOptions = RequestOptions.none(), ): ChatCompleteResponse + /** @see [complete] */ + fun complete(params: ChatCompleteParams): ChatCompleteResponse = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + fun complete(model: String, requestOptions: RequestOptions): ChatCompleteResponse = + complete(model, ChatCompleteParams.none(), requestOptions) + /** A view of [ChatService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -51,8 +71,24 @@ interface ChatService { * is otherwise the same as [ChatService.complete]. */ @MustBeClosed - fun complete(params: ChatCompleteParams): HttpResponseFor = - complete(params, RequestOptions.none()) + fun complete(model: String): HttpResponseFor = + complete(model, ChatCompleteParams.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + complete(params.toBuilder().model(model).build(), requestOptions) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + params: ChatCompleteParams = ChatCompleteParams.none(), + ): HttpResponseFor = complete(model, params, RequestOptions.none()) /** @see [complete] */ @MustBeClosed @@ -60,5 +96,18 @@ interface ChatService { params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [complete] */ + @MustBeClosed + fun complete(params: ChatCompleteParams): HttpResponseFor = + complete(params, RequestOptions.none()) + + /** @see [complete] */ + @MustBeClosed + fun complete( + model: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + complete(model, ChatCompleteParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt index c90bdc7c..2387541b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.openai.deployments import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteResponse +import kotlin.jvm.optionals.getOrNull class ChatServiceImpl internal constructor(private val clientOptions: ClientOptions) : ChatService { @@ -46,6 +48,9 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti params: ChatCompleteParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("model", params.model().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt index ce55b8cc..e737f888 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt @@ -25,8 +25,22 @@ interface InputItemService { * curl -X GET http://localhost:4000/v1/responses/resp_abc123/input_items -H "Authorization: Bearer sk-1234" * ``` */ - fun list(params: InputItemListParams): InputItemListResponse = - list(params, RequestOptions.none()) + fun list(responseId: String): InputItemListResponse = + list(responseId, InputItemListParams.none()) + + /** @see [list] */ + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InputItemListResponse = + list(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [list] */ + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + ): InputItemListResponse = list(responseId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -34,6 +48,14 @@ interface InputItemService { requestOptions: RequestOptions = RequestOptions.none(), ): InputItemListResponse + /** @see [list] */ + fun list(params: InputItemListParams): InputItemListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(responseId: String, requestOptions: RequestOptions): InputItemListResponse = + list(responseId, InputItemListParams.none(), requestOptions) + /** A view of [InputItemService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -42,8 +64,24 @@ interface InputItemService { * otherwise the same as [InputItemService.list]. */ @MustBeClosed - fun list(params: InputItemListParams): HttpResponseFor = - list(params, RequestOptions.none()) + fun list(responseId: String): HttpResponseFor = + list(responseId, InputItemListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().responseId(responseId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + responseId: String, + params: InputItemListParams = InputItemListParams.none(), + ): HttpResponseFor = list(responseId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -51,5 +89,18 @@ interface InputItemService { params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: InputItemListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + responseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(responseId, InputItemListParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt index 7c204a15..47eb7f7d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.responses import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -16,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.responses.inputitems.InputItemListParams import ai.hanzo.api.models.responses.inputitems.InputItemListResponse +import kotlin.jvm.optionals.getOrNull class InputItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : InputItemService { @@ -46,6 +48,9 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien params: InputItemListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("responseId", params.responseId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt index 9351b9eb..6c558863 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt @@ -36,8 +36,22 @@ interface CallbackService { * team_callback_settings_obj.failure_callback, "callback_vars": * team_callback_settings_obj.callback_vars, }, } */ - fun retrieve(params: CallbackRetrieveParams): CallbackRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(teamId: String): CallbackRetrieveResponse = + retrieve(teamId, CallbackRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CallbackRetrieveResponse = + retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + ): CallbackRetrieveResponse = retrieve(teamId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -45,6 +59,14 @@ interface CallbackService { requestOptions: RequestOptions = RequestOptions.none(), ): CallbackRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: CallbackRetrieveParams): CallbackRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(teamId: String, requestOptions: RequestOptions): CallbackRetrieveResponse = + retrieve(teamId, CallbackRetrieveParams.none(), requestOptions) + /** * Add a success/failure callback to a team * @@ -83,6 +105,17 @@ interface CallbackService { * This means for the team where team_id = dbe2f686-a686-4896-864a-4c3924458709, all LLM calls * will be logged to langfuse using the public key pk-lf-xxxx1 and the secret key sk-xxxxx */ + fun add(teamId: String, params: CallbackAddParams): CallbackAddResponse = + add(teamId, params, RequestOptions.none()) + + /** @see [add] */ + fun add( + teamId: String, + params: CallbackAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CallbackAddResponse = add(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [add] */ fun add(params: CallbackAddParams): CallbackAddResponse = add(params, RequestOptions.none()) /** @see [add] */ @@ -99,8 +132,25 @@ interface CallbackService { * as [CallbackService.retrieve]. */ @MustBeClosed - fun retrieve(params: CallbackRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(teamId: String): HttpResponseFor = + retrieve(teamId, CallbackRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + teamId: String, + params: CallbackRetrieveParams = CallbackRetrieveParams.none(), + ): HttpResponseFor = + retrieve(teamId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -109,11 +159,38 @@ interface CallbackService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: CallbackRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + teamId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(teamId, CallbackRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /team/{team_id}/callback`, but is otherwise the * same as [CallbackService.add]. */ @MustBeClosed + fun add(teamId: String, params: CallbackAddParams): HttpResponseFor = + add(teamId, params, RequestOptions.none()) + + /** @see [add] */ + @MustBeClosed + fun add( + teamId: String, + params: CallbackAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + add(params.toBuilder().teamId(teamId).build(), requestOptions) + + /** @see [add] */ + @MustBeClosed fun add(params: CallbackAddParams): HttpResponseFor = add(params, RequestOptions.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt index 0b9ecc0e..e4e33bfe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.team import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -19,6 +20,7 @@ import ai.hanzo.api.models.team.callback.CallbackAddParams import ai.hanzo.api.models.team.callback.CallbackAddResponse import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import ai.hanzo.api.models.team.callback.CallbackRetrieveResponse +import kotlin.jvm.optionals.getOrNull class CallbackServiceImpl internal constructor(private val clientOptions: ClientOptions) : CallbackService { @@ -56,6 +58,9 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client params: CallbackRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("teamId", params.teamId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -83,6 +88,9 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client params: CallbackAddParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("teamId", params.teamId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt index b6877f9b..fca14c5c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt @@ -22,8 +22,21 @@ interface MessageService { * * API Reference - https://platform.openai.com/docs/api-reference/messages/createMessage */ - fun create(params: MessageCreateParams): MessageCreateResponse = - create(params, RequestOptions.none()) + fun create(threadId: String): MessageCreateResponse = + create(threadId, MessageCreateParams.none()) + + /** @see [create] */ + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageCreateResponse = create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + ): MessageCreateResponse = create(threadId, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -31,12 +44,33 @@ interface MessageService { requestOptions: RequestOptions = RequestOptions.none(), ): MessageCreateResponse + /** @see [create] */ + fun create(params: MessageCreateParams): MessageCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(threadId: String, requestOptions: RequestOptions): MessageCreateResponse = + create(threadId, MessageCreateParams.none(), requestOptions) + /** * Returns a list of messages for a given thread. * * API Reference - https://platform.openai.com/docs/api-reference/messages/listMessages */ - fun list(params: MessageListParams): MessageListResponse = list(params, RequestOptions.none()) + fun list(threadId: String): MessageListResponse = list(threadId, MessageListParams.none()) + + /** @see [list] */ + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageListResponse = list(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [list] */ + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + ): MessageListResponse = list(threadId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -44,6 +78,13 @@ interface MessageService { requestOptions: RequestOptions = RequestOptions.none(), ): MessageListResponse + /** @see [list] */ + fun list(params: MessageListParams): MessageListResponse = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(threadId: String, requestOptions: RequestOptions): MessageListResponse = + list(threadId, MessageListParams.none(), requestOptions) + /** A view of [MessageService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -52,8 +93,24 @@ interface MessageService { * the same as [MessageService.create]. */ @MustBeClosed - fun create(params: MessageCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(threadId: String): HttpResponseFor = + create(threadId, MessageCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: MessageCreateParams = MessageCreateParams.none(), + ): HttpResponseFor = create(threadId, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -62,13 +119,42 @@ interface MessageService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [create] */ + @MustBeClosed + fun create(params: MessageCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(threadId, MessageCreateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /v1/threads/{thread_id}/messages`, but is otherwise * the same as [MessageService.list]. */ @MustBeClosed - fun list(params: MessageListParams): HttpResponseFor = - list(params, RequestOptions.none()) + fun list(threadId: String): HttpResponseFor = + list(threadId, MessageListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + threadId: String, + params: MessageListParams = MessageListParams.none(), + ): HttpResponseFor = list(threadId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -76,5 +162,18 @@ interface MessageService { params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: MessageListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + threadId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(threadId, MessageListParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt index ae63719f..94573bdf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.threads import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -19,6 +20,7 @@ import ai.hanzo.api.models.threads.messages.MessageCreateParams import ai.hanzo.api.models.threads.messages.MessageCreateResponse import ai.hanzo.api.models.threads.messages.MessageListParams import ai.hanzo.api.models.threads.messages.MessageListResponse +import kotlin.jvm.optionals.getOrNull class MessageServiceImpl internal constructor(private val clientOptions: ClientOptions) : MessageService { @@ -56,6 +58,9 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO params: MessageCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -84,6 +89,9 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO params: MessageListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt index bf2d325c..06a92975 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt @@ -20,7 +20,20 @@ interface RunService { * * API Reference: https://platform.openai.com/docs/api-reference/runs/createRun */ - fun create(params: RunCreateParams): RunCreateResponse = create(params, RequestOptions.none()) + fun create(threadId: String): RunCreateResponse = create(threadId, RunCreateParams.none()) + + /** @see [create] */ + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunCreateResponse = create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + ): RunCreateResponse = create(threadId, params, RequestOptions.none()) /** @see [create] */ fun create( @@ -28,6 +41,13 @@ interface RunService { requestOptions: RequestOptions = RequestOptions.none(), ): RunCreateResponse + /** @see [create] */ + fun create(params: RunCreateParams): RunCreateResponse = create(params, RequestOptions.none()) + + /** @see [create] */ + fun create(threadId: String, requestOptions: RequestOptions): RunCreateResponse = + create(threadId, RunCreateParams.none(), requestOptions) + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -36,8 +56,24 @@ interface RunService { * same as [RunService.create]. */ @MustBeClosed - fun create(params: RunCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + fun create(threadId: String): HttpResponseFor = + create(threadId, RunCreateParams.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().threadId(threadId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + params: RunCreateParams = RunCreateParams.none(), + ): HttpResponseFor = create(threadId, params, RequestOptions.none()) /** @see [create] */ @MustBeClosed @@ -45,5 +81,18 @@ interface RunService { params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [create] */ + @MustBeClosed + fun create(params: RunCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + threadId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(threadId, RunCreateParams.none(), requestOptions) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt index 8b22e877..7f1d1195 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.threads import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler import ai.hanzo.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.threads.runs.RunCreateParams import ai.hanzo.api.models.threads.runs.RunCreateResponse +import kotlin.jvm.optionals.getOrNull class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { @@ -45,6 +47,9 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio params: RunCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("threadId", params.threadId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt index 4223f50f..6b1066e9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.anthropic.AnthropicCreateParams -import ai.hanzo.api.models.anthropic.AnthropicDeleteParams -import ai.hanzo.api.models.anthropic.AnthropicModifyParams -import ai.hanzo.api.models.anthropic.AnthropicRetrieveParams -import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,10 +21,7 @@ internal class AnthropicServiceAsyncTest { .build() val anthropicServiceAsync = client.anthropic() - val anthropicFuture = - anthropicServiceAsync.create( - AnthropicCreateParams.builder().endpoint("endpoint").build() - ) + val anthropicFuture = anthropicServiceAsync.create("endpoint") val anthropic = anthropicFuture.get() anthropic.validate() @@ -45,10 +37,7 @@ internal class AnthropicServiceAsyncTest { .build() val anthropicServiceAsync = client.anthropic() - val anthropicFuture = - anthropicServiceAsync.retrieve( - AnthropicRetrieveParams.builder().endpoint("endpoint").build() - ) + val anthropicFuture = anthropicServiceAsync.retrieve("endpoint") val anthropic = anthropicFuture.get() anthropic.validate() @@ -64,10 +53,7 @@ internal class AnthropicServiceAsyncTest { .build() val anthropicServiceAsync = client.anthropic() - val anthropicFuture = - anthropicServiceAsync.update( - AnthropicUpdateParams.builder().endpoint("endpoint").build() - ) + val anthropicFuture = anthropicServiceAsync.update("endpoint") val anthropic = anthropicFuture.get() anthropic.validate() @@ -83,10 +69,7 @@ internal class AnthropicServiceAsyncTest { .build() val anthropicServiceAsync = client.anthropic() - val anthropicFuture = - anthropicServiceAsync.delete( - AnthropicDeleteParams.builder().endpoint("endpoint").build() - ) + val anthropicFuture = anthropicServiceAsync.delete("endpoint") val anthropic = anthropicFuture.get() anthropic.validate() @@ -102,10 +85,7 @@ internal class AnthropicServiceAsyncTest { .build() val anthropicServiceAsync = client.anthropic() - val responseFuture = - anthropicServiceAsync.modify( - AnthropicModifyParams.builder().endpoint("endpoint").build() - ) + val responseFuture = anthropicServiceAsync.modify("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt index c6ce091d..ebaeb075 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.assemblyai.AssemblyaiCreateParams -import ai.hanzo.api.models.assemblyai.AssemblyaiDeleteParams -import ai.hanzo.api.models.assemblyai.AssemblyaiPatchParams -import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveParams -import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,10 +21,7 @@ internal class AssemblyaiServiceAsyncTest { .build() val assemblyaiServiceAsync = client.assemblyai() - val assemblyaiFuture = - assemblyaiServiceAsync.create( - AssemblyaiCreateParams.builder().endpoint("endpoint").build() - ) + val assemblyaiFuture = assemblyaiServiceAsync.create("endpoint") val assemblyai = assemblyaiFuture.get() assemblyai.validate() @@ -45,10 +37,7 @@ internal class AssemblyaiServiceAsyncTest { .build() val assemblyaiServiceAsync = client.assemblyai() - val assemblyaiFuture = - assemblyaiServiceAsync.retrieve( - AssemblyaiRetrieveParams.builder().endpoint("endpoint").build() - ) + val assemblyaiFuture = assemblyaiServiceAsync.retrieve("endpoint") val assemblyai = assemblyaiFuture.get() assemblyai.validate() @@ -64,10 +53,7 @@ internal class AssemblyaiServiceAsyncTest { .build() val assemblyaiServiceAsync = client.assemblyai() - val assemblyaiFuture = - assemblyaiServiceAsync.update( - AssemblyaiUpdateParams.builder().endpoint("endpoint").build() - ) + val assemblyaiFuture = assemblyaiServiceAsync.update("endpoint") val assemblyai = assemblyaiFuture.get() assemblyai.validate() @@ -83,10 +69,7 @@ internal class AssemblyaiServiceAsyncTest { .build() val assemblyaiServiceAsync = client.assemblyai() - val assemblyaiFuture = - assemblyaiServiceAsync.delete( - AssemblyaiDeleteParams.builder().endpoint("endpoint").build() - ) + val assemblyaiFuture = assemblyaiServiceAsync.delete("endpoint") val assemblyai = assemblyaiFuture.get() assemblyai.validate() @@ -102,10 +85,7 @@ internal class AssemblyaiServiceAsyncTest { .build() val assemblyaiServiceAsync = client.assemblyai() - val responseFuture = - assemblyaiServiceAsync.patch( - AssemblyaiPatchParams.builder().endpoint("endpoint").build() - ) + val responseFuture = assemblyaiServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt index 91cd4c4d..afe1334c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.assistants.AssistantDeleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -54,10 +53,7 @@ internal class AssistantServiceAsyncTest { .build() val assistantServiceAsync = client.assistants() - val assistantFuture = - assistantServiceAsync.delete( - AssistantDeleteParams.builder().assistantId("assistant_id").build() - ) + val assistantFuture = assistantServiceAsync.delete("assistant_id") val assistant = assistantFuture.get() assistant.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt index df546006..58613f1f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.azure.AzureCallParams -import ai.hanzo.api.models.azure.AzureCreateParams -import ai.hanzo.api.models.azure.AzureDeleteParams -import ai.hanzo.api.models.azure.AzurePatchParams -import ai.hanzo.api.models.azure.AzureUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class AzureServiceAsyncTest { .build() val azureServiceAsync = client.azure() - val azureFuture = - azureServiceAsync.create(AzureCreateParams.builder().endpoint("endpoint").build()) + val azureFuture = azureServiceAsync.create("endpoint") val azure = azureFuture.get() azure.validate() @@ -43,8 +37,7 @@ internal class AzureServiceAsyncTest { .build() val azureServiceAsync = client.azure() - val azureFuture = - azureServiceAsync.update(AzureUpdateParams.builder().endpoint("endpoint").build()) + val azureFuture = azureServiceAsync.update("endpoint") val azure = azureFuture.get() azure.validate() @@ -60,8 +53,7 @@ internal class AzureServiceAsyncTest { .build() val azureServiceAsync = client.azure() - val azureFuture = - azureServiceAsync.delete(AzureDeleteParams.builder().endpoint("endpoint").build()) + val azureFuture = azureServiceAsync.delete("endpoint") val azure = azureFuture.get() azure.validate() @@ -77,8 +69,7 @@ internal class AzureServiceAsyncTest { .build() val azureServiceAsync = client.azure() - val responseFuture = - azureServiceAsync.call(AzureCallParams.builder().endpoint("endpoint").build()) + val responseFuture = azureServiceAsync.call("endpoint") val response = responseFuture.get() response.validate() @@ -94,8 +85,7 @@ internal class AzureServiceAsyncTest { .build() val azureServiceAsync = client.azure() - val responseFuture = - azureServiceAsync.patch(AzurePatchParams.builder().endpoint("endpoint").build()) + val responseFuture = azureServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt index c4da6505..a4d875e2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt @@ -6,7 +6,6 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.models.batches.BatchCancelWithProviderParams import ai.hanzo.api.models.batches.BatchCreateParams -import ai.hanzo.api.models.batches.BatchCreateWithProviderParams import ai.hanzo.api.models.batches.BatchListParams import ai.hanzo.api.models.batches.BatchListWithProviderParams import ai.hanzo.api.models.batches.BatchRetrieveParams @@ -105,10 +104,7 @@ internal class BatchServiceAsyncTest { .build() val batchServiceAsync = client.batches() - val responseFuture = - batchServiceAsync.createWithProvider( - BatchCreateWithProviderParams.builder().provider("provider").build() - ) + val responseFuture = batchServiceAsync.createWithProvider("provider") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt index 8a07183d..d4ab0f1a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.bedrock.BedrockCreateParams -import ai.hanzo.api.models.bedrock.BedrockDeleteParams -import ai.hanzo.api.models.bedrock.BedrockPatchParams -import ai.hanzo.api.models.bedrock.BedrockRetrieveParams -import ai.hanzo.api.models.bedrock.BedrockUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class BedrockServiceAsyncTest { .build() val bedrockServiceAsync = client.bedrock() - val bedrockFuture = - bedrockServiceAsync.create(BedrockCreateParams.builder().endpoint("endpoint").build()) + val bedrockFuture = bedrockServiceAsync.create("endpoint") val bedrock = bedrockFuture.get() bedrock.validate() @@ -43,10 +37,7 @@ internal class BedrockServiceAsyncTest { .build() val bedrockServiceAsync = client.bedrock() - val bedrockFuture = - bedrockServiceAsync.retrieve( - BedrockRetrieveParams.builder().endpoint("endpoint").build() - ) + val bedrockFuture = bedrockServiceAsync.retrieve("endpoint") val bedrock = bedrockFuture.get() bedrock.validate() @@ -62,8 +53,7 @@ internal class BedrockServiceAsyncTest { .build() val bedrockServiceAsync = client.bedrock() - val bedrockFuture = - bedrockServiceAsync.update(BedrockUpdateParams.builder().endpoint("endpoint").build()) + val bedrockFuture = bedrockServiceAsync.update("endpoint") val bedrock = bedrockFuture.get() bedrock.validate() @@ -79,8 +69,7 @@ internal class BedrockServiceAsyncTest { .build() val bedrockServiceAsync = client.bedrock() - val bedrockFuture = - bedrockServiceAsync.delete(BedrockDeleteParams.builder().endpoint("endpoint").build()) + val bedrockFuture = bedrockServiceAsync.delete("endpoint") val bedrock = bedrockFuture.get() bedrock.validate() @@ -96,8 +85,7 @@ internal class BedrockServiceAsyncTest { .build() val bedrockServiceAsync = client.bedrock() - val responseFuture = - bedrockServiceAsync.patch(BedrockPatchParams.builder().endpoint("endpoint").build()) + val responseFuture = bedrockServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt index 8533f5e4..edf1cf7e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.cohere.CohereCreateParams -import ai.hanzo.api.models.cohere.CohereDeleteParams -import ai.hanzo.api.models.cohere.CohereModifyParams -import ai.hanzo.api.models.cohere.CohereRetrieveParams -import ai.hanzo.api.models.cohere.CohereUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class CohereServiceAsyncTest { .build() val cohereServiceAsync = client.cohere() - val cohereFuture = - cohereServiceAsync.create(CohereCreateParams.builder().endpoint("endpoint").build()) + val cohereFuture = cohereServiceAsync.create("endpoint") val cohere = cohereFuture.get() cohere.validate() @@ -43,8 +37,7 @@ internal class CohereServiceAsyncTest { .build() val cohereServiceAsync = client.cohere() - val cohereFuture = - cohereServiceAsync.retrieve(CohereRetrieveParams.builder().endpoint("endpoint").build()) + val cohereFuture = cohereServiceAsync.retrieve("endpoint") val cohere = cohereFuture.get() cohere.validate() @@ -60,8 +53,7 @@ internal class CohereServiceAsyncTest { .build() val cohereServiceAsync = client.cohere() - val cohereFuture = - cohereServiceAsync.update(CohereUpdateParams.builder().endpoint("endpoint").build()) + val cohereFuture = cohereServiceAsync.update("endpoint") val cohere = cohereFuture.get() cohere.validate() @@ -77,8 +69,7 @@ internal class CohereServiceAsyncTest { .build() val cohereServiceAsync = client.cohere() - val cohereFuture = - cohereServiceAsync.delete(CohereDeleteParams.builder().endpoint("endpoint").build()) + val cohereFuture = cohereServiceAsync.delete("endpoint") val cohere = cohereFuture.get() cohere.validate() @@ -94,8 +85,7 @@ internal class CohereServiceAsyncTest { .build() val cohereServiceAsync = client.cohere() - val responseFuture = - cohereServiceAsync.modify(CohereModifyParams.builder().endpoint("endpoint").build()) + val responseFuture = cohereServiceAsync.modify("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt index 1fcbea52..ade95815 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt @@ -6,7 +6,6 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.credentials.CredentialCreateParams -import ai.hanzo.api.models.credentials.CredentialDeleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -64,10 +63,7 @@ internal class CredentialServiceAsyncTest { .build() val credentialServiceAsync = client.credentials() - val credentialFuture = - credentialServiceAsync.delete( - CredentialDeleteParams.builder().credentialName("credential_name").build() - ) + val credentialFuture = credentialServiceAsync.delete("credential_name") val credential = credentialFuture.get() credential.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt index 7e5d71c9..a53640b0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.engines.EngineCompleteParams -import ai.hanzo.api.models.engines.EngineEmbedParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,8 +21,7 @@ internal class EngineServiceAsyncTest { .build() val engineServiceAsync = client.engines() - val responseFuture = - engineServiceAsync.complete(EngineCompleteParams.builder().model("model").build()) + val responseFuture = engineServiceAsync.complete("model") val response = responseFuture.get() response.validate() @@ -40,8 +37,7 @@ internal class EngineServiceAsyncTest { .build() val engineServiceAsync = client.engines() - val responseFuture = - engineServiceAsync.embed(EngineEmbedParams.builder().model("model").build()) + val responseFuture = engineServiceAsync.embed("model") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt index 271ffdac..068672da 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiCreateParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiDeleteParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiPatchParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,10 +21,7 @@ internal class EuAssemblyaiServiceAsyncTest { .build() val euAssemblyaiServiceAsync = client.euAssemblyai() - val euAssemblyaiFuture = - euAssemblyaiServiceAsync.create( - EuAssemblyaiCreateParams.builder().endpoint("endpoint").build() - ) + val euAssemblyaiFuture = euAssemblyaiServiceAsync.create("endpoint") val euAssemblyai = euAssemblyaiFuture.get() euAssemblyai.validate() @@ -45,10 +37,7 @@ internal class EuAssemblyaiServiceAsyncTest { .build() val euAssemblyaiServiceAsync = client.euAssemblyai() - val euAssemblyaiFuture = - euAssemblyaiServiceAsync.retrieve( - EuAssemblyaiRetrieveParams.builder().endpoint("endpoint").build() - ) + val euAssemblyaiFuture = euAssemblyaiServiceAsync.retrieve("endpoint") val euAssemblyai = euAssemblyaiFuture.get() euAssemblyai.validate() @@ -64,10 +53,7 @@ internal class EuAssemblyaiServiceAsyncTest { .build() val euAssemblyaiServiceAsync = client.euAssemblyai() - val euAssemblyaiFuture = - euAssemblyaiServiceAsync.update( - EuAssemblyaiUpdateParams.builder().endpoint("endpoint").build() - ) + val euAssemblyaiFuture = euAssemblyaiServiceAsync.update("endpoint") val euAssemblyai = euAssemblyaiFuture.get() euAssemblyai.validate() @@ -83,10 +69,7 @@ internal class EuAssemblyaiServiceAsyncTest { .build() val euAssemblyaiServiceAsync = client.euAssemblyai() - val euAssemblyaiFuture = - euAssemblyaiServiceAsync.delete( - EuAssemblyaiDeleteParams.builder().endpoint("endpoint").build() - ) + val euAssemblyaiFuture = euAssemblyaiServiceAsync.delete("endpoint") val euAssemblyai = euAssemblyaiFuture.get() euAssemblyai.validate() @@ -102,10 +85,7 @@ internal class EuAssemblyaiServiceAsyncTest { .build() val euAssemblyaiServiceAsync = client.euAssemblyai() - val responseFuture = - euAssemblyaiServiceAsync.patch( - EuAssemblyaiPatchParams.builder().endpoint("endpoint").build() - ) + val responseFuture = euAssemblyaiServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt index 9d2c7a20..86243cb0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.gemini.GeminiCreateParams -import ai.hanzo.api.models.gemini.GeminiDeleteParams -import ai.hanzo.api.models.gemini.GeminiPatchParams -import ai.hanzo.api.models.gemini.GeminiRetrieveParams -import ai.hanzo.api.models.gemini.GeminiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class GeminiServiceAsyncTest { .build() val geminiServiceAsync = client.gemini() - val geminiFuture = - geminiServiceAsync.create(GeminiCreateParams.builder().endpoint("endpoint").build()) + val geminiFuture = geminiServiceAsync.create("endpoint") val gemini = geminiFuture.get() gemini.validate() @@ -43,8 +37,7 @@ internal class GeminiServiceAsyncTest { .build() val geminiServiceAsync = client.gemini() - val geminiFuture = - geminiServiceAsync.retrieve(GeminiRetrieveParams.builder().endpoint("endpoint").build()) + val geminiFuture = geminiServiceAsync.retrieve("endpoint") val gemini = geminiFuture.get() gemini.validate() @@ -60,8 +53,7 @@ internal class GeminiServiceAsyncTest { .build() val geminiServiceAsync = client.gemini() - val geminiFuture = - geminiServiceAsync.update(GeminiUpdateParams.builder().endpoint("endpoint").build()) + val geminiFuture = geminiServiceAsync.update("endpoint") val gemini = geminiFuture.get() gemini.validate() @@ -77,8 +69,7 @@ internal class GeminiServiceAsyncTest { .build() val geminiServiceAsync = client.gemini() - val geminiFuture = - geminiServiceAsync.delete(GeminiDeleteParams.builder().endpoint("endpoint").build()) + val geminiFuture = geminiServiceAsync.delete("endpoint") val gemini = geminiFuture.get() gemini.validate() @@ -94,8 +85,7 @@ internal class GeminiServiceAsyncTest { .build() val geminiServiceAsync = client.gemini() - val responseFuture = - geminiServiceAsync.patch(GeminiPatchParams.builder().endpoint("endpoint").build()) + val responseFuture = geminiServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt index b7820438..953b2427 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.langfuse.LangfuseCreateParams -import ai.hanzo.api.models.langfuse.LangfuseDeleteParams -import ai.hanzo.api.models.langfuse.LangfusePatchParams -import ai.hanzo.api.models.langfuse.LangfuseRetrieveParams -import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class LangfuseServiceAsyncTest { .build() val langfuseServiceAsync = client.langfuse() - val langfuseFuture = - langfuseServiceAsync.create(LangfuseCreateParams.builder().endpoint("endpoint").build()) + val langfuseFuture = langfuseServiceAsync.create("endpoint") val langfuse = langfuseFuture.get() langfuse.validate() @@ -43,10 +37,7 @@ internal class LangfuseServiceAsyncTest { .build() val langfuseServiceAsync = client.langfuse() - val langfuseFuture = - langfuseServiceAsync.retrieve( - LangfuseRetrieveParams.builder().endpoint("endpoint").build() - ) + val langfuseFuture = langfuseServiceAsync.retrieve("endpoint") val langfuse = langfuseFuture.get() langfuse.validate() @@ -62,8 +53,7 @@ internal class LangfuseServiceAsyncTest { .build() val langfuseServiceAsync = client.langfuse() - val langfuseFuture = - langfuseServiceAsync.update(LangfuseUpdateParams.builder().endpoint("endpoint").build()) + val langfuseFuture = langfuseServiceAsync.update("endpoint") val langfuse = langfuseFuture.get() langfuse.validate() @@ -79,8 +69,7 @@ internal class LangfuseServiceAsyncTest { .build() val langfuseServiceAsync = client.langfuse() - val langfuseFuture = - langfuseServiceAsync.delete(LangfuseDeleteParams.builder().endpoint("endpoint").build()) + val langfuseFuture = langfuseServiceAsync.delete("endpoint") val langfuse = langfuseFuture.get() langfuse.validate() @@ -96,8 +85,7 @@ internal class LangfuseServiceAsyncTest { .build() val langfuseServiceAsync = client.langfuse() - val responseFuture = - langfuseServiceAsync.patch(LangfusePatchParams.builder().endpoint("endpoint").build()) + val responseFuture = langfuseServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt index 5d573616..0d4b5d03 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.openai.OpenAICreateParams -import ai.hanzo.api.models.openai.OpenAIDeleteParams -import ai.hanzo.api.models.openai.OpenAIPatchParams -import ai.hanzo.api.models.openai.OpenAIRetrieveParams -import ai.hanzo.api.models.openai.OpenAIUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class OpenAIServiceAsyncTest { .build() val openaiServiceAsync = client.openai() - val openaiFuture = - openaiServiceAsync.create(OpenAICreateParams.builder().endpoint("endpoint").build()) + val openaiFuture = openaiServiceAsync.create("endpoint") val openai = openaiFuture.get() openai.validate() @@ -43,8 +37,7 @@ internal class OpenAIServiceAsyncTest { .build() val openaiServiceAsync = client.openai() - val openaiFuture = - openaiServiceAsync.retrieve(OpenAIRetrieveParams.builder().endpoint("endpoint").build()) + val openaiFuture = openaiServiceAsync.retrieve("endpoint") val openai = openaiFuture.get() openai.validate() @@ -60,8 +53,7 @@ internal class OpenAIServiceAsyncTest { .build() val openaiServiceAsync = client.openai() - val openaiFuture = - openaiServiceAsync.update(OpenAIUpdateParams.builder().endpoint("endpoint").build()) + val openaiFuture = openaiServiceAsync.update("endpoint") val openai = openaiFuture.get() openai.validate() @@ -77,8 +69,7 @@ internal class OpenAIServiceAsyncTest { .build() val openaiServiceAsync = client.openai() - val openaiFuture = - openaiServiceAsync.delete(OpenAIDeleteParams.builder().endpoint("endpoint").build()) + val openaiFuture = openaiServiceAsync.delete("endpoint") val openai = openaiFuture.get() openai.validate() @@ -94,8 +85,7 @@ internal class OpenAIServiceAsyncTest { .build() val openaiServiceAsync = client.openai() - val responseFuture = - openaiServiceAsync.patch(OpenAIPatchParams.builder().endpoint("endpoint").build()) + val responseFuture = openaiServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt index 1ca1443b..81f0ea4f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.responses.ResponseDeleteParams -import ai.hanzo.api.models.responses.ResponseRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -39,10 +37,7 @@ internal class ResponseServiceAsyncTest { .build() val responseServiceAsync = client.responses() - val responseFuture = - responseServiceAsync.retrieve( - ResponseRetrieveParams.builder().responseId("response_id").build() - ) + val responseFuture = responseServiceAsync.retrieve("response_id") val response = responseFuture.get() response.validate() @@ -58,10 +53,7 @@ internal class ResponseServiceAsyncTest { .build() val responseServiceAsync = client.responses() - val responseFuture = - responseServiceAsync.delete( - ResponseDeleteParams.builder().responseId("response_id").build() - ) + val responseFuture = responseServiceAsync.delete("response_id") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt index 4e4c4a1e..ff05440b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt @@ -11,7 +11,6 @@ import ai.hanzo.api.models.team.TeamAddMemberParams import ai.hanzo.api.models.team.TeamBlockParams import ai.hanzo.api.models.team.TeamCreateParams import ai.hanzo.api.models.team.TeamDeleteParams -import ai.hanzo.api.models.team.TeamDisableLoggingParams import ai.hanzo.api.models.team.TeamListAvailableParams import ai.hanzo.api.models.team.TeamListParams import ai.hanzo.api.models.team.TeamRemoveMemberParams @@ -206,10 +205,7 @@ internal class TeamServiceAsyncTest { .build() val teamServiceAsync = client.team() - val responseFuture = - teamServiceAsync.disableLogging( - TeamDisableLoggingParams.builder().teamId("team_id").build() - ) + val responseFuture = teamServiceAsync.disableLogging("team_id") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt index 7c536b3a..f9080618 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.threads.ThreadRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -38,10 +37,7 @@ internal class ThreadServiceAsyncTest { .build() val threadServiceAsync = client.threads() - val threadFuture = - threadServiceAsync.retrieve( - ThreadRetrieveParams.builder().threadId("thread_id").build() - ) + val threadFuture = threadServiceAsync.retrieve("thread_id") val thread = threadFuture.get() thread.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt index 1e61f3f9..4b1800c5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.vertexai.VertexAiCreateParams -import ai.hanzo.api.models.vertexai.VertexAiDeleteParams -import ai.hanzo.api.models.vertexai.VertexAiPatchParams -import ai.hanzo.api.models.vertexai.VertexAiRetrieveParams -import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class VertexAiServiceAsyncTest { .build() val vertexAiServiceAsync = client.vertexAi() - val vertexAiFuture = - vertexAiServiceAsync.create(VertexAiCreateParams.builder().endpoint("endpoint").build()) + val vertexAiFuture = vertexAiServiceAsync.create("endpoint") val vertexAi = vertexAiFuture.get() vertexAi.validate() @@ -43,10 +37,7 @@ internal class VertexAiServiceAsyncTest { .build() val vertexAiServiceAsync = client.vertexAi() - val vertexAiFuture = - vertexAiServiceAsync.retrieve( - VertexAiRetrieveParams.builder().endpoint("endpoint").build() - ) + val vertexAiFuture = vertexAiServiceAsync.retrieve("endpoint") val vertexAi = vertexAiFuture.get() vertexAi.validate() @@ -62,8 +53,7 @@ internal class VertexAiServiceAsyncTest { .build() val vertexAiServiceAsync = client.vertexAi() - val vertexAiFuture = - vertexAiServiceAsync.update(VertexAiUpdateParams.builder().endpoint("endpoint").build()) + val vertexAiFuture = vertexAiServiceAsync.update("endpoint") val vertexAi = vertexAiFuture.get() vertexAi.validate() @@ -79,8 +69,7 @@ internal class VertexAiServiceAsyncTest { .build() val vertexAiServiceAsync = client.vertexAi() - val vertexAiFuture = - vertexAiServiceAsync.delete(VertexAiDeleteParams.builder().endpoint("endpoint").build()) + val vertexAiFuture = vertexAiServiceAsync.delete("endpoint") val vertexAi = vertexAiFuture.get() vertexAi.validate() @@ -96,8 +85,7 @@ internal class VertexAiServiceAsyncTest { .build() val vertexAiServiceAsync = client.vertexAi() - val responseFuture = - vertexAiServiceAsync.patch(VertexAiPatchParams.builder().endpoint("endpoint").build()) + val responseFuture = vertexAiServiceAsync.patch("endpoint") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt index 4de1ec05..84ae6050 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt @@ -8,7 +8,6 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointCreateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointDeleteParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListParams -import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughGenericEndpoint import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -54,10 +53,7 @@ internal class PassThroughEndpointServiceAsyncTest { .build() val passThroughEndpointServiceAsync = client.config().passThroughEndpoint() - val passThroughEndpointFuture = - passThroughEndpointServiceAsync.update( - PassThroughEndpointUpdateParams.builder().endpointId("endpoint_id").build() - ) + val passThroughEndpointFuture = passThroughEndpointServiceAsync.update("endpoint_id") val passThroughEndpoint = passThroughEndpointFuture.get() passThroughEndpoint.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt index 2e6e492c..f32ed6e1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async.engines import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.engines.chat.ChatCompleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,8 +21,7 @@ internal class ChatServiceAsyncTest { .build() val chatServiceAsync = client.engines().chat() - val responseFuture = - chatServiceAsync.complete(ChatCompleteParams.builder().model("model").build()) + val responseFuture = chatServiceAsync.complete("model") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt index 2909cdf6..0707d0f8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async.finetuning.jobs import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,10 +21,7 @@ internal class CancelServiceAsyncTest { .build() val cancelServiceAsync = client.fineTuning().jobs().cancel() - val cancelFuture = - cancelServiceAsync.create( - CancelCreateParams.builder().fineTuningJobId("fine_tuning_job_id").build() - ) + val cancelFuture = cancelServiceAsync.create("fine_tuning_job_id") val cancel = cancelFuture.get() cancel.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt index 947e397b..81eea156 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.async.openai import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.openai.deployments.DeploymentCompleteParams -import ai.hanzo.api.models.openai.deployments.DeploymentEmbedParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,10 +21,7 @@ internal class DeploymentServiceAsyncTest { .build() val deploymentServiceAsync = client.openai().deployments() - val responseFuture = - deploymentServiceAsync.complete( - DeploymentCompleteParams.builder().model("model").build() - ) + val responseFuture = deploymentServiceAsync.complete("model") val response = responseFuture.get() response.validate() @@ -42,8 +37,7 @@ internal class DeploymentServiceAsyncTest { .build() val deploymentServiceAsync = client.openai().deployments() - val responseFuture = - deploymentServiceAsync.embed(DeploymentEmbedParams.builder().model("model").build()) + val responseFuture = deploymentServiceAsync.embed("model") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt index deb680b0..d2fff48f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async.openai.deployments import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,8 +21,7 @@ internal class ChatServiceAsyncTest { .build() val chatServiceAsync = client.openai().deployments().chat() - val responseFuture = - chatServiceAsync.complete(ChatCompleteParams.builder().model("model").build()) + val responseFuture = chatServiceAsync.complete("model") val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt index 4b7f56b0..d4fb7455 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async.responses import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.responses.inputitems.InputItemListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,10 +21,7 @@ internal class InputItemServiceAsyncTest { .build() val inputItemServiceAsync = client.responses().inputItems() - val inputItemsFuture = - inputItemServiceAsync.list( - InputItemListParams.builder().responseId("response_id").build() - ) + val inputItemsFuture = inputItemServiceAsync.list("response_id") val inputItems = inputItemsFuture.get() inputItems.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt index 5cf76a4c..3570864e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt @@ -6,7 +6,6 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.team.callback.CallbackAddParams -import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -24,10 +23,7 @@ internal class CallbackServiceAsyncTest { .build() val callbackServiceAsync = client.team().callback() - val callbackFuture = - callbackServiceAsync.retrieve( - CallbackRetrieveParams.builder().teamId("team_id").build() - ) + val callbackFuture = callbackServiceAsync.retrieve("team_id") val callback = callbackFuture.get() callback.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt index 6d496c56..30da7509 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.async.threads import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.threads.messages.MessageCreateParams -import ai.hanzo.api.models.threads.messages.MessageListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,8 +21,7 @@ internal class MessageServiceAsyncTest { .build() val messageServiceAsync = client.threads().messages() - val messageFuture = - messageServiceAsync.create(MessageCreateParams.builder().threadId("thread_id").build()) + val messageFuture = messageServiceAsync.create("thread_id") val message = messageFuture.get() message.validate() @@ -40,8 +37,7 @@ internal class MessageServiceAsyncTest { .build() val messageServiceAsync = client.threads().messages() - val messagesFuture = - messageServiceAsync.list(MessageListParams.builder().threadId("thread_id").build()) + val messagesFuture = messageServiceAsync.list("thread_id") val messages = messagesFuture.get() messages.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt index 7d5c1b5e..8c51a2f1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async.threads import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.threads.runs.RunCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,8 +21,7 @@ internal class RunServiceAsyncTest { .build() val runServiceAsync = client.threads().runs() - val runFuture = - runServiceAsync.create(RunCreateParams.builder().threadId("thread_id").build()) + val runFuture = runServiceAsync.create("thread_id") val run = runFuture.get() run.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt index 37e1f431..a2f0881d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.anthropic.AnthropicCreateParams -import ai.hanzo.api.models.anthropic.AnthropicDeleteParams -import ai.hanzo.api.models.anthropic.AnthropicModifyParams -import ai.hanzo.api.models.anthropic.AnthropicRetrieveParams -import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class AnthropicServiceTest { .build() val anthropicService = client.anthropic() - val anthropic = - anthropicService.create(AnthropicCreateParams.builder().endpoint("endpoint").build()) + val anthropic = anthropicService.create("endpoint") anthropic.validate() } @@ -42,10 +36,7 @@ internal class AnthropicServiceTest { .build() val anthropicService = client.anthropic() - val anthropic = - anthropicService.retrieve( - AnthropicRetrieveParams.builder().endpoint("endpoint").build() - ) + val anthropic = anthropicService.retrieve("endpoint") anthropic.validate() } @@ -60,8 +51,7 @@ internal class AnthropicServiceTest { .build() val anthropicService = client.anthropic() - val anthropic = - anthropicService.update(AnthropicUpdateParams.builder().endpoint("endpoint").build()) + val anthropic = anthropicService.update("endpoint") anthropic.validate() } @@ -76,8 +66,7 @@ internal class AnthropicServiceTest { .build() val anthropicService = client.anthropic() - val anthropic = - anthropicService.delete(AnthropicDeleteParams.builder().endpoint("endpoint").build()) + val anthropic = anthropicService.delete("endpoint") anthropic.validate() } @@ -92,8 +81,7 @@ internal class AnthropicServiceTest { .build() val anthropicService = client.anthropic() - val response = - anthropicService.modify(AnthropicModifyParams.builder().endpoint("endpoint").build()) + val response = anthropicService.modify("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt index 8cb07419..f3ee773e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.assemblyai.AssemblyaiCreateParams -import ai.hanzo.api.models.assemblyai.AssemblyaiDeleteParams -import ai.hanzo.api.models.assemblyai.AssemblyaiPatchParams -import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveParams -import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class AssemblyaiServiceTest { .build() val assemblyaiService = client.assemblyai() - val assemblyai = - assemblyaiService.create(AssemblyaiCreateParams.builder().endpoint("endpoint").build()) + val assemblyai = assemblyaiService.create("endpoint") assemblyai.validate() } @@ -42,10 +36,7 @@ internal class AssemblyaiServiceTest { .build() val assemblyaiService = client.assemblyai() - val assemblyai = - assemblyaiService.retrieve( - AssemblyaiRetrieveParams.builder().endpoint("endpoint").build() - ) + val assemblyai = assemblyaiService.retrieve("endpoint") assemblyai.validate() } @@ -60,8 +51,7 @@ internal class AssemblyaiServiceTest { .build() val assemblyaiService = client.assemblyai() - val assemblyai = - assemblyaiService.update(AssemblyaiUpdateParams.builder().endpoint("endpoint").build()) + val assemblyai = assemblyaiService.update("endpoint") assemblyai.validate() } @@ -76,8 +66,7 @@ internal class AssemblyaiServiceTest { .build() val assemblyaiService = client.assemblyai() - val assemblyai = - assemblyaiService.delete(AssemblyaiDeleteParams.builder().endpoint("endpoint").build()) + val assemblyai = assemblyaiService.delete("endpoint") assemblyai.validate() } @@ -92,8 +81,7 @@ internal class AssemblyaiServiceTest { .build() val assemblyaiService = client.assemblyai() - val response = - assemblyaiService.patch(AssemblyaiPatchParams.builder().endpoint("endpoint").build()) + val response = assemblyaiService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt index 4a78f01c..a16b76a9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.assistants.AssistantDeleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,10 +51,7 @@ internal class AssistantServiceTest { .build() val assistantService = client.assistants() - val assistant = - assistantService.delete( - AssistantDeleteParams.builder().assistantId("assistant_id").build() - ) + val assistant = assistantService.delete("assistant_id") assistant.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt index 4a606353..b02675ed 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.azure.AzureCallParams -import ai.hanzo.api.models.azure.AzureCreateParams -import ai.hanzo.api.models.azure.AzureDeleteParams -import ai.hanzo.api.models.azure.AzurePatchParams -import ai.hanzo.api.models.azure.AzureUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,7 +21,7 @@ internal class AzureServiceTest { .build() val azureService = client.azure() - val azure = azureService.create(AzureCreateParams.builder().endpoint("endpoint").build()) + val azure = azureService.create("endpoint") azure.validate() } @@ -41,7 +36,7 @@ internal class AzureServiceTest { .build() val azureService = client.azure() - val azure = azureService.update(AzureUpdateParams.builder().endpoint("endpoint").build()) + val azure = azureService.update("endpoint") azure.validate() } @@ -56,7 +51,7 @@ internal class AzureServiceTest { .build() val azureService = client.azure() - val azure = azureService.delete(AzureDeleteParams.builder().endpoint("endpoint").build()) + val azure = azureService.delete("endpoint") azure.validate() } @@ -71,7 +66,7 @@ internal class AzureServiceTest { .build() val azureService = client.azure() - val response = azureService.call(AzureCallParams.builder().endpoint("endpoint").build()) + val response = azureService.call("endpoint") response.validate() } @@ -86,7 +81,7 @@ internal class AzureServiceTest { .build() val azureService = client.azure() - val response = azureService.patch(AzurePatchParams.builder().endpoint("endpoint").build()) + val response = azureService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt index edfadf6b..6e0a5bc2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt @@ -6,7 +6,6 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.models.batches.BatchCancelWithProviderParams import ai.hanzo.api.models.batches.BatchCreateParams -import ai.hanzo.api.models.batches.BatchCreateWithProviderParams import ai.hanzo.api.models.batches.BatchListParams import ai.hanzo.api.models.batches.BatchListWithProviderParams import ai.hanzo.api.models.batches.BatchRetrieveParams @@ -100,10 +99,7 @@ internal class BatchServiceTest { .build() val batchService = client.batches() - val response = - batchService.createWithProvider( - BatchCreateWithProviderParams.builder().provider("provider").build() - ) + val response = batchService.createWithProvider("provider") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt index 0972e1a5..adb50b90 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.bedrock.BedrockCreateParams -import ai.hanzo.api.models.bedrock.BedrockDeleteParams -import ai.hanzo.api.models.bedrock.BedrockPatchParams -import ai.hanzo.api.models.bedrock.BedrockRetrieveParams -import ai.hanzo.api.models.bedrock.BedrockUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class BedrockServiceTest { .build() val bedrockService = client.bedrock() - val bedrock = - bedrockService.create(BedrockCreateParams.builder().endpoint("endpoint").build()) + val bedrock = bedrockService.create("endpoint") bedrock.validate() } @@ -42,8 +36,7 @@ internal class BedrockServiceTest { .build() val bedrockService = client.bedrock() - val bedrock = - bedrockService.retrieve(BedrockRetrieveParams.builder().endpoint("endpoint").build()) + val bedrock = bedrockService.retrieve("endpoint") bedrock.validate() } @@ -58,8 +51,7 @@ internal class BedrockServiceTest { .build() val bedrockService = client.bedrock() - val bedrock = - bedrockService.update(BedrockUpdateParams.builder().endpoint("endpoint").build()) + val bedrock = bedrockService.update("endpoint") bedrock.validate() } @@ -74,8 +66,7 @@ internal class BedrockServiceTest { .build() val bedrockService = client.bedrock() - val bedrock = - bedrockService.delete(BedrockDeleteParams.builder().endpoint("endpoint").build()) + val bedrock = bedrockService.delete("endpoint") bedrock.validate() } @@ -90,8 +81,7 @@ internal class BedrockServiceTest { .build() val bedrockService = client.bedrock() - val response = - bedrockService.patch(BedrockPatchParams.builder().endpoint("endpoint").build()) + val response = bedrockService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt index e853a8bb..e866211f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.cohere.CohereCreateParams -import ai.hanzo.api.models.cohere.CohereDeleteParams -import ai.hanzo.api.models.cohere.CohereModifyParams -import ai.hanzo.api.models.cohere.CohereRetrieveParams -import ai.hanzo.api.models.cohere.CohereUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,7 +21,7 @@ internal class CohereServiceTest { .build() val cohereService = client.cohere() - val cohere = cohereService.create(CohereCreateParams.builder().endpoint("endpoint").build()) + val cohere = cohereService.create("endpoint") cohere.validate() } @@ -41,8 +36,7 @@ internal class CohereServiceTest { .build() val cohereService = client.cohere() - val cohere = - cohereService.retrieve(CohereRetrieveParams.builder().endpoint("endpoint").build()) + val cohere = cohereService.retrieve("endpoint") cohere.validate() } @@ -57,7 +51,7 @@ internal class CohereServiceTest { .build() val cohereService = client.cohere() - val cohere = cohereService.update(CohereUpdateParams.builder().endpoint("endpoint").build()) + val cohere = cohereService.update("endpoint") cohere.validate() } @@ -72,7 +66,7 @@ internal class CohereServiceTest { .build() val cohereService = client.cohere() - val cohere = cohereService.delete(CohereDeleteParams.builder().endpoint("endpoint").build()) + val cohere = cohereService.delete("endpoint") cohere.validate() } @@ -87,8 +81,7 @@ internal class CohereServiceTest { .build() val cohereService = client.cohere() - val response = - cohereService.modify(CohereModifyParams.builder().endpoint("endpoint").build()) + val response = cohereService.modify("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt index 9e7e3289..9fb7da90 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt @@ -6,7 +6,6 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.credentials.CredentialCreateParams -import ai.hanzo.api.models.credentials.CredentialDeleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -62,10 +61,7 @@ internal class CredentialServiceTest { .build() val credentialService = client.credentials() - val credential = - credentialService.delete( - CredentialDeleteParams.builder().credentialName("credential_name").build() - ) + val credential = credentialService.delete("credential_name") credential.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt index 63bb999e..126fa03d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.engines.EngineCompleteParams -import ai.hanzo.api.models.engines.EngineEmbedParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,7 +21,7 @@ internal class EngineServiceTest { .build() val engineService = client.engines() - val response = engineService.complete(EngineCompleteParams.builder().model("model").build()) + val response = engineService.complete("model") response.validate() } @@ -38,7 +36,7 @@ internal class EngineServiceTest { .build() val engineService = client.engines() - val response = engineService.embed(EngineEmbedParams.builder().model("model").build()) + val response = engineService.embed("model") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt index 79b99385..917c4c10 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiCreateParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiDeleteParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiPatchParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveParams -import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,10 +21,7 @@ internal class EuAssemblyaiServiceTest { .build() val euAssemblyaiService = client.euAssemblyai() - val euAssemblyai = - euAssemblyaiService.create( - EuAssemblyaiCreateParams.builder().endpoint("endpoint").build() - ) + val euAssemblyai = euAssemblyaiService.create("endpoint") euAssemblyai.validate() } @@ -44,10 +36,7 @@ internal class EuAssemblyaiServiceTest { .build() val euAssemblyaiService = client.euAssemblyai() - val euAssemblyai = - euAssemblyaiService.retrieve( - EuAssemblyaiRetrieveParams.builder().endpoint("endpoint").build() - ) + val euAssemblyai = euAssemblyaiService.retrieve("endpoint") euAssemblyai.validate() } @@ -62,10 +51,7 @@ internal class EuAssemblyaiServiceTest { .build() val euAssemblyaiService = client.euAssemblyai() - val euAssemblyai = - euAssemblyaiService.update( - EuAssemblyaiUpdateParams.builder().endpoint("endpoint").build() - ) + val euAssemblyai = euAssemblyaiService.update("endpoint") euAssemblyai.validate() } @@ -80,10 +66,7 @@ internal class EuAssemblyaiServiceTest { .build() val euAssemblyaiService = client.euAssemblyai() - val euAssemblyai = - euAssemblyaiService.delete( - EuAssemblyaiDeleteParams.builder().endpoint("endpoint").build() - ) + val euAssemblyai = euAssemblyaiService.delete("endpoint") euAssemblyai.validate() } @@ -98,10 +81,7 @@ internal class EuAssemblyaiServiceTest { .build() val euAssemblyaiService = client.euAssemblyai() - val response = - euAssemblyaiService.patch( - EuAssemblyaiPatchParams.builder().endpoint("endpoint").build() - ) + val response = euAssemblyaiService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt index 8c112317..bf2bbd32 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.gemini.GeminiCreateParams -import ai.hanzo.api.models.gemini.GeminiDeleteParams -import ai.hanzo.api.models.gemini.GeminiPatchParams -import ai.hanzo.api.models.gemini.GeminiRetrieveParams -import ai.hanzo.api.models.gemini.GeminiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,7 +21,7 @@ internal class GeminiServiceTest { .build() val geminiService = client.gemini() - val gemini = geminiService.create(GeminiCreateParams.builder().endpoint("endpoint").build()) + val gemini = geminiService.create("endpoint") gemini.validate() } @@ -41,8 +36,7 @@ internal class GeminiServiceTest { .build() val geminiService = client.gemini() - val gemini = - geminiService.retrieve(GeminiRetrieveParams.builder().endpoint("endpoint").build()) + val gemini = geminiService.retrieve("endpoint") gemini.validate() } @@ -57,7 +51,7 @@ internal class GeminiServiceTest { .build() val geminiService = client.gemini() - val gemini = geminiService.update(GeminiUpdateParams.builder().endpoint("endpoint").build()) + val gemini = geminiService.update("endpoint") gemini.validate() } @@ -72,7 +66,7 @@ internal class GeminiServiceTest { .build() val geminiService = client.gemini() - val gemini = geminiService.delete(GeminiDeleteParams.builder().endpoint("endpoint").build()) + val gemini = geminiService.delete("endpoint") gemini.validate() } @@ -87,7 +81,7 @@ internal class GeminiServiceTest { .build() val geminiService = client.gemini() - val response = geminiService.patch(GeminiPatchParams.builder().endpoint("endpoint").build()) + val response = geminiService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt index 50b8cbac..910c1aa5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.langfuse.LangfuseCreateParams -import ai.hanzo.api.models.langfuse.LangfuseDeleteParams -import ai.hanzo.api.models.langfuse.LangfusePatchParams -import ai.hanzo.api.models.langfuse.LangfuseRetrieveParams -import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class LangfuseServiceTest { .build() val langfuseService = client.langfuse() - val langfuse = - langfuseService.create(LangfuseCreateParams.builder().endpoint("endpoint").build()) + val langfuse = langfuseService.create("endpoint") langfuse.validate() } @@ -42,8 +36,7 @@ internal class LangfuseServiceTest { .build() val langfuseService = client.langfuse() - val langfuse = - langfuseService.retrieve(LangfuseRetrieveParams.builder().endpoint("endpoint").build()) + val langfuse = langfuseService.retrieve("endpoint") langfuse.validate() } @@ -58,8 +51,7 @@ internal class LangfuseServiceTest { .build() val langfuseService = client.langfuse() - val langfuse = - langfuseService.update(LangfuseUpdateParams.builder().endpoint("endpoint").build()) + val langfuse = langfuseService.update("endpoint") langfuse.validate() } @@ -74,8 +66,7 @@ internal class LangfuseServiceTest { .build() val langfuseService = client.langfuse() - val langfuse = - langfuseService.delete(LangfuseDeleteParams.builder().endpoint("endpoint").build()) + val langfuse = langfuseService.delete("endpoint") langfuse.validate() } @@ -90,8 +81,7 @@ internal class LangfuseServiceTest { .build() val langfuseService = client.langfuse() - val response = - langfuseService.patch(LangfusePatchParams.builder().endpoint("endpoint").build()) + val response = langfuseService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt index 77b1dc26..15af4bbb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.openai.OpenAICreateParams -import ai.hanzo.api.models.openai.OpenAIDeleteParams -import ai.hanzo.api.models.openai.OpenAIPatchParams -import ai.hanzo.api.models.openai.OpenAIRetrieveParams -import ai.hanzo.api.models.openai.OpenAIUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,7 +21,7 @@ internal class OpenAIServiceTest { .build() val openaiService = client.openai() - val openai = openaiService.create(OpenAICreateParams.builder().endpoint("endpoint").build()) + val openai = openaiService.create("endpoint") openai.validate() } @@ -41,8 +36,7 @@ internal class OpenAIServiceTest { .build() val openaiService = client.openai() - val openai = - openaiService.retrieve(OpenAIRetrieveParams.builder().endpoint("endpoint").build()) + val openai = openaiService.retrieve("endpoint") openai.validate() } @@ -57,7 +51,7 @@ internal class OpenAIServiceTest { .build() val openaiService = client.openai() - val openai = openaiService.update(OpenAIUpdateParams.builder().endpoint("endpoint").build()) + val openai = openaiService.update("endpoint") openai.validate() } @@ -72,7 +66,7 @@ internal class OpenAIServiceTest { .build() val openaiService = client.openai() - val openai = openaiService.delete(OpenAIDeleteParams.builder().endpoint("endpoint").build()) + val openai = openaiService.delete("endpoint") openai.validate() } @@ -87,7 +81,7 @@ internal class OpenAIServiceTest { .build() val openaiService = client.openai() - val response = openaiService.patch(OpenAIPatchParams.builder().endpoint("endpoint").build()) + val response = openaiService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt index b65edd23..e43d407d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.responses.ResponseDeleteParams -import ai.hanzo.api.models.responses.ResponseRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -38,10 +36,7 @@ internal class ResponseServiceTest { .build() val responseService = client.responses() - val response = - responseService.retrieve( - ResponseRetrieveParams.builder().responseId("response_id").build() - ) + val response = responseService.retrieve("response_id") response.validate() } @@ -56,8 +51,7 @@ internal class ResponseServiceTest { .build() val responseService = client.responses() - val response = - responseService.delete(ResponseDeleteParams.builder().responseId("response_id").build()) + val response = responseService.delete("response_id") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt index 246a3fab..eaf6e536 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt @@ -11,7 +11,6 @@ import ai.hanzo.api.models.team.TeamAddMemberParams import ai.hanzo.api.models.team.TeamBlockParams import ai.hanzo.api.models.team.TeamCreateParams import ai.hanzo.api.models.team.TeamDeleteParams -import ai.hanzo.api.models.team.TeamDisableLoggingParams import ai.hanzo.api.models.team.TeamListAvailableParams import ai.hanzo.api.models.team.TeamListParams import ai.hanzo.api.models.team.TeamRemoveMemberParams @@ -200,8 +199,7 @@ internal class TeamServiceTest { .build() val teamService = client.team() - val response = - teamService.disableLogging(TeamDisableLoggingParams.builder().teamId("team_id").build()) + val response = teamService.disableLogging("team_id") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt index bad9614c..415fe17e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.threads.ThreadRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -37,8 +36,7 @@ internal class ThreadServiceTest { .build() val threadService = client.threads() - val thread = - threadService.retrieve(ThreadRetrieveParams.builder().threadId("thread_id").build()) + val thread = threadService.retrieve("thread_id") thread.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt index 4b0c8805..776cb3f3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt @@ -4,11 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.vertexai.VertexAiCreateParams -import ai.hanzo.api.models.vertexai.VertexAiDeleteParams -import ai.hanzo.api.models.vertexai.VertexAiPatchParams -import ai.hanzo.api.models.vertexai.VertexAiRetrieveParams -import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,8 +21,7 @@ internal class VertexAiServiceTest { .build() val vertexAiService = client.vertexAi() - val vertexAi = - vertexAiService.create(VertexAiCreateParams.builder().endpoint("endpoint").build()) + val vertexAi = vertexAiService.create("endpoint") vertexAi.validate() } @@ -42,8 +36,7 @@ internal class VertexAiServiceTest { .build() val vertexAiService = client.vertexAi() - val vertexAi = - vertexAiService.retrieve(VertexAiRetrieveParams.builder().endpoint("endpoint").build()) + val vertexAi = vertexAiService.retrieve("endpoint") vertexAi.validate() } @@ -58,8 +51,7 @@ internal class VertexAiServiceTest { .build() val vertexAiService = client.vertexAi() - val vertexAi = - vertexAiService.update(VertexAiUpdateParams.builder().endpoint("endpoint").build()) + val vertexAi = vertexAiService.update("endpoint") vertexAi.validate() } @@ -74,8 +66,7 @@ internal class VertexAiServiceTest { .build() val vertexAiService = client.vertexAi() - val vertexAi = - vertexAiService.delete(VertexAiDeleteParams.builder().endpoint("endpoint").build()) + val vertexAi = vertexAiService.delete("endpoint") vertexAi.validate() } @@ -90,8 +81,7 @@ internal class VertexAiServiceTest { .build() val vertexAiService = client.vertexAi() - val response = - vertexAiService.patch(VertexAiPatchParams.builder().endpoint("endpoint").build()) + val response = vertexAiService.patch("endpoint") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt index 0fa23638..a348d1d0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt @@ -8,7 +8,6 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointCreateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointDeleteParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListParams -import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughGenericEndpoint import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -53,10 +52,7 @@ internal class PassThroughEndpointServiceTest { .build() val passThroughEndpointService = client.config().passThroughEndpoint() - val passThroughEndpoint = - passThroughEndpointService.update( - PassThroughEndpointUpdateParams.builder().endpointId("endpoint_id").build() - ) + val passThroughEndpoint = passThroughEndpointService.update("endpoint_id") passThroughEndpoint.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt index 174fbd09..5b6972b4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking.engines import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.engines.chat.ChatCompleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,7 +21,7 @@ internal class ChatServiceTest { .build() val chatService = client.engines().chat() - val response = chatService.complete(ChatCompleteParams.builder().model("model").build()) + val response = chatService.complete("model") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt index 256266f0..09adb6ef 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking.finetuning.jobs import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,10 +21,7 @@ internal class CancelServiceTest { .build() val cancelService = client.fineTuning().jobs().cancel() - val cancel = - cancelService.create( - CancelCreateParams.builder().fineTuningJobId("fine_tuning_job_id").build() - ) + val cancel = cancelService.create("fine_tuning_job_id") cancel.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt index 1ccbb7c4..28a39744 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.blocking.openai import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.openai.deployments.DeploymentCompleteParams -import ai.hanzo.api.models.openai.deployments.DeploymentEmbedParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,8 +21,7 @@ internal class DeploymentServiceTest { .build() val deploymentService = client.openai().deployments() - val response = - deploymentService.complete(DeploymentCompleteParams.builder().model("model").build()) + val response = deploymentService.complete("model") response.validate() } @@ -39,8 +36,7 @@ internal class DeploymentServiceTest { .build() val deploymentService = client.openai().deployments() - val response = - deploymentService.embed(DeploymentEmbedParams.builder().model("model").build()) + val response = deploymentService.embed("model") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt index 80c34e4b..29049246 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking.openai.deployments import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,7 +21,7 @@ internal class ChatServiceTest { .build() val chatService = client.openai().deployments().chat() - val response = chatService.complete(ChatCompleteParams.builder().model("model").build()) + val response = chatService.complete("model") response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt index 53698fa2..b01fd296 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking.responses import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.responses.inputitems.InputItemListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,8 +21,7 @@ internal class InputItemServiceTest { .build() val inputItemService = client.responses().inputItems() - val inputItems = - inputItemService.list(InputItemListParams.builder().responseId("response_id").build()) + val inputItems = inputItemService.list("response_id") inputItems.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt index 885f4060..33074793 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt @@ -6,7 +6,6 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.team.callback.CallbackAddParams -import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -24,8 +23,7 @@ internal class CallbackServiceTest { .build() val callbackService = client.team().callback() - val callback = - callbackService.retrieve(CallbackRetrieveParams.builder().teamId("team_id").build()) + val callback = callbackService.retrieve("team_id") callback.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt index 92888adb..b090729b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt @@ -4,8 +4,6 @@ package ai.hanzo.api.services.blocking.threads import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.threads.messages.MessageCreateParams -import ai.hanzo.api.models.threads.messages.MessageListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,8 +21,7 @@ internal class MessageServiceTest { .build() val messageService = client.threads().messages() - val message = - messageService.create(MessageCreateParams.builder().threadId("thread_id").build()) + val message = messageService.create("thread_id") message.validate() } @@ -39,8 +36,7 @@ internal class MessageServiceTest { .build() val messageService = client.threads().messages() - val messages = - messageService.list(MessageListParams.builder().threadId("thread_id").build()) + val messages = messageService.list("thread_id") messages.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt index 6f2fba2e..05be8af2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking.threads import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.threads.runs.RunCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,7 +21,7 @@ internal class RunServiceTest { .build() val runService = client.threads().runs() - val run = runService.create(RunCreateParams.builder().threadId("thread_id").build()) + val run = runService.create("thread_id") run.validate() } From e735ee9fb131714101989c4d8a724399932e8026 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 05:30:48 +0000 Subject: [PATCH 31/75] feat(client)!: extract auto pagination to shared classes refactor(client)!: refactor async auto-pagination refactor(client)!: rename `getNextPage{,Params}` to `nextPage{,Params}` refactor(client)!: swap `nextPage{,Params}` to return non-optional # Migration - If you were referencing the `AutoPager` class on a specific `*Page` or `*PageAsync` type, then you should instead reference the shared `AutoPager` and `AutoPagerAsync` types, under the `core` package - `AutoPagerAsync` now has different usage. You can call `.subscribe(...)` on the returned object instead to get called back each page item. You can also call `onCompleteFuture()` to get a future that completes when all items have been processed. Finally, you can call `.close()` on the returned object to stop auto-paginating early - If you were referencing `getNextPage` or `getNextPageParams`: - Swap to `nextPage()` and `nextPageParams()` - Note that these both now return non-optional types (use `hasNextPage()` before calling these, since they will throw if it's impossible to get another page) There are examples and further information about pagination in the readme. --- README.md | 2 - .../api/core/http/AsyncStreamResponse.kt | 157 ++++++++++ ...ntomReachableClosingAsyncStreamResponse.kt | 56 ++++ .../PhantomReachableClosingStreamResponse.kt | 21 ++ .../ai/hanzo/api/core/http/StreamResponse.kt | 19 ++ .../api/core/http/AsyncStreamResponseTest.kt | 268 ++++++++++++++++++ 6 files changed, 521 insertions(+), 2 deletions(-) create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/AsyncStreamResponse.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingStreamResponse.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/StreamResponse.kt create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/AsyncStreamResponseTest.kt diff --git a/README.md b/README.md index 55805c54..6941deea 100644 --- a/README.md +++ b/README.md @@ -325,7 +325,6 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; ClientGetHomeResponse response = client.getHome(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); @@ -582,7 +581,6 @@ UtilTokenCounterResponse response = client.utils().tokenCounter(params).validate Or configure the method call to validate the response using the `responseValidation` method: ```java -import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; ClientGetHomeResponse response = client.getHome(RequestOptions.builder().responseValidation(true).build()); diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/AsyncStreamResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/AsyncStreamResponse.kt new file mode 100644 index 00000000..9cfd82c9 --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package ai.hanzo.api.core.http + +import ai.hanzo.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt new file mode 100644 index 00000000..3949c757 --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -0,0 +1,56 @@ +package ai.hanzo.api.core.http + +import ai.hanzo.api.core.closeWhenPhantomReachable +import ai.hanzo.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor + +/** + * A delegating wrapper around an `AsyncStreamResponse` that closes it once it's only phantom + * reachable. + * + * This class ensures the `AsyncStreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingAsyncStreamResponse( + private val asyncStreamResponse: AsyncStreamResponse +) : AsyncStreamResponse { + + /** + * An object used for keeping `asyncStreamResponse` open while the object is still reachable. + */ + private val reachabilityTracker = Object() + + init { + closeWhenPhantomReachable(reachabilityTracker, asyncStreamResponse::close) + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker)) + } + + override fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse = + apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker), executor) + } + + override fun onCompleteFuture(): CompletableFuture = + asyncStreamResponse.onCompleteFuture() + + override fun close() = asyncStreamResponse.close() +} + +/** + * A wrapper around a `Handler` that also references a `reachabilityTracker` object. + * + * Referencing the `reachabilityTracker` object prevents it from getting reclaimed while the handler + * is still reachable. + */ +private class TrackedHandler( + private val handler: Handler, + private val reachabilityTracker: Any, +) : Handler { + override fun onNext(value: T) = handler.onNext(value) + + override fun onComplete(error: Optional) = handler.onComplete(error) +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingStreamResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 00000000..8c59c3cd --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package ai.hanzo.api.core.http + +import ai.hanzo.api.core.closeWhenPhantomReachable +import java.util.stream.Stream + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/StreamResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/StreamResponse.kt new file mode 100644 index 00000000..c3e2fb60 --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package ai.hanzo.api.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/AsyncStreamResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 00000000..b86c4b9c --- /dev/null +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package ai.hanzo.api.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} From ccd164eaddd08e28deb6dc7934e27b75febee968 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 02:46:31 +0000 Subject: [PATCH 32/75] chore(docs): grammar improvements --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index bada7faa..0b579e02 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Hanzo please follow the respective company's security reporting guidelines. +or products provided by Hanzo, please follow the respective company's security reporting guidelines. ### Hanzo Terms and Policies -Please contact dev@hanzo.ai for any questions or concerns regarding security of our services. +Please contact dev@hanzo.ai for any questions or concerns regarding the security of our services. --- From bb225395cd286571c72d6ad48582d0f5b54b9db9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:32:19 +0000 Subject: [PATCH 33/75] feat(api): api update --- .github/workflows/ci.yml | 6 +++ .github/workflows/publish-sonatype.yml | 4 +- .stats.yml | 4 +- README.md | 15 ++++++ bin/check-release-environment | 8 +-- .../src/main/kotlin/hanzo.publish.gradle.kts | 4 ++ .../api/client/okhttp/HanzoOkHttpClient.kt | 8 +-- .../client/okhttp/HanzoOkHttpClientAsync.kt | 8 +-- .../hanzo/api/client/okhttp/OkHttpClient.kt | 22 +++----- .../kotlin/ai/hanzo/api/client/HanzoClient.kt | 16 ++++++ .../ai/hanzo/api/client/HanzoClientAsync.kt | 21 ++++++-- .../hanzo/api/client/HanzoClientAsyncImpl.kt | 12 +++++ .../ai/hanzo/api/client/HanzoClientImpl.kt | 12 +++++ .../kotlin/ai/hanzo/api/core/ClientOptions.kt | 31 ++++++----- .../ai/hanzo/api/core/http/HttpRequest.kt | 12 ++--- .../api/services/async/ActiveServiceAsync.kt | 23 ++++++-- .../services/async/ActiveServiceAsyncImpl.kt | 12 +++++ .../api/services/async/AddServiceAsync.kt | 19 +++++-- .../api/services/async/AddServiceAsyncImpl.kt | 12 +++++ .../services/async/AnthropicServiceAsync.kt | 49 +++++++---------- .../async/AnthropicServiceAsyncImpl.kt | 16 ++++++ .../services/async/AssemblyaiServiceAsync.kt | 49 +++++++---------- .../async/AssemblyaiServiceAsyncImpl.kt | 16 ++++++ .../services/async/AssistantServiceAsync.kt | 33 ++++++------ .../async/AssistantServiceAsyncImpl.kt | 14 +++++ .../api/services/async/AudioServiceAsync.kt | 18 +++++++ .../services/async/AudioServiceAsyncImpl.kt | 11 ++++ .../api/services/async/AzureServiceAsync.kt | 49 +++++++---------- .../services/async/AzureServiceAsyncImpl.kt | 16 ++++++ .../api/services/async/BatchServiceAsync.kt | 53 +++++++------------ .../services/async/BatchServiceAsyncImpl.kt | 18 +++++++ .../api/services/async/BedrockServiceAsync.kt | 49 +++++++---------- .../services/async/BedrockServiceAsyncImpl.kt | 16 ++++++ .../api/services/async/BudgetServiceAsync.kt | 33 ++++++------ .../services/async/BudgetServiceAsyncImpl.kt | 17 ++++++ .../api/services/async/CacheServiceAsync.kt | 31 ++++++----- .../services/async/CacheServiceAsyncImpl.kt | 14 +++++ .../api/services/async/ChatServiceAsync.kt | 16 ++++++ .../services/async/ChatServiceAsyncImpl.kt | 11 ++++ .../api/services/async/CohereServiceAsync.kt | 49 +++++++---------- .../services/async/CohereServiceAsyncImpl.kt | 16 ++++++ .../services/async/CompletionServiceAsync.kt | 23 ++++++-- .../async/CompletionServiceAsyncImpl.kt | 12 +++++ .../api/services/async/ConfigServiceAsync.kt | 18 +++++++ .../services/async/ConfigServiceAsyncImpl.kt | 11 ++++ .../services/async/CredentialServiceAsync.kt | 31 ++++++----- .../async/CredentialServiceAsyncImpl.kt | 14 +++++ .../services/async/CustomerServiceAsync.kt | 35 ++++++------ .../async/CustomerServiceAsyncImpl.kt | 18 +++++++ .../api/services/async/DeleteServiceAsync.kt | 21 ++++++-- .../services/async/DeleteServiceAsyncImpl.kt | 12 +++++ .../services/async/EmbeddingServiceAsync.kt | 23 ++++++-- .../async/EmbeddingServiceAsyncImpl.kt | 12 +++++ .../api/services/async/EngineServiceAsync.kt | 31 ++++++----- .../services/async/EngineServiceAsyncImpl.kt | 13 +++++ .../async/EuAssemblyaiServiceAsync.kt | 49 +++++++---------- .../async/EuAssemblyaiServiceAsyncImpl.kt | 16 ++++++ .../api/services/async/FileServiceAsync.kt | 35 ++++++------ .../services/async/FileServiceAsyncImpl.kt | 15 ++++++ .../services/async/FineTuningServiceAsync.kt | 18 +++++++ .../async/FineTuningServiceAsyncImpl.kt | 11 ++++ .../api/services/async/GeminiServiceAsync.kt | 49 +++++++---------- .../services/async/GeminiServiceAsyncImpl.kt | 16 ++++++ .../api/services/async/GlobalServiceAsync.kt | 18 +++++++ .../services/async/GlobalServiceAsyncImpl.kt | 11 ++++ .../services/async/GuardrailServiceAsync.kt | 23 ++++++-- .../async/GuardrailServiceAsyncImpl.kt | 12 +++++ .../api/services/async/HealthServiceAsync.kt | 37 +++++++------ .../services/async/HealthServiceAsyncImpl.kt | 16 ++++++ .../api/services/async/ImageServiceAsync.kt | 18 +++++++ .../services/async/ImageServiceAsyncImpl.kt | 11 ++++ .../api/services/async/KeyServiceAsync.kt | 49 ++++++----------- .../api/services/async/KeyServiceAsyncImpl.kt | 20 +++++++ .../services/async/LangfuseServiceAsync.kt | 49 +++++++---------- .../async/LangfuseServiceAsyncImpl.kt | 16 ++++++ .../services/async/ModelGroupServiceAsync.kt | 23 ++++++-- .../async/ModelGroupServiceAsyncImpl.kt | 12 +++++ .../api/services/async/ModelServiceAsync.kt | 23 ++++++-- .../services/async/ModelServiceAsyncImpl.kt | 13 +++++ .../services/async/ModerationServiceAsync.kt | 23 ++++++-- .../async/ModerationServiceAsyncImpl.kt | 12 +++++ .../api/services/async/OpenAIServiceAsync.kt | 49 +++++++---------- .../services/async/OpenAIServiceAsyncImpl.kt | 16 ++++++ .../async/OrganizationServiceAsync.kt | 37 +++++++------ .../async/OrganizationServiceAsyncImpl.kt | 18 +++++++ .../services/async/ProviderServiceAsync.kt | 23 ++++++-- .../async/ProviderServiceAsyncImpl.kt | 12 +++++ .../api/services/async/RerankServiceAsync.kt | 31 ++++++----- .../services/async/RerankServiceAsyncImpl.kt | 14 +++++ .../services/async/ResponseServiceAsync.kt | 35 ++++++------ .../async/ResponseServiceAsyncImpl.kt | 14 +++++ .../api/services/async/RouteServiceAsync.kt | 23 ++++++-- .../services/async/RouteServiceAsyncImpl.kt | 12 +++++ .../api/services/async/SettingServiceAsync.kt | 23 ++++++-- .../services/async/SettingServiceAsyncImpl.kt | 12 +++++ .../api/services/async/SpendServiceAsync.kt | 31 ++++++----- .../services/async/SpendServiceAsyncImpl.kt | 14 +++++ .../api/services/async/TeamServiceAsync.kt | 53 ++++++------------- .../services/async/TeamServiceAsyncImpl.kt | 23 ++++++++ .../api/services/async/TestServiceAsync.kt | 21 ++++++-- .../services/async/TestServiceAsyncImpl.kt | 12 +++++ .../api/services/async/ThreadServiceAsync.kt | 29 ++++++---- .../services/async/ThreadServiceAsyncImpl.kt | 13 +++++ .../api/services/async/UserServiceAsync.kt | 35 ++++++------ .../services/async/UserServiceAsyncImpl.kt | 16 ++++++ .../api/services/async/UtilServiceAsync.kt | 23 +++++--- .../services/async/UtilServiceAsyncImpl.kt | 14 +++++ .../services/async/VertexAiServiceAsync.kt | 49 +++++++---------- .../async/VertexAiServiceAsyncImpl.kt | 16 ++++++ .../async/audio/SpeechServiceAsync.kt | 23 ++++++-- .../async/audio/SpeechServiceAsyncImpl.kt | 12 +++++ .../async/audio/TranscriptionServiceAsync.kt | 21 ++++++-- .../audio/TranscriptionServiceAsyncImpl.kt | 12 +++++ .../async/batches/CancelServiceAsync.kt | 25 ++++++--- .../async/batches/CancelServiceAsyncImpl.kt | 12 +++++ .../services/async/cache/RediServiceAsync.kt | 21 ++++++-- .../async/cache/RediServiceAsyncImpl.kt | 12 +++++ .../async/chat/CompletionServiceAsync.kt | 23 ++++++-- .../async/chat/CompletionServiceAsyncImpl.kt | 12 +++++ .../config/PassThroughEndpointServiceAsync.kt | 33 ++++++------ .../PassThroughEndpointServiceAsyncImpl.kt | 19 +++++++ .../async/engines/ChatServiceAsync.kt | 23 +++++--- .../async/engines/ChatServiceAsyncImpl.kt | 12 +++++ .../async/files/ContentServiceAsync.kt | 23 ++++++-- .../async/files/ContentServiceAsyncImpl.kt | 12 +++++ .../async/finetuning/JobServiceAsync.kt | 25 +++++---- .../async/finetuning/JobServiceAsyncImpl.kt | 14 +++++ .../finetuning/jobs/CancelServiceAsync.kt | 25 ++++++--- .../finetuning/jobs/CancelServiceAsyncImpl.kt | 12 +++++ .../async/global/SpendServiceAsync.kt | 31 ++++++----- .../async/global/SpendServiceAsyncImpl.kt | 14 +++++ .../async/images/GenerationServiceAsync.kt | 23 ++++++-- .../images/GenerationServiceAsyncImpl.kt | 12 +++++ .../async/key/RegenerateServiceAsync.kt | 22 +++++++- .../async/key/RegenerateServiceAsyncImpl.kt | 14 ++++- .../services/async/model/InfoServiceAsync.kt | 21 ++++++-- .../async/model/InfoServiceAsyncImpl.kt | 12 +++++ .../async/model/UpdateServiceAsync.kt | 25 ++++++--- .../async/model/UpdateServiceAsyncImpl.kt | 13 +++++ .../async/openai/DeploymentServiceAsync.kt | 31 ++++++----- .../openai/DeploymentServiceAsyncImpl.kt | 13 +++++ .../openai/deployments/ChatServiceAsync.kt | 23 +++++--- .../deployments/ChatServiceAsyncImpl.kt | 12 +++++ .../async/organization/InfoServiceAsync.kt | 21 ++++++-- .../organization/InfoServiceAsyncImpl.kt | 13 +++++ .../async/responses/InputItemServiceAsync.kt | 25 ++++++--- .../responses/InputItemServiceAsyncImpl.kt | 12 +++++ .../async/team/CallbackServiceAsync.kt | 29 ++++++---- .../async/team/CallbackServiceAsyncImpl.kt | 13 +++++ .../services/async/team/ModelServiceAsync.kt | 23 ++++++-- .../async/team/ModelServiceAsyncImpl.kt | 13 +++++ .../async/threads/MessageServiceAsync.kt | 31 ++++++----- .../async/threads/MessageServiceAsyncImpl.kt | 13 +++++ .../services/async/threads/RunServiceAsync.kt | 23 +++++--- .../async/threads/RunServiceAsyncImpl.kt | 12 +++++ .../api/services/blocking/ActiveService.kt | 16 ++++++ .../services/blocking/ActiveServiceImpl.kt | 12 +++++ .../hanzo/api/services/blocking/AddService.kt | 16 ++++++ .../api/services/blocking/AddServiceImpl.kt | 12 +++++ .../api/services/blocking/AnthropicService.kt | 16 ++++++ .../services/blocking/AnthropicServiceImpl.kt | 16 ++++++ .../services/blocking/AssemblyaiService.kt | 18 +++++++ .../blocking/AssemblyaiServiceImpl.kt | 16 ++++++ .../api/services/blocking/AssistantService.kt | 16 ++++++ .../services/blocking/AssistantServiceImpl.kt | 14 +++++ .../api/services/blocking/AudioService.kt | 16 ++++++ .../api/services/blocking/AudioServiceImpl.kt | 11 ++++ .../api/services/blocking/AzureService.kt | 16 ++++++ .../api/services/blocking/AzureServiceImpl.kt | 16 ++++++ .../api/services/blocking/BatchService.kt | 16 ++++++ .../api/services/blocking/BatchServiceImpl.kt | 18 +++++++ .../api/services/blocking/BedrockService.kt | 16 ++++++ .../services/blocking/BedrockServiceImpl.kt | 16 ++++++ .../api/services/blocking/BudgetService.kt | 16 ++++++ .../services/blocking/BudgetServiceImpl.kt | 17 ++++++ .../api/services/blocking/CacheService.kt | 16 ++++++ .../api/services/blocking/CacheServiceImpl.kt | 14 +++++ .../api/services/blocking/ChatService.kt | 16 ++++++ .../api/services/blocking/ChatServiceImpl.kt | 11 ++++ .../api/services/blocking/CohereService.kt | 16 ++++++ .../services/blocking/CohereServiceImpl.kt | 16 ++++++ .../services/blocking/CompletionService.kt | 18 +++++++ .../blocking/CompletionServiceImpl.kt | 12 +++++ .../api/services/blocking/ConfigService.kt | 16 ++++++ .../services/blocking/ConfigServiceImpl.kt | 11 ++++ .../services/blocking/CredentialService.kt | 18 +++++++ .../blocking/CredentialServiceImpl.kt | 14 +++++ .../api/services/blocking/CustomerService.kt | 16 ++++++ .../services/blocking/CustomerServiceImpl.kt | 18 +++++++ .../api/services/blocking/DeleteService.kt | 16 ++++++ .../services/blocking/DeleteServiceImpl.kt | 12 +++++ .../api/services/blocking/EmbeddingService.kt | 16 ++++++ .../services/blocking/EmbeddingServiceImpl.kt | 12 +++++ .../api/services/blocking/EngineService.kt | 16 ++++++ .../services/blocking/EngineServiceImpl.kt | 13 +++++ .../services/blocking/EuAssemblyaiService.kt | 18 +++++++ .../blocking/EuAssemblyaiServiceImpl.kt | 16 ++++++ .../api/services/blocking/FileService.kt | 16 ++++++ .../api/services/blocking/FileServiceImpl.kt | 15 ++++++ .../services/blocking/FineTuningService.kt | 18 +++++++ .../blocking/FineTuningServiceImpl.kt | 11 ++++ .../api/services/blocking/GeminiService.kt | 16 ++++++ .../services/blocking/GeminiServiceImpl.kt | 16 ++++++ .../api/services/blocking/GlobalService.kt | 16 ++++++ .../services/blocking/GlobalServiceImpl.kt | 11 ++++ .../api/services/blocking/GuardrailService.kt | 16 ++++++ .../services/blocking/GuardrailServiceImpl.kt | 12 +++++ .../api/services/blocking/HealthService.kt | 16 ++++++ .../services/blocking/HealthServiceImpl.kt | 16 ++++++ .../api/services/blocking/ImageService.kt | 16 ++++++ .../api/services/blocking/ImageServiceImpl.kt | 11 ++++ .../hanzo/api/services/blocking/KeyService.kt | 16 ++++++ .../api/services/blocking/KeyServiceImpl.kt | 20 +++++++ .../api/services/blocking/LangfuseService.kt | 16 ++++++ .../services/blocking/LangfuseServiceImpl.kt | 16 ++++++ .../services/blocking/ModelGroupService.kt | 18 +++++++ .../blocking/ModelGroupServiceImpl.kt | 12 +++++ .../api/services/blocking/ModelService.kt | 16 ++++++ .../api/services/blocking/ModelServiceImpl.kt | 13 +++++ .../services/blocking/ModerationService.kt | 18 +++++++ .../blocking/ModerationServiceImpl.kt | 12 +++++ .../api/services/blocking/OpenAIService.kt | 16 ++++++ .../services/blocking/OpenAIServiceImpl.kt | 16 ++++++ .../services/blocking/OrganizationService.kt | 18 +++++++ .../blocking/OrganizationServiceImpl.kt | 18 +++++++ .../api/services/blocking/ProviderService.kt | 16 ++++++ .../services/blocking/ProviderServiceImpl.kt | 12 +++++ .../api/services/blocking/RerankService.kt | 16 ++++++ .../services/blocking/RerankServiceImpl.kt | 14 +++++ .../api/services/blocking/ResponseService.kt | 16 ++++++ .../services/blocking/ResponseServiceImpl.kt | 14 +++++ .../api/services/blocking/RouteService.kt | 16 ++++++ .../api/services/blocking/RouteServiceImpl.kt | 12 +++++ .../api/services/blocking/SettingService.kt | 16 ++++++ .../services/blocking/SettingServiceImpl.kt | 12 +++++ .../api/services/blocking/SpendService.kt | 16 ++++++ .../api/services/blocking/SpendServiceImpl.kt | 14 +++++ .../api/services/blocking/TeamService.kt | 16 ++++++ .../api/services/blocking/TeamServiceImpl.kt | 23 ++++++++ .../api/services/blocking/TestService.kt | 16 ++++++ .../api/services/blocking/TestServiceImpl.kt | 12 +++++ .../api/services/blocking/ThreadService.kt | 16 ++++++ .../services/blocking/ThreadServiceImpl.kt | 13 +++++ .../api/services/blocking/UserService.kt | 16 ++++++ .../api/services/blocking/UserServiceImpl.kt | 16 ++++++ .../api/services/blocking/UtilService.kt | 16 ++++++ .../api/services/blocking/UtilServiceImpl.kt | 14 +++++ .../api/services/blocking/VertexAiService.kt | 16 ++++++ .../services/blocking/VertexAiServiceImpl.kt | 16 ++++++ .../services/blocking/audio/SpeechService.kt | 16 ++++++ .../blocking/audio/SpeechServiceImpl.kt | 12 +++++ .../blocking/audio/TranscriptionService.kt | 18 +++++++ .../audio/TranscriptionServiceImpl.kt | 12 +++++ .../blocking/batches/CancelService.kt | 16 ++++++ .../blocking/batches/CancelServiceImpl.kt | 12 +++++ .../services/blocking/cache/RediService.kt | 16 ++++++ .../blocking/cache/RediServiceImpl.kt | 12 +++++ .../blocking/chat/CompletionService.kt | 18 +++++++ .../blocking/chat/CompletionServiceImpl.kt | 12 +++++ .../config/PassThroughEndpointService.kt | 18 +++++++ .../config/PassThroughEndpointServiceImpl.kt | 17 ++++++ .../services/blocking/engines/ChatService.kt | 16 ++++++ .../blocking/engines/ChatServiceImpl.kt | 12 +++++ .../services/blocking/files/ContentService.kt | 16 ++++++ .../blocking/files/ContentServiceImpl.kt | 12 +++++ .../blocking/finetuning/JobService.kt | 16 ++++++ .../blocking/finetuning/JobServiceImpl.kt | 14 +++++ .../blocking/finetuning/jobs/CancelService.kt | 16 ++++++ .../finetuning/jobs/CancelServiceImpl.kt | 12 +++++ .../services/blocking/global/SpendService.kt | 16 ++++++ .../blocking/global/SpendServiceImpl.kt | 14 +++++ .../blocking/images/GenerationService.kt | 18 +++++++ .../blocking/images/GenerationServiceImpl.kt | 12 +++++ .../blocking/key/RegenerateService.kt | 22 +++++++- .../blocking/key/RegenerateServiceImpl.kt | 14 ++++- .../services/blocking/model/InfoService.kt | 16 ++++++ .../blocking/model/InfoServiceImpl.kt | 12 +++++ .../services/blocking/model/UpdateService.kt | 16 ++++++ .../blocking/model/UpdateServiceImpl.kt | 13 +++++ .../blocking/openai/DeploymentService.kt | 18 +++++++ .../blocking/openai/DeploymentServiceImpl.kt | 13 +++++ .../openai/deployments/ChatService.kt | 16 ++++++ .../openai/deployments/ChatServiceImpl.kt | 12 +++++ .../blocking/organization/InfoService.kt | 16 ++++++ .../blocking/organization/InfoServiceImpl.kt | 13 +++++ .../blocking/responses/InputItemService.kt | 16 ++++++ .../responses/InputItemServiceImpl.kt | 12 +++++ .../services/blocking/team/CallbackService.kt | 16 ++++++ .../blocking/team/CallbackServiceImpl.kt | 13 +++++ .../services/blocking/team/ModelService.kt | 16 ++++++ .../blocking/team/ModelServiceImpl.kt | 13 +++++ .../blocking/threads/MessageService.kt | 16 ++++++ .../blocking/threads/MessageServiceImpl.kt | 13 +++++ .../services/blocking/threads/RunService.kt | 16 ++++++ .../blocking/threads/RunServiceImpl.kt | 12 +++++ .../ai/hanzo/api/core/ClientOptionsTest.kt | 34 ++++++++++++ .../api/core/http/RetryingHttpClientTest.kt | 29 ++++++++-- hanzo-java-example/build.gradle.kts | 9 +++- 298 files changed, 4495 insertions(+), 935 deletions(-) create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ClientOptionsTest.kt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db2f03ae..4d632595 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,17 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -35,6 +40,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 17bad012..33f86979 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: temurin java-version: | @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral -Dorg.gradle.jvmargs="-Xmx8g" --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.HANZO_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.HANZO_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/.stats.yml b/.stats.yml index bb9fef09..affe3eef 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-ec4be99f95dc46e9442eb60f233b2bff271d6f5bf57d7c61a52bc4804f55bbd1.yml -openapi_spec_hash: 87bc62c36bb6028ffd1f3e54a2809099 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-2d6e1036fb1eea7e95cafc281141ead9ef77796e43711b17edccaab67c5e791a.yml +openapi_spec_hash: 12501774d0127be4ec1812d613a58e97 config_hash: 830747463ff4d018b5633ce511e88558 diff --git a/README.md b/README.md index 6941deea..4d9653e9 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,21 @@ See this table for the available options: > Don't create more than one client in the same application. Each client has a connection pool and > thread pools, which are more efficient to share between requests. +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import ai.hanzo.api.client.HanzoClient; + +HanzoClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + ## Requests and responses To send a request to the Hanzo API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. diff --git a/bin/check-release-environment b/bin/check-release-environment index 8f014071..3a6a7b4a 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,19 +3,19 @@ errors=() if [ -z "${SONATYPE_USERNAME}" ]; then - errors+=("The HANZO_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${SONATYPE_PASSWORD}" ]; then - errors+=("The HANZO_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_KEY}" ]; then - errors+=("The HANZO_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_PASSWORD}" ]; then - errors+=("The HANZO_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} diff --git a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts index 657800f3..d4c39529 100644 --- a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts @@ -53,3 +53,7 @@ configure { } } } + +tasks.withType().configureEach { + isZip64 = true +} diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt index 77b25cb0..c3534112 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt @@ -163,13 +163,7 @@ class HanzoOkHttpClient private constructor() { fun build(): HanzoClient = HanzoClientImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt index 01a34f83..26d03728 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt @@ -163,13 +163,7 @@ class HanzoOkHttpClientAsync private constructor() { fun build(): HanzoClientAsync = HanzoClientAsyncImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt index 3b93ec84..fd37b7fa 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt @@ -2,7 +2,6 @@ package ai.hanzo.api.client.okhttp import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.Timeout -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.HttpClient import ai.hanzo.api.core.http.HttpMethod @@ -17,7 +16,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -28,8 +26,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient -private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { @@ -142,11 +139,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun HttpRequest.toUrl(): String { - url?.let { - return it - } - - val builder = baseUrl.newBuilder() + val builder = baseUrl.toHttpUrl().newBuilder() pathSegments.forEach(builder::addPathSegment) queryParams.keys().forEach { key -> queryParams.values(key).forEach { builder.addQueryParameter(key, it) } @@ -196,12 +189,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { - private var baseUrl: HttpUrl? = null private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) @@ -216,8 +206,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) - .build(), - checkRequired("baseUrl", baseUrl), + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } ) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt index 5ba61eca..f5bc1079 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.client +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.ClientGetHomeParams @@ -54,6 +55,7 @@ import ai.hanzo.api.services.blocking.UserService import ai.hanzo.api.services.blocking.UtilService import ai.hanzo.api.services.blocking.VertexAiService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer /** * A client for interacting with the Hanzo REST API synchronously. You can also switch to @@ -84,6 +86,13 @@ interface HanzoClient { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HanzoClient + fun models(): ModelService fun openai(): OpenAIService @@ -213,6 +222,13 @@ interface HanzoClient { /** A view of [HanzoClient] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HanzoClient.WithRawResponse + fun models(): ModelService.WithRawResponse fun openai(): OpenAIService.WithRawResponse diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt index e9905a45..7677078f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.client +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.ClientGetHomeParams @@ -53,8 +54,8 @@ import ai.hanzo.api.services.async.ThreadServiceAsync import ai.hanzo.api.services.async.UserServiceAsync import ai.hanzo.api.services.async.UtilServiceAsync import ai.hanzo.api.services.async.VertexAiServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer /** * A client for interacting with the Hanzo REST API asynchronously. You can also switch to @@ -85,6 +86,13 @@ interface HanzoClientAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HanzoClientAsync + fun models(): ModelServiceAsync fun openai(): OpenAIServiceAsync @@ -215,6 +223,13 @@ interface HanzoClientAsync { /** A view of [HanzoClientAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HanzoClientAsync.WithRawResponse + fun models(): ModelServiceAsync.WithRawResponse fun openai(): OpenAIServiceAsync.WithRawResponse @@ -315,26 +330,22 @@ interface HanzoClientAsync { * Returns a raw HTTP response for `get /`, but is otherwise the same as * [HanzoClientAsync.getHome]. */ - @MustBeClosed fun getHome(): CompletableFuture> = getHome(ClientGetHomeParams.none()) /** @see [getHome] */ - @MustBeClosed fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [getHome] */ - @MustBeClosed fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none() ): CompletableFuture> = getHome(params, RequestOptions.none()) /** @see [getHome] */ - @MustBeClosed fun getHome( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt index 81849c7f..3e323ad8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt @@ -112,6 +112,7 @@ import ai.hanzo.api.services.async.UtilServiceAsyncImpl import ai.hanzo.api.services.async.VertexAiServiceAsync import ai.hanzo.api.services.async.VertexAiServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClientAsync { @@ -310,6 +311,9 @@ class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClie override fun withRawResponse(): HanzoClientAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HanzoClientAsync = + HanzoClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun models(): ModelServiceAsync = models override fun openai(): OpenAIServiceAsync = openai @@ -612,6 +616,13 @@ class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClie BudgetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): HanzoClientAsync.WithRawResponse = + HanzoClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun models(): ModelServiceAsync.WithRawResponse = models override fun openai(): OpenAIServiceAsync.WithRawResponse = openai @@ -719,6 +730,7 @@ class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt index 866f48ca..b2890a0c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt @@ -111,6 +111,7 @@ import ai.hanzo.api.services.blocking.UtilService import ai.hanzo.api.services.blocking.UtilServiceImpl import ai.hanzo.api.services.blocking.VertexAiService import ai.hanzo.api.services.blocking.VertexAiServiceImpl +import java.util.function.Consumer class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { @@ -263,6 +264,9 @@ class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { override fun withRawResponse(): HanzoClient.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HanzoClient = + HanzoClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun models(): ModelService = models override fun openai(): OpenAIService = openai @@ -565,6 +569,13 @@ class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { BudgetServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): HanzoClient.WithRawResponse = + HanzoClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun models(): ModelService.WithRawResponse = models override fun openai(): OpenAIService.WithRawResponse = openai @@ -672,6 +683,7 @@ class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt index 9921cadd..b27c08f7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt @@ -9,6 +9,8 @@ import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper import java.time.Clock +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class ClientOptions private constructor( @@ -17,7 +19,7 @@ private constructor( @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, + private val baseUrl: String?, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -32,6 +34,8 @@ private constructor( } } + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + fun toBuilder() = Builder().from(this) companion object { @@ -61,7 +65,7 @@ private constructor( private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() - private var baseUrl: String = PRODUCTION_URL + private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false @@ -84,7 +88,9 @@ private constructor( apiKey = clientOptions.apiKey } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility @@ -94,7 +100,10 @@ private constructor( fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -186,8 +195,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun baseUrl(): String = baseUrl - fun fromEnv() = apply { System.getenv("HANZO_BASE_URL")?.let { baseUrl(it) } System.getenv("HANZO_API_KEY")?.let { apiKey(it) } @@ -229,13 +236,11 @@ private constructor( return ClientOptions( httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build(), checkJacksonVersionCompatibility, jsonMapper, clock, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt index 94495ca6..9afb39ca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt @@ -6,7 +6,7 @@ import ai.hanzo.api.core.toImmutable class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, - @get:JvmName("url") val url: String?, + @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("pathSegments") val pathSegments: List, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @@ -16,7 +16,7 @@ private constructor( fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = - "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -25,7 +25,7 @@ private constructor( class Builder internal constructor() { private var method: HttpMethod? = null - private var url: String? = null + private var baseUrl: String? = null private var pathSegments: MutableList = mutableListOf() private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() @@ -34,7 +34,7 @@ private constructor( @JvmSynthetic internal fun from(request: HttpRequest) = apply { method = request.method - url = request.url + baseUrl = request.baseUrl pathSegments = request.pathSegments.toMutableList() headers = request.headers.toBuilder() queryParams = request.queryParams.toBuilder() @@ -43,7 +43,7 @@ private constructor( fun method(method: HttpMethod) = apply { this.method = method } - fun url(url: String) = apply { this.url = url } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } @@ -136,7 +136,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( checkRequired("method", method), - url, + checkRequired("baseUrl", baseUrl), pathSegments.toImmutable(), headers.build(), queryParams.build(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsync.kt index bbe08e41..047ebf53 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.active.ActiveListCallbacksParams import ai.hanzo.api.models.active.ActiveListCallbacksResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ActiveServiceAsync { @@ -16,6 +17,13 @@ interface ActiveServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ActiveServiceAsync + /** * Returns a list of llm level settings * @@ -64,30 +72,35 @@ interface ActiveServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ActiveServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /active/callbacks`, but is otherwise the same as * [ActiveServiceAsync.listCallbacks]. */ - @MustBeClosed fun listCallbacks(): CompletableFuture> = listCallbacks(ActiveListCallbacksParams.none()) /** @see [listCallbacks] */ - @MustBeClosed fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [listCallbacks] */ - @MustBeClosed fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none() ): CompletableFuture> = listCallbacks(params, RequestOptions.none()) /** @see [listCallbacks] */ - @MustBeClosed fun listCallbacks( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt index 467a27f5..27af8261 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.active.ActiveListCallbacksParams import ai.hanzo.api.models.active.ActiveListCallbacksResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ActiveServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ActiveServiceAsync { @@ -27,6 +28,9 @@ class ActiveServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): ActiveServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ActiveServiceAsync = + ActiveServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun listCallbacks( params: ActiveListCallbacksParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ActiveServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ActiveServiceAsync.WithRawResponse = + ActiveServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listCallbacksHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class ActiveServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("active", "callbacks") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt index 28322380..ca8425d6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.AddAddAllowedIpResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AddServiceAsync { @@ -16,6 +17,13 @@ interface AddServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AddServiceAsync + /** Add Allowed Ip */ fun addAllowedIp(params: AddAddAllowedIpParams): CompletableFuture = addAllowedIp(params, RequestOptions.none()) @@ -29,18 +37,23 @@ interface AddServiceAsync { /** A view of [AddServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AddServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /add/allowed_ip`, but is otherwise the same as * [AddServiceAsync.addAllowedIp]. */ - @MustBeClosed fun addAllowedIp( params: AddAddAllowedIpParams ): CompletableFuture> = addAllowedIp(params, RequestOptions.none()) /** @see [addAllowedIp] */ - @MustBeClosed fun addAllowedIp( params: AddAddAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt index 25718086..f538519a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.AddAddAllowedIpResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class AddServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AddServiceAsync { @@ -28,6 +29,9 @@ class AddServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): AddServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AddServiceAsync = + AddServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun addAllowedIp( params: AddAddAllowedIpParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class AddServiceAsyncImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AddServiceAsync.WithRawResponse = + AddServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val addAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class AddServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("add", "allowed_ip") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt index a49ccb0d..809df39b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.anthropic.AnthropicCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.anthropic.AnthropicRetrieveParams import ai.hanzo.api.models.anthropic.AnthropicRetrieveResponse import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import ai.hanzo.api.models.anthropic.AnthropicUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AnthropicServiceAsync { @@ -24,6 +25,13 @@ interface AnthropicServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AnthropicServiceAsync + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ fun create(endpoint: String): CompletableFuture = create(endpoint, AnthropicCreateParams.none()) @@ -205,16 +213,23 @@ interface AnthropicServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AnthropicServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, AnthropicCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), @@ -223,7 +238,6 @@ interface AnthropicServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), @@ -231,21 +245,18 @@ interface AnthropicServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: AnthropicCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: AnthropicCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -256,14 +267,12 @@ interface AnthropicServiceAsync { * Returns a raw HTTP response for `get /anthropic/{endpoint}`, but is otherwise the same as * [AnthropicServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( endpoint: String ): CompletableFuture> = retrieve(endpoint, AnthropicRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), @@ -272,7 +281,6 @@ interface AnthropicServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), @@ -280,21 +288,18 @@ interface AnthropicServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: AnthropicRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: AnthropicRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -305,12 +310,10 @@ interface AnthropicServiceAsync { * Returns a raw HTTP response for `put /anthropic/{endpoint}`, but is otherwise the same as * [AnthropicServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, AnthropicUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), @@ -319,7 +322,6 @@ interface AnthropicServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), @@ -327,21 +329,18 @@ interface AnthropicServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: AnthropicUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: AnthropicUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -352,12 +351,10 @@ interface AnthropicServiceAsync { * Returns a raw HTTP response for `delete /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, AnthropicDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), @@ -366,7 +363,6 @@ interface AnthropicServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), @@ -374,21 +370,18 @@ interface AnthropicServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: AnthropicDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: AnthropicDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -399,12 +392,10 @@ interface AnthropicServiceAsync { * Returns a raw HTTP response for `patch /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicServiceAsync.modify]. */ - @MustBeClosed fun modify(endpoint: String): CompletableFuture> = modify(endpoint, AnthropicModifyParams.none()) /** @see [modify] */ - @MustBeClosed fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), @@ -413,7 +404,6 @@ interface AnthropicServiceAsync { modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [modify] */ - @MustBeClosed fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), @@ -421,21 +411,18 @@ interface AnthropicServiceAsync { modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ - @MustBeClosed fun modify( params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [modify] */ - @MustBeClosed fun modify( params: AnthropicModifyParams ): CompletableFuture> = modify(params, RequestOptions.none()) /** @see [modify] */ - @MustBeClosed fun modify( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt index 94739ec3..9e915c48 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.anthropic.AnthropicRetrieveResponse import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import ai.hanzo.api.models.anthropic.AnthropicUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): AnthropicServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AnthropicServiceAsync = + AnthropicServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AnthropicCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AnthropicServiceAsync.WithRawResponse = + AnthropicServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt index fc13add3..7fc34dea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.assemblyai.AssemblyaiCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveParams import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveResponse import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AssemblyaiServiceAsync { @@ -24,6 +25,13 @@ interface AssemblyaiServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AssemblyaiServiceAsync + /** Assemblyai Proxy Route */ fun create(endpoint: String): CompletableFuture = create(endpoint, AssemblyaiCreateParams.none()) @@ -206,16 +214,23 @@ interface AssemblyaiServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AssemblyaiServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, AssemblyaiCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), @@ -224,7 +239,6 @@ interface AssemblyaiServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), @@ -232,21 +246,18 @@ interface AssemblyaiServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: AssemblyaiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -257,14 +268,12 @@ interface AssemblyaiServiceAsync { * Returns a raw HTTP response for `get /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( endpoint: String ): CompletableFuture> = retrieve(endpoint, AssemblyaiRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), @@ -273,7 +282,6 @@ interface AssemblyaiServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), @@ -281,21 +289,18 @@ interface AssemblyaiServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: AssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: AssemblyaiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -306,12 +311,10 @@ interface AssemblyaiServiceAsync { * Returns a raw HTTP response for `put /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, AssemblyaiUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), @@ -320,7 +323,6 @@ interface AssemblyaiServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), @@ -328,21 +330,18 @@ interface AssemblyaiServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: AssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: AssemblyaiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -353,12 +352,10 @@ interface AssemblyaiServiceAsync { * Returns a raw HTTP response for `delete /assemblyai/{endpoint}`, but is otherwise the * same as [AssemblyaiServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, AssemblyaiDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), @@ -367,7 +364,6 @@ interface AssemblyaiServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), @@ -375,21 +371,18 @@ interface AssemblyaiServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: AssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: AssemblyaiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -400,12 +393,10 @@ interface AssemblyaiServiceAsync { * Returns a raw HTTP response for `patch /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, AssemblyaiPatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), @@ -414,7 +405,6 @@ interface AssemblyaiServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), @@ -422,21 +412,18 @@ interface AssemblyaiServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: AssemblyaiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt index d904cb86..fd209e06 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveResponse import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): AssemblyaiServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AssemblyaiServiceAsync = + AssemblyaiServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AssemblyaiServiceAsync.WithRawResponse = + AssemblyaiServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt index b83f912a..8734e4fc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.assistants.AssistantCreateParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.assistants.AssistantDeleteParams import ai.hanzo.api.models.assistants.AssistantDeleteResponse import ai.hanzo.api.models.assistants.AssistantListParams import ai.hanzo.api.models.assistants.AssistantListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AssistantServiceAsync { @@ -20,6 +21,13 @@ interface AssistantServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AssistantServiceAsync + /** * Create assistant * @@ -111,30 +119,35 @@ interface AssistantServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AssistantServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/assistants`, but is otherwise the same as * [AssistantServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(AssistantCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: AssistantCreateParams = AssistantCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: AssistantCreateParams = AssistantCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -144,26 +157,22 @@ interface AssistantServiceAsync { * Returns a raw HTTP response for `get /v1/assistants`, but is otherwise the same as * [AssistantServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(AssistantListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: AssistantListParams = AssistantListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: AssistantListParams = AssistantListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -173,14 +182,12 @@ interface AssistantServiceAsync { * Returns a raw HTTP response for `delete /v1/assistants/{assistant_id}`, but is otherwise * the same as [AssistantServiceAsync.delete]. */ - @MustBeClosed fun delete( assistantId: String ): CompletableFuture> = delete(assistantId, AssistantDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), @@ -189,7 +196,6 @@ interface AssistantServiceAsync { delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), @@ -197,21 +203,18 @@ interface AssistantServiceAsync { delete(assistantId, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: AssistantDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( assistantId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt index 4b18e822..ef5767e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.models.assistants.AssistantDeleteResponse import ai.hanzo.api.models.assistants.AssistantListParams import ai.hanzo.api.models.assistants.AssistantListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AssistantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): AssistantServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AssistantServiceAsync = + AssistantServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AssistantCreateParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AssistantServiceAsync.WithRawResponse = + AssistantServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -71,6 +82,7 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "assistants") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -102,6 +114,7 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "assistants") .build() .prepareAsync(clientOptions, params) @@ -135,6 +148,7 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "assistants", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsync.kt index 3971b067..1d445570 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsync.kt @@ -2,8 +2,10 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.audio.SpeechServiceAsync import ai.hanzo.api.services.async.audio.TranscriptionServiceAsync +import java.util.function.Consumer interface AudioServiceAsync { @@ -12,6 +14,13 @@ interface AudioServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudioServiceAsync + fun speech(): SpeechServiceAsync fun transcriptions(): TranscriptionServiceAsync @@ -19,6 +28,15 @@ interface AudioServiceAsync { /** A view of [AudioServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AudioServiceAsync.WithRawResponse + fun speech(): SpeechServiceAsync.WithRawResponse fun transcriptions(): TranscriptionServiceAsync.WithRawResponse diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsyncImpl.kt index 9836ceb8..4ce47cf6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AudioServiceAsyncImpl.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.services.async.audio.SpeechServiceAsync import ai.hanzo.api.services.async.audio.SpeechServiceAsyncImpl import ai.hanzo.api.services.async.audio.TranscriptionServiceAsync import ai.hanzo.api.services.async.audio.TranscriptionServiceAsyncImpl +import java.util.function.Consumer class AudioServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AudioServiceAsync { @@ -23,6 +24,9 @@ class AudioServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): AudioServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AudioServiceAsync = + AudioServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun speech(): SpeechServiceAsync = speech override fun transcriptions(): TranscriptionServiceAsync = transcriptions @@ -38,6 +42,13 @@ class AudioServiceAsyncImpl internal constructor(private val clientOptions: Clie TranscriptionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): AudioServiceAsync.WithRawResponse = + AudioServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun speech(): SpeechServiceAsync.WithRawResponse = speech override fun transcriptions(): TranscriptionServiceAsync.WithRawResponse = transcriptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt index a97fb2b1..3927a1a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.azure.AzureCallParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.azure.AzurePatchParams import ai.hanzo.api.models.azure.AzurePatchResponse import ai.hanzo.api.models.azure.AzureUpdateParams import ai.hanzo.api.models.azure.AzureUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AzureServiceAsync { @@ -24,6 +25,13 @@ interface AzureServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AzureServiceAsync + /** * Call any azure endpoint using the proxy. * @@ -221,16 +229,23 @@ interface AzureServiceAsync { /** A view of [AzureServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AzureServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, AzureCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), @@ -239,7 +254,6 @@ interface AzureServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), @@ -247,21 +261,18 @@ interface AzureServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: AzureCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: AzureCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -272,12 +283,10 @@ interface AzureServiceAsync { * Returns a raw HTTP response for `put /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, AzureUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), @@ -286,7 +295,6 @@ interface AzureServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), @@ -294,21 +302,18 @@ interface AzureServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: AzureUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: AzureUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -319,12 +324,10 @@ interface AzureServiceAsync { * Returns a raw HTTP response for `delete /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, AzureDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), @@ -333,7 +336,6 @@ interface AzureServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), @@ -341,21 +343,18 @@ interface AzureServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: AzureDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: AzureDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -366,12 +365,10 @@ interface AzureServiceAsync { * Returns a raw HTTP response for `get /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.call]. */ - @MustBeClosed fun call(endpoint: String): CompletableFuture> = call(endpoint, AzureCallParams.none()) /** @see [call] */ - @MustBeClosed fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), @@ -380,7 +377,6 @@ interface AzureServiceAsync { call(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [call] */ - @MustBeClosed fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), @@ -388,19 +384,16 @@ interface AzureServiceAsync { call(endpoint, params, RequestOptions.none()) /** @see [call] */ - @MustBeClosed fun call( params: AzureCallParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [call] */ - @MustBeClosed fun call(params: AzureCallParams): CompletableFuture> = call(params, RequestOptions.none()) /** @see [call] */ - @MustBeClosed fun call( endpoint: String, requestOptions: RequestOptions, @@ -411,12 +404,10 @@ interface AzureServiceAsync { * Returns a raw HTTP response for `patch /azure/{endpoint}`, but is otherwise the same as * [AzureServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, AzurePatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), @@ -425,7 +416,6 @@ interface AzureServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), @@ -433,21 +423,18 @@ interface AzureServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: AzurePatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt index 44bfefcc..a21af70a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.azure.AzurePatchResponse import ai.hanzo.api.models.azure.AzureUpdateParams import ai.hanzo.api.models.azure.AzureUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AzureServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): AzureServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AzureServiceAsync = + AzureServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AzureCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AzureServiceAsync.WithRawResponse = + AzureServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -160,6 +173,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -225,6 +240,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt index a448f337..be570111 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.batches.BatchCancelWithProviderParams @@ -19,8 +20,8 @@ import ai.hanzo.api.models.batches.BatchRetrieveResponse import ai.hanzo.api.models.batches.BatchRetrieveWithProviderParams import ai.hanzo.api.models.batches.BatchRetrieveWithProviderResponse import ai.hanzo.api.services.async.batches.CancelServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BatchServiceAsync { @@ -29,6 +30,13 @@ interface BatchServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchServiceAsync + fun cancel(): CancelServiceAsync /** @@ -311,32 +319,37 @@ interface BatchServiceAsync { /** A view of [BatchServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse + fun cancel(): CancelServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /v1/batches`, but is otherwise the same as * [BatchServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(BatchCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: BatchCreateParams = BatchCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: BatchCreateParams = BatchCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -346,12 +359,10 @@ interface BatchServiceAsync { * Returns a raw HTTP response for `get /v1/batches/{batch_id}`, but is otherwise the same * as [BatchServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(batchId: String): CompletableFuture> = retrieve(batchId, BatchRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), @@ -360,7 +371,6 @@ interface BatchServiceAsync { retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), @@ -368,21 +378,18 @@ interface BatchServiceAsync { retrieve(batchId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: BatchRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: BatchRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( batchId: String, requestOptions: RequestOptions, @@ -393,26 +400,22 @@ interface BatchServiceAsync { * Returns a raw HTTP response for `get /v1/batches`, but is otherwise the same as * [BatchServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(BatchListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: BatchListParams = BatchListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: BatchListParams = BatchListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -422,7 +425,6 @@ interface BatchServiceAsync { * Returns a raw HTTP response for `post /{provider}/v1/batches/{batch_id}/cancel`, but is * otherwise the same as [BatchServiceAsync.cancelWithProvider]. */ - @MustBeClosed fun cancelWithProvider( batchId: String, params: BatchCancelWithProviderParams, @@ -430,7 +432,6 @@ interface BatchServiceAsync { cancelWithProvider(batchId, params, RequestOptions.none()) /** @see [cancelWithProvider] */ - @MustBeClosed fun cancelWithProvider( batchId: String, params: BatchCancelWithProviderParams, @@ -439,14 +440,12 @@ interface BatchServiceAsync { cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) /** @see [cancelWithProvider] */ - @MustBeClosed fun cancelWithProvider( params: BatchCancelWithProviderParams ): CompletableFuture> = cancelWithProvider(params, RequestOptions.none()) /** @see [cancelWithProvider] */ - @MustBeClosed fun cancelWithProvider( params: BatchCancelWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -456,14 +455,12 @@ interface BatchServiceAsync { * Returns a raw HTTP response for `post /{provider}/v1/batches`, but is otherwise the same * as [BatchServiceAsync.createWithProvider]. */ - @MustBeClosed fun createWithProvider( provider: String ): CompletableFuture> = createWithProvider(provider, BatchCreateWithProviderParams.none()) /** @see [createWithProvider] */ - @MustBeClosed fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), @@ -472,7 +469,6 @@ interface BatchServiceAsync { createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) /** @see [createWithProvider] */ - @MustBeClosed fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), @@ -480,21 +476,18 @@ interface BatchServiceAsync { createWithProvider(provider, params, RequestOptions.none()) /** @see [createWithProvider] */ - @MustBeClosed fun createWithProvider( params: BatchCreateWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [createWithProvider] */ - @MustBeClosed fun createWithProvider( params: BatchCreateWithProviderParams ): CompletableFuture> = createWithProvider(params, RequestOptions.none()) /** @see [createWithProvider] */ - @MustBeClosed fun createWithProvider( provider: String, requestOptions: RequestOptions, @@ -505,14 +498,12 @@ interface BatchServiceAsync { * Returns a raw HTTP response for `get /{provider}/v1/batches`, but is otherwise the same * as [BatchServiceAsync.listWithProvider]. */ - @MustBeClosed fun listWithProvider( provider: String ): CompletableFuture> = listWithProvider(provider, BatchListWithProviderParams.none()) /** @see [listWithProvider] */ - @MustBeClosed fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), @@ -521,7 +512,6 @@ interface BatchServiceAsync { listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) /** @see [listWithProvider] */ - @MustBeClosed fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), @@ -529,21 +519,18 @@ interface BatchServiceAsync { listWithProvider(provider, params, RequestOptions.none()) /** @see [listWithProvider] */ - @MustBeClosed fun listWithProvider( params: BatchListWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [listWithProvider] */ - @MustBeClosed fun listWithProvider( params: BatchListWithProviderParams ): CompletableFuture> = listWithProvider(params, RequestOptions.none()) /** @see [listWithProvider] */ - @MustBeClosed fun listWithProvider( provider: String, requestOptions: RequestOptions, @@ -554,7 +541,6 @@ interface BatchServiceAsync { * Returns a raw HTTP response for `get /{provider}/v1/batches/{batch_id}`, but is otherwise * the same as [BatchServiceAsync.retrieveWithProvider]. */ - @MustBeClosed fun retrieveWithProvider( batchId: String, params: BatchRetrieveWithProviderParams, @@ -562,7 +548,6 @@ interface BatchServiceAsync { retrieveWithProvider(batchId, params, RequestOptions.none()) /** @see [retrieveWithProvider] */ - @MustBeClosed fun retrieveWithProvider( batchId: String, params: BatchRetrieveWithProviderParams, @@ -571,14 +556,12 @@ interface BatchServiceAsync { retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) /** @see [retrieveWithProvider] */ - @MustBeClosed fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): CompletableFuture> = retrieveWithProvider(params, RequestOptions.none()) /** @see [retrieveWithProvider] */ - @MustBeClosed fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt index 2c706f13..c62ba85a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt @@ -33,6 +33,7 @@ import ai.hanzo.api.models.batches.BatchRetrieveWithProviderResponse import ai.hanzo.api.services.async.batches.CancelServiceAsync import ai.hanzo.api.services.async.batches.CancelServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,6 +47,9 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BatchServiceAsync = + BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun cancel(): CancelServiceAsync = cancel override fun create( @@ -106,6 +110,13 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie CancelServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse = + BatchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun cancel(): CancelServiceAsync.WithRawResponse = cancel private val createHandler: Handler = @@ -119,6 +130,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "batches") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -153,6 +165,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "batches", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -182,6 +195,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "batches") .build() .prepareAsync(clientOptions, params) @@ -215,6 +229,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( params._pathParam(0), "v1", @@ -255,6 +270,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "batches") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -289,6 +305,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "batches") .build() .prepareAsync(clientOptions, params) @@ -322,6 +339,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "batches", params._pathParam(1)) .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt index 3fa1d6ca..ad605d1a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.bedrock.BedrockCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.bedrock.BedrockRetrieveParams import ai.hanzo.api.models.bedrock.BedrockRetrieveResponse import ai.hanzo.api.models.bedrock.BedrockUpdateParams import ai.hanzo.api.models.bedrock.BedrockUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BedrockServiceAsync { @@ -24,6 +25,13 @@ interface BedrockServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BedrockServiceAsync + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ fun create(endpoint: String): CompletableFuture = create(endpoint, BedrockCreateParams.none()) @@ -205,16 +213,23 @@ interface BedrockServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BedrockServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, BedrockCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), @@ -223,7 +238,6 @@ interface BedrockServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), @@ -231,21 +245,18 @@ interface BedrockServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: BedrockCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: BedrockCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -256,14 +267,12 @@ interface BedrockServiceAsync { * Returns a raw HTTP response for `get /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( endpoint: String ): CompletableFuture> = retrieve(endpoint, BedrockRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), @@ -272,7 +281,6 @@ interface BedrockServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), @@ -280,21 +288,18 @@ interface BedrockServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: BedrockRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: BedrockRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -305,12 +310,10 @@ interface BedrockServiceAsync { * Returns a raw HTTP response for `put /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, BedrockUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), @@ -319,7 +322,6 @@ interface BedrockServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), @@ -327,21 +329,18 @@ interface BedrockServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: BedrockUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: BedrockUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -352,12 +351,10 @@ interface BedrockServiceAsync { * Returns a raw HTTP response for `delete /bedrock/{endpoint}`, but is otherwise the same * as [BedrockServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, BedrockDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), @@ -366,7 +363,6 @@ interface BedrockServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), @@ -374,21 +370,18 @@ interface BedrockServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: BedrockDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: BedrockDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -399,12 +392,10 @@ interface BedrockServiceAsync { * Returns a raw HTTP response for `patch /bedrock/{endpoint}`, but is otherwise the same as * [BedrockServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, BedrockPatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), @@ -413,7 +404,6 @@ interface BedrockServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), @@ -421,21 +411,18 @@ interface BedrockServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: BedrockPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt index c0e8c07c..d4e83d74 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.bedrock.BedrockRetrieveResponse import ai.hanzo.api.models.bedrock.BedrockUpdateParams import ai.hanzo.api.models.bedrock.BedrockUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BedrockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): BedrockServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BedrockServiceAsync = + BedrockServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: BedrockCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BedrockServiceAsync.WithRawResponse = + BedrockServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt index 0e57f34b..75b4030e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.budget.BudgetCreateParams @@ -16,8 +17,8 @@ import ai.hanzo.api.models.budget.BudgetSettingsParams import ai.hanzo.api.models.budget.BudgetSettingsResponse import ai.hanzo.api.models.budget.BudgetUpdateParams import ai.hanzo.api.models.budget.BudgetUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BudgetServiceAsync { @@ -26,6 +27,13 @@ interface BudgetServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BudgetServiceAsync + /** * Create a new budget object. Can apply this to teams, orgs, end-users, keys. * @@ -146,18 +154,25 @@ interface BudgetServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BudgetServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /budget/new`, but is otherwise the same as * [BudgetServiceAsync.create]. */ - @MustBeClosed fun create( params: BudgetCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: BudgetCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -167,14 +182,12 @@ interface BudgetServiceAsync { * Returns a raw HTTP response for `post /budget/update`, but is otherwise the same as * [BudgetServiceAsync.update]. */ - @MustBeClosed fun update( params: BudgetUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: BudgetUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -184,26 +197,22 @@ interface BudgetServiceAsync { * Returns a raw HTTP response for `get /budget/list`, but is otherwise the same as * [BudgetServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(BudgetListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: BudgetListParams = BudgetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: BudgetListParams = BudgetListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -213,14 +222,12 @@ interface BudgetServiceAsync { * Returns a raw HTTP response for `post /budget/delete`, but is otherwise the same as * [BudgetServiceAsync.delete]. */ - @MustBeClosed fun delete( params: BudgetDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: BudgetDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -230,12 +237,10 @@ interface BudgetServiceAsync { * Returns a raw HTTP response for `post /budget/info`, but is otherwise the same as * [BudgetServiceAsync.info]. */ - @MustBeClosed fun info(params: BudgetInfoParams): CompletableFuture> = info(params, RequestOptions.none()) /** @see [info] */ - @MustBeClosed fun info( params: BudgetInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -245,14 +250,12 @@ interface BudgetServiceAsync { * Returns a raw HTTP response for `get /budget/settings`, but is otherwise the same as * [BudgetServiceAsync.settings]. */ - @MustBeClosed fun settings( params: BudgetSettingsParams ): CompletableFuture> = settings(params, RequestOptions.none()) /** @see [settings] */ - @MustBeClosed fun settings( params: BudgetSettingsParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt index 401091e0..3f6341a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt @@ -28,6 +28,7 @@ import ai.hanzo.api.models.budget.BudgetSettingsResponse import ai.hanzo.api.models.budget.BudgetUpdateParams import ai.hanzo.api.models.budget.BudgetUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class BudgetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BudgetServiceAsync { @@ -38,6 +39,9 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): BudgetServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BudgetServiceAsync = + BudgetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: BudgetCreateParams, requestOptions: RequestOptions, @@ -85,6 +89,13 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BudgetServiceAsync.WithRawResponse = + BudgetServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -96,6 +107,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -127,6 +139,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -157,6 +170,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "list") .build() .prepareAsync(clientOptions, params) @@ -187,6 +201,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -217,6 +232,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "info") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -248,6 +264,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "settings") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt index fb790dce..4733aacd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.cache.CacheDeleteParams @@ -11,8 +12,8 @@ import ai.hanzo.api.models.cache.CacheFlushAllResponse import ai.hanzo.api.models.cache.CachePingParams import ai.hanzo.api.models.cache.CachePingResponse import ai.hanzo.api.services.async.cache.RediServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CacheServiceAsync { @@ -21,6 +22,13 @@ interface CacheServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CacheServiceAsync + fun redis(): RediServiceAsync /** @@ -100,32 +108,37 @@ interface CacheServiceAsync { /** A view of [CacheServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CacheServiceAsync.WithRawResponse + fun redis(): RediServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /cache/delete`, but is otherwise the same as * [CacheServiceAsync.delete]. */ - @MustBeClosed fun delete(): CompletableFuture> = delete(CacheDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: CacheDeleteParams = CacheDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: CacheDeleteParams = CacheDeleteParams.none() ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( requestOptions: RequestOptions ): CompletableFuture> = @@ -135,26 +148,22 @@ interface CacheServiceAsync { * Returns a raw HTTP response for `post /cache/flushall`, but is otherwise the same as * [CacheServiceAsync.flushAll]. */ - @MustBeClosed fun flushAll(): CompletableFuture> = flushAll(CacheFlushAllParams.none()) /** @see [flushAll] */ - @MustBeClosed fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [flushAll] */ - @MustBeClosed fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none() ): CompletableFuture> = flushAll(params, RequestOptions.none()) /** @see [flushAll] */ - @MustBeClosed fun flushAll( requestOptions: RequestOptions ): CompletableFuture> = @@ -164,26 +173,22 @@ interface CacheServiceAsync { * Returns a raw HTTP response for `get /cache/ping`, but is otherwise the same as * [CacheServiceAsync.ping]. */ - @MustBeClosed fun ping(): CompletableFuture> = ping(CachePingParams.none()) /** @see [ping] */ - @MustBeClosed fun ping( params: CachePingParams = CachePingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [ping] */ - @MustBeClosed fun ping( params: CachePingParams = CachePingParams.none() ): CompletableFuture> = ping(params, RequestOptions.none()) /** @see [ping] */ - @MustBeClosed fun ping( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt index 19d7d0e7..c18ea321 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.models.cache.CachePingResponse import ai.hanzo.api.services.async.cache.RediServiceAsync import ai.hanzo.api.services.async.cache.RediServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CacheServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CacheServiceAsync { @@ -36,6 +37,9 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CacheServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CacheServiceAsync = + CacheServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun redis(): RediServiceAsync = redis override fun delete( @@ -68,6 +72,13 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie RediServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CacheServiceAsync.WithRawResponse = + CacheServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun redis(): RediServiceAsync.WithRawResponse = redis private val deleteHandler: Handler = @@ -81,6 +92,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "delete") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -112,6 +124,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "flushall") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -142,6 +155,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "ping") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsync.kt index 29bea4a2..9895d3d8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsync.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.chat.CompletionServiceAsync +import java.util.function.Consumer interface ChatServiceAsync { @@ -11,11 +13,25 @@ interface ChatServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync + fun completions(): CompletionServiceAsync /** A view of [ChatServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync.WithRawResponse + fun completions(): CompletionServiceAsync.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsyncImpl.kt index c0eef6d4..445fe9a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ChatServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.chat.CompletionServiceAsync import ai.hanzo.api.services.async.chat.CompletionServiceAsyncImpl +import java.util.function.Consumer class ChatServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ChatServiceAsync { @@ -19,6 +20,9 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): ChatServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatServiceAsync = + ChatServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun completions(): CompletionServiceAsync = completions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien CompletionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ChatServiceAsync.WithRawResponse = + ChatServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun completions(): CompletionServiceAsync.WithRawResponse = completions } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt index c5415081..7bfdca85 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.cohere.CohereCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.cohere.CohereRetrieveParams import ai.hanzo.api.models.cohere.CohereRetrieveResponse import ai.hanzo.api.models.cohere.CohereUpdateParams import ai.hanzo.api.models.cohere.CohereUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CohereServiceAsync { @@ -24,6 +25,13 @@ interface CohereServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CohereServiceAsync + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ fun create(endpoint: String): CompletableFuture = create(endpoint, CohereCreateParams.none()) @@ -204,16 +212,23 @@ interface CohereServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CohereServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, CohereCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), @@ -222,7 +237,6 @@ interface CohereServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), @@ -230,21 +244,18 @@ interface CohereServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: CohereCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: CohereCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -255,12 +266,10 @@ interface CohereServiceAsync { * Returns a raw HTTP response for `get /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(endpoint: String): CompletableFuture> = retrieve(endpoint, CohereRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), @@ -269,7 +278,6 @@ interface CohereServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), @@ -277,21 +285,18 @@ interface CohereServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: CohereRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: CohereRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -302,12 +307,10 @@ interface CohereServiceAsync { * Returns a raw HTTP response for `put /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, CohereUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), @@ -316,7 +319,6 @@ interface CohereServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), @@ -324,21 +326,18 @@ interface CohereServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: CohereUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: CohereUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -349,12 +348,10 @@ interface CohereServiceAsync { * Returns a raw HTTP response for `delete /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, CohereDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), @@ -363,7 +360,6 @@ interface CohereServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), @@ -371,21 +367,18 @@ interface CohereServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: CohereDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: CohereDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -396,12 +389,10 @@ interface CohereServiceAsync { * Returns a raw HTTP response for `patch /cohere/{endpoint}`, but is otherwise the same as * [CohereServiceAsync.modify]. */ - @MustBeClosed fun modify(endpoint: String): CompletableFuture> = modify(endpoint, CohereModifyParams.none()) /** @see [modify] */ - @MustBeClosed fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), @@ -410,7 +401,6 @@ interface CohereServiceAsync { modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [modify] */ - @MustBeClosed fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), @@ -418,21 +408,18 @@ interface CohereServiceAsync { modify(endpoint, params, RequestOptions.none()) /** @see [modify] */ - @MustBeClosed fun modify( params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [modify] */ - @MustBeClosed fun modify( params: CohereModifyParams ): CompletableFuture> = modify(params, RequestOptions.none()) /** @see [modify] */ - @MustBeClosed fun modify( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt index 469daad9..b02af234 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.cohere.CohereRetrieveResponse import ai.hanzo.api.models.cohere.CohereUpdateParams import ai.hanzo.api.models.cohere.CohereUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CohereServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): CohereServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CohereServiceAsync = + CohereServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CohereCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CohereServiceAsync.WithRawResponse = + CohereServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt index c2b602bf..7433283a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.completions.CompletionCreateParams import ai.hanzo.api.models.completions.CompletionCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompletionServiceAsync { @@ -16,6 +17,13 @@ interface CompletionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompletionServiceAsync + /** * Follows the exact same API spec as `OpenAI's Completions API * https://platform.openai.com/docs/api-reference/completions` @@ -56,30 +64,35 @@ interface CompletionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompletionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /completions`, but is otherwise the same as * [CompletionServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(CompletionCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt index 6bf61d16..025f70cf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.completions.CompletionCreateParams import ai.hanzo.api.models.completions.CompletionCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompletionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompletionServiceAsync { @@ -28,6 +29,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): CompletionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompletionServiceAsync = + CompletionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompletionServiceAsync.WithRawResponse = + CompletionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsync.kt index b1878896..a4a4531d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsync.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.config.PassThroughEndpointServiceAsync +import java.util.function.Consumer interface ConfigServiceAsync { @@ -11,6 +13,13 @@ interface ConfigServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigServiceAsync + fun passThroughEndpoint(): PassThroughEndpointServiceAsync /** @@ -18,6 +27,15 @@ interface ConfigServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigServiceAsync.WithRawResponse + fun passThroughEndpoint(): PassThroughEndpointServiceAsync.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsyncImpl.kt index 3ec782c5..29911b76 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ConfigServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.config.PassThroughEndpointServiceAsync import ai.hanzo.api.services.async.config.PassThroughEndpointServiceAsyncImpl +import java.util.function.Consumer class ConfigServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConfigServiceAsync { @@ -19,6 +20,9 @@ class ConfigServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): ConfigServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigServiceAsync = + ConfigServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun passThroughEndpoint(): PassThroughEndpointServiceAsync = passThroughEndpoint class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class ConfigServiceAsyncImpl internal constructor(private val clientOptions: Cli PassThroughEndpointServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConfigServiceAsync.WithRawResponse = + ConfigServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun passThroughEndpoint(): PassThroughEndpointServiceAsync.WithRawResponse = passThroughEndpoint } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt index 76b0d42c..23de8d05 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.credentials.CredentialCreateParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.credentials.CredentialDeleteParams import ai.hanzo.api.models.credentials.CredentialDeleteResponse import ai.hanzo.api.models.credentials.CredentialListParams import ai.hanzo.api.models.credentials.CredentialListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CredentialServiceAsync { @@ -20,6 +21,13 @@ interface CredentialServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CredentialServiceAsync + /** * [BETA] endpoint. This might change unexpectedly. Stores credential in DB. Reloads credentials * in memory. @@ -93,18 +101,25 @@ interface CredentialServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CredentialServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /credentials`, but is otherwise the same as * [CredentialServiceAsync.create]. */ - @MustBeClosed fun create( params: CredentialCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: CredentialCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -114,26 +129,22 @@ interface CredentialServiceAsync { * Returns a raw HTTP response for `get /credentials`, but is otherwise the same as * [CredentialServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(CredentialListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: CredentialListParams = CredentialListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: CredentialListParams = CredentialListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -143,14 +154,12 @@ interface CredentialServiceAsync { * Returns a raw HTTP response for `delete /credentials/{credential_name}`, but is otherwise * the same as [CredentialServiceAsync.delete]. */ - @MustBeClosed fun delete( credentialName: String ): CompletableFuture> = delete(credentialName, CredentialDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), @@ -159,7 +168,6 @@ interface CredentialServiceAsync { delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), @@ -167,21 +175,18 @@ interface CredentialServiceAsync { delete(credentialName, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: CredentialDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( credentialName: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt index f8a11537..d194c7e6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.models.credentials.CredentialDeleteResponse import ai.hanzo.api.models.credentials.CredentialListParams import ai.hanzo.api.models.credentials.CredentialListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CredentialServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): CredentialServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CredentialServiceAsync = + CredentialServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CredentialCreateParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CredentialServiceAsync.WithRawResponse = + CredentialServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -71,6 +82,7 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("credentials") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -102,6 +114,7 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("credentials") .build() .prepareAsync(clientOptions, params) @@ -135,6 +148,7 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("credentials", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt index 59d6242a..03af1db4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.customer.CustomerBlockParams @@ -18,8 +19,8 @@ import ai.hanzo.api.models.customer.CustomerUnblockParams import ai.hanzo.api.models.customer.CustomerUnblockResponse import ai.hanzo.api.models.customer.CustomerUpdateParams import ai.hanzo.api.models.customer.CustomerUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CustomerServiceAsync { @@ -28,6 +29,13 @@ interface CustomerServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CustomerServiceAsync + /** * Allow creating a new Customer * @@ -235,18 +243,25 @@ interface CustomerServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CustomerServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /customer/new`, but is otherwise the same as * [CustomerServiceAsync.create]. */ - @MustBeClosed fun create( params: CustomerCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: CustomerCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -256,14 +271,12 @@ interface CustomerServiceAsync { * Returns a raw HTTP response for `post /customer/update`, but is otherwise the same as * [CustomerServiceAsync.update]. */ - @MustBeClosed fun update( params: CustomerUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: CustomerUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -273,26 +286,22 @@ interface CustomerServiceAsync { * Returns a raw HTTP response for `get /customer/list`, but is otherwise the same as * [CustomerServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture>> = list(CustomerListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: CustomerListParams = CustomerListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [list] */ - @MustBeClosed fun list( params: CustomerListParams = CustomerListParams.none() ): CompletableFuture>> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture>> = @@ -302,14 +311,12 @@ interface CustomerServiceAsync { * Returns a raw HTTP response for `post /customer/delete`, but is otherwise the same as * [CustomerServiceAsync.delete]. */ - @MustBeClosed fun delete( params: CustomerDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: CustomerDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -319,14 +326,12 @@ interface CustomerServiceAsync { * Returns a raw HTTP response for `post /customer/block`, but is otherwise the same as * [CustomerServiceAsync.block]. */ - @MustBeClosed fun block( params: CustomerBlockParams ): CompletableFuture> = block(params, RequestOptions.none()) /** @see [block] */ - @MustBeClosed fun block( params: CustomerBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -336,14 +341,12 @@ interface CustomerServiceAsync { * Returns a raw HTTP response for `get /customer/info`, but is otherwise the same as * [CustomerServiceAsync.retrieveInfo]. */ - @MustBeClosed fun retrieveInfo( params: CustomerRetrieveInfoParams ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: CustomerRetrieveInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -353,14 +356,12 @@ interface CustomerServiceAsync { * Returns a raw HTTP response for `post /customer/unblock`, but is otherwise the same as * [CustomerServiceAsync.unblock]. */ - @MustBeClosed fun unblock( params: CustomerUnblockParams ): CompletableFuture> = unblock(params, RequestOptions.none()) /** @see [unblock] */ - @MustBeClosed fun unblock( params: CustomerUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt index 0530cc4e..d547c37d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt @@ -30,6 +30,7 @@ import ai.hanzo.api.models.customer.CustomerUnblockResponse import ai.hanzo.api.models.customer.CustomerUpdateParams import ai.hanzo.api.models.customer.CustomerUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { @@ -40,6 +41,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): CustomerServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CustomerServiceAsync = + CustomerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CustomerCreateParams, requestOptions: RequestOptions, @@ -94,6 +98,13 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CustomerServiceAsync.WithRawResponse = + CustomerServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -105,6 +116,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -136,6 +148,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -167,6 +180,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "list") .build() .prepareAsync(clientOptions, params) @@ -197,6 +211,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -228,6 +243,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "block") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -259,6 +275,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "info") .build() .prepareAsync(clientOptions, params) @@ -289,6 +306,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "unblock") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt index 2221afe5..15117005 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import ai.hanzo.api.models.delete.DeleteCreateAllowedIpResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DeleteServiceAsync { @@ -16,6 +17,13 @@ interface DeleteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeleteServiceAsync + /** Delete Allowed Ip */ fun createAllowedIp( params: DeleteCreateAllowedIpParams @@ -33,18 +41,25 @@ interface DeleteServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeleteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /delete/allowed_ip`, but is otherwise the same as * [DeleteServiceAsync.createAllowedIp]. */ - @MustBeClosed fun createAllowedIp( params: DeleteCreateAllowedIpParams ): CompletableFuture> = createAllowedIp(params, RequestOptions.none()) /** @see [createAllowedIp] */ - @MustBeClosed fun createAllowedIp( params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt index 5f1f51b7..e9e7722c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import ai.hanzo.api.models.delete.DeleteCreateAllowedIpResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class DeleteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DeleteServiceAsync { @@ -28,6 +29,9 @@ class DeleteServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): DeleteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DeleteServiceAsync = + DeleteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun createAllowedIp( params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class DeleteServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DeleteServiceAsync.WithRawResponse = + DeleteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class DeleteServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("delete", "allowed_ip") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt index 718aa53b..62c26bf0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.embeddings.EmbeddingCreateParams import ai.hanzo.api.models.embeddings.EmbeddingCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EmbeddingServiceAsync { @@ -16,6 +17,13 @@ interface EmbeddingServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmbeddingServiceAsync + /** * Follows the exact same API spec as `OpenAI's Embeddings API * https://platform.openai.com/docs/api-reference/embeddings` @@ -52,30 +60,35 @@ interface EmbeddingServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmbeddingServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /embeddings`, but is otherwise the same as * [EmbeddingServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(EmbeddingCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt index 02d944a2..bce5315c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.embeddings.EmbeddingCreateParams import ai.hanzo.api.models.embeddings.EmbeddingCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EmbeddingServiceAsync { @@ -28,6 +29,9 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): EmbeddingServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmbeddingServiceAsync = + EmbeddingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: EmbeddingCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmbeddingServiceAsync.WithRawResponse = + EmbeddingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("embeddings") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt index 79a968cc..831d397a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.engines.EngineCompleteParams @@ -9,8 +10,8 @@ import ai.hanzo.api.models.engines.EngineCompleteResponse import ai.hanzo.api.models.engines.EngineEmbedParams import ai.hanzo.api.models.engines.EngineEmbedResponse import ai.hanzo.api.services.async.engines.ChatServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EngineServiceAsync { @@ -19,6 +20,13 @@ interface EngineServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EngineServiceAsync + fun chat(): ChatServiceAsync /** @@ -124,18 +132,25 @@ interface EngineServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EngineServiceAsync.WithRawResponse + fun chat(): ChatServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /engines/{model}/completions`, but is otherwise the * same as [EngineServiceAsync.complete]. */ - @MustBeClosed fun complete(model: String): CompletableFuture> = complete(model, EngineCompleteParams.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), @@ -144,7 +159,6 @@ interface EngineServiceAsync { complete(params.toBuilder().model(model).build(), requestOptions) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), @@ -152,21 +166,18 @@ interface EngineServiceAsync { complete(model, params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( params: EngineCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [complete] */ - @MustBeClosed fun complete( params: EngineCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, requestOptions: RequestOptions, @@ -177,12 +188,10 @@ interface EngineServiceAsync { * Returns a raw HTTP response for `post /engines/{model}/embeddings`, but is otherwise the * same as [EngineServiceAsync.embed]. */ - @MustBeClosed fun embed(model: String): CompletableFuture> = embed(model, EngineEmbedParams.none()) /** @see [embed] */ - @MustBeClosed fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), @@ -191,7 +200,6 @@ interface EngineServiceAsync { embed(params.toBuilder().model(model).build(), requestOptions) /** @see [embed] */ - @MustBeClosed fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), @@ -199,21 +207,18 @@ interface EngineServiceAsync { embed(model, params, RequestOptions.none()) /** @see [embed] */ - @MustBeClosed fun embed( params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [embed] */ - @MustBeClosed fun embed( params: EngineEmbedParams ): CompletableFuture> = embed(params, RequestOptions.none()) /** @see [embed] */ - @MustBeClosed fun embed( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt index b010aaf2..04f02a43 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.models.engines.EngineEmbedResponse import ai.hanzo.api.services.async.engines.ChatServiceAsync import ai.hanzo.api.services.async.engines.ChatServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EngineServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -36,6 +37,9 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): EngineServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EngineServiceAsync = + EngineServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun chat(): ChatServiceAsync = chat override fun complete( @@ -61,6 +65,13 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli ChatServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): EngineServiceAsync.WithRawResponse = + EngineServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun chat(): ChatServiceAsync.WithRawResponse = chat private val completeHandler: Handler = @@ -77,6 +88,7 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("engines", params._pathParam(0), "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -111,6 +123,7 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("engines", params._pathParam(0), "embeddings") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt index ff7e56cc..b3299a82 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.euassemblyai.EuAssemblyaiCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveResponse import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EuAssemblyaiServiceAsync { @@ -24,6 +25,13 @@ interface EuAssemblyaiServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EuAssemblyaiServiceAsync + /** Assemblyai Proxy Route */ fun create(endpoint: String): CompletableFuture = create(endpoint, EuAssemblyaiCreateParams.none()) @@ -210,18 +218,25 @@ interface EuAssemblyaiServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EuAssemblyaiServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.create]. */ - @MustBeClosed fun create( endpoint: String ): CompletableFuture> = create(endpoint, EuAssemblyaiCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), @@ -230,7 +245,6 @@ interface EuAssemblyaiServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), @@ -238,21 +252,18 @@ interface EuAssemblyaiServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: EuAssemblyaiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -263,14 +274,12 @@ interface EuAssemblyaiServiceAsync { * Returns a raw HTTP response for `get /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( endpoint: String ): CompletableFuture> = retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), @@ -279,7 +288,6 @@ interface EuAssemblyaiServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), @@ -287,21 +295,18 @@ interface EuAssemblyaiServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: EuAssemblyaiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -312,14 +317,12 @@ interface EuAssemblyaiServiceAsync { * Returns a raw HTTP response for `put /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.update]. */ - @MustBeClosed fun update( endpoint: String ): CompletableFuture> = update(endpoint, EuAssemblyaiUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), @@ -328,7 +331,6 @@ interface EuAssemblyaiServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), @@ -336,21 +338,18 @@ interface EuAssemblyaiServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: EuAssemblyaiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -361,14 +360,12 @@ interface EuAssemblyaiServiceAsync { * Returns a raw HTTP response for `delete /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.delete]. */ - @MustBeClosed fun delete( endpoint: String ): CompletableFuture> = delete(endpoint, EuAssemblyaiDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), @@ -377,7 +374,6 @@ interface EuAssemblyaiServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), @@ -385,21 +381,18 @@ interface EuAssemblyaiServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: EuAssemblyaiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -410,12 +403,10 @@ interface EuAssemblyaiServiceAsync { * Returns a raw HTTP response for `patch /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, EuAssemblyaiPatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), @@ -424,7 +415,6 @@ interface EuAssemblyaiServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), @@ -432,21 +422,18 @@ interface EuAssemblyaiServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: EuAssemblyaiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt index 5ea2bc85..a9d27995 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveResponse import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption override fun withRawResponse(): EuAssemblyaiServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EuAssemblyaiServiceAsync = + EuAssemblyaiServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EuAssemblyaiServiceAsync.WithRawResponse = + EuAssemblyaiServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt index ed52c7f2..5c7904da 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.files.FileCreateParams @@ -13,8 +14,8 @@ import ai.hanzo.api.models.files.FileListResponse import ai.hanzo.api.models.files.FileRetrieveParams import ai.hanzo.api.models.files.FileRetrieveResponse import ai.hanzo.api.services.async.files.ContentServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface FileServiceAsync { @@ -23,6 +24,13 @@ interface FileServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync + fun content(): ContentServiceAsync /** @@ -178,13 +186,19 @@ interface FileServiceAsync { /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileServiceAsync.WithRawResponse + fun content(): ContentServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /{provider}/v1/files`, but is otherwise the same as * [FileServiceAsync.create]. */ - @MustBeClosed fun create( provider: String, params: FileCreateParams, @@ -192,7 +206,6 @@ interface FileServiceAsync { create(provider, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( provider: String, params: FileCreateParams, @@ -201,14 +214,12 @@ interface FileServiceAsync { create(params.toBuilder().provider(provider).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( params: FileCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: FileCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -218,7 +229,6 @@ interface FileServiceAsync { * Returns a raw HTTP response for `get /{provider}/v1/files/{file_id}`, but is otherwise * the same as [FileServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( fileId: String, params: FileRetrieveParams, @@ -226,7 +236,6 @@ interface FileServiceAsync { retrieve(fileId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( fileId: String, params: FileRetrieveParams, @@ -235,14 +244,12 @@ interface FileServiceAsync { retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: FileRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: FileRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -252,12 +259,10 @@ interface FileServiceAsync { * Returns a raw HTTP response for `get /{provider}/v1/files`, but is otherwise the same as * [FileServiceAsync.list]. */ - @MustBeClosed fun list(provider: String): CompletableFuture> = list(provider, FileListParams.none()) /** @see [list] */ - @MustBeClosed fun list( provider: String, params: FileListParams = FileListParams.none(), @@ -266,7 +271,6 @@ interface FileServiceAsync { list(params.toBuilder().provider(provider).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( provider: String, params: FileListParams = FileListParams.none(), @@ -274,19 +278,16 @@ interface FileServiceAsync { list(provider, params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: FileListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list(params: FileListParams): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( provider: String, requestOptions: RequestOptions, @@ -297,7 +298,6 @@ interface FileServiceAsync { * Returns a raw HTTP response for `delete /{provider}/v1/files/{file_id}`, but is otherwise * the same as [FileServiceAsync.delete]. */ - @MustBeClosed fun delete( fileId: String, params: FileDeleteParams, @@ -305,7 +305,6 @@ interface FileServiceAsync { delete(fileId, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( fileId: String, params: FileDeleteParams, @@ -314,14 +313,12 @@ interface FileServiceAsync { delete(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( params: FileDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: FileDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt index c9a295a4..5f0c9178 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt @@ -28,6 +28,7 @@ import ai.hanzo.api.models.files.FileRetrieveResponse import ai.hanzo.api.services.async.files.ContentServiceAsync import ai.hanzo.api.services.async.files.ContentServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -41,6 +42,9 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileServiceAsync = + FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun content(): ContentServiceAsync = content override fun create( @@ -80,6 +84,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien ContentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FileServiceAsync.WithRawResponse = + FileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun content(): ContentServiceAsync.WithRawResponse = content private val createHandler: Handler = @@ -95,6 +106,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -129,6 +141,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files", params._pathParam(1)) .build() .prepareAsync(clientOptions, params) @@ -161,6 +174,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files") .build() .prepareAsync(clientOptions, params) @@ -193,6 +207,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files", params._pathParam(1)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsync.kt index cf1e42ee..bb9ef316 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsync.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.finetuning.JobServiceAsync +import java.util.function.Consumer interface FineTuningServiceAsync { @@ -11,6 +13,13 @@ interface FineTuningServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FineTuningServiceAsync + fun jobs(): JobServiceAsync /** @@ -19,6 +28,15 @@ interface FineTuningServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): FineTuningServiceAsync.WithRawResponse + fun jobs(): JobServiceAsync.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsyncImpl.kt index a386a82b..96e1b979 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FineTuningServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.finetuning.JobServiceAsync import ai.hanzo.api.services.async.finetuning.JobServiceAsyncImpl +import java.util.function.Consumer class FineTuningServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : FineTuningServiceAsync { @@ -17,6 +18,9 @@ class FineTuningServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): FineTuningServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FineTuningServiceAsync = + FineTuningServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun jobs(): JobServiceAsync = jobs class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class FineTuningServiceAsyncImpl internal constructor(private val clientOptions: JobServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FineTuningServiceAsync.WithRawResponse = + FineTuningServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun jobs(): JobServiceAsync.WithRawResponse = jobs } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt index c4411175..eaa0221f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.gemini.GeminiCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.gemini.GeminiRetrieveParams import ai.hanzo.api.models.gemini.GeminiRetrieveResponse import ai.hanzo.api.models.gemini.GeminiUpdateParams import ai.hanzo.api.models.gemini.GeminiUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface GeminiServiceAsync { @@ -24,6 +25,13 @@ interface GeminiServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GeminiServiceAsync + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ fun create(endpoint: String): CompletableFuture = create(endpoint, GeminiCreateParams.none()) @@ -204,16 +212,23 @@ interface GeminiServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GeminiServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, GeminiCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), @@ -222,7 +237,6 @@ interface GeminiServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), @@ -230,21 +244,18 @@ interface GeminiServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: GeminiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: GeminiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -255,12 +266,10 @@ interface GeminiServiceAsync { * Returns a raw HTTP response for `get /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(endpoint: String): CompletableFuture> = retrieve(endpoint, GeminiRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), @@ -269,7 +278,6 @@ interface GeminiServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), @@ -277,21 +285,18 @@ interface GeminiServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: GeminiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: GeminiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -302,12 +307,10 @@ interface GeminiServiceAsync { * Returns a raw HTTP response for `put /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, GeminiUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), @@ -316,7 +319,6 @@ interface GeminiServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), @@ -324,21 +326,18 @@ interface GeminiServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: GeminiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: GeminiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -349,12 +348,10 @@ interface GeminiServiceAsync { * Returns a raw HTTP response for `delete /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, GeminiDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), @@ -363,7 +360,6 @@ interface GeminiServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), @@ -371,21 +367,18 @@ interface GeminiServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: GeminiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: GeminiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -396,12 +389,10 @@ interface GeminiServiceAsync { * Returns a raw HTTP response for `patch /gemini/{endpoint}`, but is otherwise the same as * [GeminiServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, GeminiPatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), @@ -410,7 +401,6 @@ interface GeminiServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), @@ -418,21 +408,18 @@ interface GeminiServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: GeminiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt index b990ac53..a05530bd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.gemini.GeminiRetrieveResponse import ai.hanzo.api.models.gemini.GeminiUpdateParams import ai.hanzo.api.models.gemini.GeminiUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class GeminiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): GeminiServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GeminiServiceAsync = + GeminiServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: GeminiCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GeminiServiceAsync.WithRawResponse = + GeminiServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsync.kt index 27050d89..de8f7f4c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsync.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.global.SpendServiceAsync +import java.util.function.Consumer interface GlobalServiceAsync { @@ -11,6 +13,13 @@ interface GlobalServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GlobalServiceAsync + fun spend(): SpendServiceAsync /** @@ -18,6 +27,15 @@ interface GlobalServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GlobalServiceAsync.WithRawResponse + fun spend(): SpendServiceAsync.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsyncImpl.kt index 55ddbb2c..e1e11ed6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GlobalServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.global.SpendServiceAsync import ai.hanzo.api.services.async.global.SpendServiceAsyncImpl +import java.util.function.Consumer class GlobalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GlobalServiceAsync { @@ -17,6 +18,9 @@ class GlobalServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): GlobalServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GlobalServiceAsync = + GlobalServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun spend(): SpendServiceAsync = spend class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class GlobalServiceAsyncImpl internal constructor(private val clientOptions: Cli SpendServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): GlobalServiceAsync.WithRawResponse = + GlobalServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun spend(): SpendServiceAsync.WithRawResponse = spend } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt index 4d45bc6d..1a4a3f20 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.guardrails.GuardrailListParams import ai.hanzo.api.models.guardrails.GuardrailListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface GuardrailServiceAsync { @@ -16,6 +17,13 @@ interface GuardrailServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GuardrailServiceAsync + /** * List the guardrails that are available on the proxy server * @@ -72,30 +80,35 @@ interface GuardrailServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GuardrailServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /guardrails/list`, but is otherwise the same as * [GuardrailServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(GuardrailListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: GuardrailListParams = GuardrailListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: GuardrailListParams = GuardrailListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt index 270dc269..29b8e831 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.guardrails.GuardrailListParams import ai.hanzo.api.models.guardrails.GuardrailListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GuardrailServiceAsync { @@ -27,6 +28,9 @@ class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): GuardrailServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GuardrailServiceAsync = + GuardrailServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: GuardrailListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GuardrailServiceAsync.WithRawResponse = + GuardrailServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("guardrails", "list") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt index bc00e1af..638f524f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.health.HealthCheckAllParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.health.HealthCheckReadinessParams import ai.hanzo.api.models.health.HealthCheckReadinessResponse import ai.hanzo.api.models.health.HealthCheckServicesParams import ai.hanzo.api.models.health.HealthCheckServicesResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface HealthServiceAsync { @@ -24,6 +25,13 @@ interface HealthServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HealthServiceAsync + /** * 🚨 USE `/health/liveliness` to health check the proxy 🚨 * @@ -146,30 +154,35 @@ interface HealthServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): HealthServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /health`, but is otherwise the same as * [HealthServiceAsync.checkAll]. */ - @MustBeClosed fun checkAll(): CompletableFuture> = checkAll(HealthCheckAllParams.none()) /** @see [checkAll] */ - @MustBeClosed fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [checkAll] */ - @MustBeClosed fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none() ): CompletableFuture> = checkAll(params, RequestOptions.none()) /** @see [checkAll] */ - @MustBeClosed fun checkAll( requestOptions: RequestOptions ): CompletableFuture> = @@ -179,26 +192,22 @@ interface HealthServiceAsync { * Returns a raw HTTP response for `get /health/liveliness`, but is otherwise the same as * [HealthServiceAsync.checkLiveliness]. */ - @MustBeClosed fun checkLiveliness(): CompletableFuture> = checkLiveliness(HealthCheckLivelinessParams.none()) /** @see [checkLiveliness] */ - @MustBeClosed fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [checkLiveliness] */ - @MustBeClosed fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none() ): CompletableFuture> = checkLiveliness(params, RequestOptions.none()) /** @see [checkLiveliness] */ - @MustBeClosed fun checkLiveliness( requestOptions: RequestOptions ): CompletableFuture> = @@ -208,26 +217,22 @@ interface HealthServiceAsync { * Returns a raw HTTP response for `get /health/liveness`, but is otherwise the same as * [HealthServiceAsync.checkLiveness]. */ - @MustBeClosed fun checkLiveness(): CompletableFuture> = checkLiveness(HealthCheckLivenessParams.none()) /** @see [checkLiveness] */ - @MustBeClosed fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [checkLiveness] */ - @MustBeClosed fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none() ): CompletableFuture> = checkLiveness(params, RequestOptions.none()) /** @see [checkLiveness] */ - @MustBeClosed fun checkLiveness( requestOptions: RequestOptions ): CompletableFuture> = @@ -237,26 +242,22 @@ interface HealthServiceAsync { * Returns a raw HTTP response for `get /health/readiness`, but is otherwise the same as * [HealthServiceAsync.checkReadiness]. */ - @MustBeClosed fun checkReadiness(): CompletableFuture> = checkReadiness(HealthCheckReadinessParams.none()) /** @see [checkReadiness] */ - @MustBeClosed fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [checkReadiness] */ - @MustBeClosed fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none() ): CompletableFuture> = checkReadiness(params, RequestOptions.none()) /** @see [checkReadiness] */ - @MustBeClosed fun checkReadiness( requestOptions: RequestOptions ): CompletableFuture> = @@ -266,14 +267,12 @@ interface HealthServiceAsync { * Returns a raw HTTP response for `get /health/services`, but is otherwise the same as * [HealthServiceAsync.checkServices]. */ - @MustBeClosed fun checkServices( params: HealthCheckServicesParams ): CompletableFuture> = checkServices(params, RequestOptions.none()) /** @see [checkServices] */ - @MustBeClosed fun checkServices( params: HealthCheckServicesParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt index ca0f6d4a..9110864f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt @@ -25,6 +25,7 @@ import ai.hanzo.api.models.health.HealthCheckReadinessResponse import ai.hanzo.api.models.health.HealthCheckServicesParams import ai.hanzo.api.models.health.HealthCheckServicesResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class HealthServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : HealthServiceAsync { @@ -35,6 +36,9 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): HealthServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HealthServiceAsync = + HealthServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun checkAll( params: HealthCheckAllParams, requestOptions: RequestOptions, @@ -75,6 +79,13 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): HealthServiceAsync.WithRawResponse = + HealthServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val checkAllHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -86,6 +97,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health") .build() .prepareAsync(clientOptions, params) @@ -116,6 +128,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "liveliness") .build() .prepareAsync(clientOptions, params) @@ -146,6 +159,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "liveness") .build() .prepareAsync(clientOptions, params) @@ -176,6 +190,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "readiness") .build() .prepareAsync(clientOptions, params) @@ -206,6 +221,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "services") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsync.kt index 550208d8..bee7c2b8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsync.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.images.GenerationServiceAsync +import java.util.function.Consumer interface ImageServiceAsync { @@ -11,11 +13,27 @@ interface ImageServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ImageServiceAsync + fun generations(): GenerationServiceAsync /** A view of [ImageServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ImageServiceAsync.WithRawResponse + fun generations(): GenerationServiceAsync.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsyncImpl.kt index b86621f6..47737c36 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ImageServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.async.images.GenerationServiceAsync import ai.hanzo.api.services.async.images.GenerationServiceAsyncImpl +import java.util.function.Consumer class ImageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ImageServiceAsync { @@ -19,6 +20,9 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ImageServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ImageServiceAsync = + ImageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun generations(): GenerationServiceAsync = generations class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie GenerationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ImageServiceAsync.WithRawResponse = + ImageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun generations(): GenerationServiceAsync.WithRawResponse = generations } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt index c650c5e1..e343e6d4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.key.GenerateKeyResponse @@ -22,9 +23,9 @@ import ai.hanzo.api.models.key.KeyUnblockResponse import ai.hanzo.api.models.key.KeyUpdateParams import ai.hanzo.api.models.key.KeyUpdateResponse import ai.hanzo.api.services.async.key.RegenerateServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.Optional import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface KeyServiceAsync { @@ -33,6 +34,13 @@ interface KeyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KeyServiceAsync + fun regenerate(): RegenerateServiceAsync /** @@ -482,18 +490,23 @@ interface KeyServiceAsync { /** A view of [KeyServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KeyServiceAsync.WithRawResponse + fun regenerate(): RegenerateServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /key/update`, but is otherwise the same as * [KeyServiceAsync.update]. */ - @MustBeClosed fun update(params: KeyUpdateParams): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: KeyUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -503,24 +516,20 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `get /key/list`, but is otherwise the same as * [KeyServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(KeyListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: KeyListParams = KeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: KeyListParams = KeyListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -530,26 +539,22 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `post /key/delete`, but is otherwise the same as * [KeyServiceAsync.delete]. */ - @MustBeClosed fun delete(): CompletableFuture> = delete(KeyDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: KeyDeleteParams = KeyDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: KeyDeleteParams = KeyDeleteParams.none() ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( requestOptions: RequestOptions ): CompletableFuture> = @@ -559,14 +564,12 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `post /key/block`, but is otherwise the same as * [KeyServiceAsync.block]. */ - @MustBeClosed fun block( params: KeyBlockParams ): CompletableFuture>> = block(params, RequestOptions.none()) /** @see [block] */ - @MustBeClosed fun block( params: KeyBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -576,26 +579,22 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `post /key/health`, but is otherwise the same as * [KeyServiceAsync.checkHealth]. */ - @MustBeClosed fun checkHealth(): CompletableFuture> = checkHealth(KeyCheckHealthParams.none()) /** @see [checkHealth] */ - @MustBeClosed fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [checkHealth] */ - @MustBeClosed fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none() ): CompletableFuture> = checkHealth(params, RequestOptions.none()) /** @see [checkHealth] */ - @MustBeClosed fun checkHealth( requestOptions: RequestOptions ): CompletableFuture> = @@ -605,26 +604,22 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `post /key/generate`, but is otherwise the same as * [KeyServiceAsync.generate]. */ - @MustBeClosed fun generate(): CompletableFuture> = generate(KeyGenerateParams.none()) /** @see [generate] */ - @MustBeClosed fun generate( params: KeyGenerateParams = KeyGenerateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [generate] */ - @MustBeClosed fun generate( params: KeyGenerateParams = KeyGenerateParams.none() ): CompletableFuture> = generate(params, RequestOptions.none()) /** @see [generate] */ - @MustBeClosed fun generate( requestOptions: RequestOptions ): CompletableFuture> = @@ -634,14 +629,12 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `post /key/{key}/regenerate`, but is otherwise the same * as [KeyServiceAsync.regenerateByKey]. */ - @MustBeClosed fun regenerateByKey( pathKey: String ): CompletableFuture>> = regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) /** @see [regenerateByKey] */ - @MustBeClosed fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), @@ -650,7 +643,6 @@ interface KeyServiceAsync { regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) /** @see [regenerateByKey] */ - @MustBeClosed fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), @@ -658,21 +650,18 @@ interface KeyServiceAsync { regenerateByKey(pathKey, params, RequestOptions.none()) /** @see [regenerateByKey] */ - @MustBeClosed fun regenerateByKey( params: KeyRegenerateByKeyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [regenerateByKey] */ - @MustBeClosed fun regenerateByKey( params: KeyRegenerateByKeyParams ): CompletableFuture>> = regenerateByKey(params, RequestOptions.none()) /** @see [regenerateByKey] */ - @MustBeClosed fun regenerateByKey( pathKey: String, requestOptions: RequestOptions, @@ -683,26 +672,22 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `get /key/info`, but is otherwise the same as * [KeyServiceAsync.retrieveInfo]. */ - @MustBeClosed fun retrieveInfo(): CompletableFuture> = retrieveInfo(KeyRetrieveInfoParams.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = @@ -712,14 +697,12 @@ interface KeyServiceAsync { * Returns a raw HTTP response for `post /key/unblock`, but is otherwise the same as * [KeyServiceAsync.unblock]. */ - @MustBeClosed fun unblock( params: KeyUnblockParams ): CompletableFuture> = unblock(params, RequestOptions.none()) /** @see [unblock] */ - @MustBeClosed fun unblock( params: KeyUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt index 55b96b63..1b37ed2a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt @@ -37,6 +37,7 @@ import ai.hanzo.api.services.async.key.RegenerateServiceAsync import ai.hanzo.api.services.async.key.RegenerateServiceAsyncImpl import java.util.Optional import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class KeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -52,6 +53,9 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): KeyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): KeyServiceAsync = + KeyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun regenerate(): RegenerateServiceAsync = regenerate override fun update( @@ -126,6 +130,13 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client RegenerateServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): KeyServiceAsync.WithRawResponse = + KeyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun regenerate(): RegenerateServiceAsync.WithRawResponse = regenerate private val updateHandler: Handler = @@ -138,6 +149,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -168,6 +180,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "list") .build() .prepareAsync(clientOptions, params) @@ -197,6 +210,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -228,6 +242,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "block") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -259,6 +274,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "health") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -290,6 +306,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "generate") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -324,6 +341,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", params._pathParam(0), "regenerate") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -355,6 +373,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "info") .build() .prepareAsync(clientOptions, params) @@ -384,6 +403,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "unblock") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt index d029a633..140a1b47 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.langfuse.LangfuseCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.langfuse.LangfuseRetrieveParams import ai.hanzo.api.models.langfuse.LangfuseRetrieveResponse import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import ai.hanzo.api.models.langfuse.LangfuseUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface LangfuseServiceAsync { @@ -24,6 +25,13 @@ interface LangfuseServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LangfuseServiceAsync + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * @@ -225,16 +233,23 @@ interface LangfuseServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): LangfuseServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, LangfuseCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), @@ -243,7 +258,6 @@ interface LangfuseServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), @@ -251,21 +265,18 @@ interface LangfuseServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: LangfuseCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: LangfuseCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -276,14 +287,12 @@ interface LangfuseServiceAsync { * Returns a raw HTTP response for `get /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( endpoint: String ): CompletableFuture> = retrieve(endpoint, LangfuseRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), @@ -292,7 +301,6 @@ interface LangfuseServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), @@ -300,21 +308,18 @@ interface LangfuseServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: LangfuseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: LangfuseRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -325,12 +330,10 @@ interface LangfuseServiceAsync { * Returns a raw HTTP response for `put /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, LangfuseUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), @@ -339,7 +342,6 @@ interface LangfuseServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), @@ -347,21 +349,18 @@ interface LangfuseServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: LangfuseUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: LangfuseUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -372,12 +371,10 @@ interface LangfuseServiceAsync { * Returns a raw HTTP response for `delete /langfuse/{endpoint}`, but is otherwise the same * as [LangfuseServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, LangfuseDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), @@ -386,7 +383,6 @@ interface LangfuseServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), @@ -394,21 +390,18 @@ interface LangfuseServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: LangfuseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: LangfuseDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -419,12 +412,10 @@ interface LangfuseServiceAsync { * Returns a raw HTTP response for `patch /langfuse/{endpoint}`, but is otherwise the same * as [LangfuseServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, LangfusePatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), @@ -433,7 +424,6 @@ interface LangfuseServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), @@ -441,21 +431,18 @@ interface LangfuseServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: LangfusePatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt index 845015ed..2c56dadf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.langfuse.LangfuseRetrieveResponse import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import ai.hanzo.api.models.langfuse.LangfuseUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): LangfuseServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): LangfuseServiceAsync = + LangfuseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: LangfuseCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): LangfuseServiceAsync.WithRawResponse = + LangfuseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt index cc73179e..f8e76dff 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoParams import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ModelGroupServiceAsync { @@ -16,6 +17,13 @@ interface ModelGroupServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelGroupServiceAsync + /** * Get information about all the deployments on llm proxy, including config.yaml descriptions * (except api key and api base) @@ -181,30 +189,35 @@ interface ModelGroupServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModelGroupServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /model_group/info`, but is otherwise the same as * [ModelGroupServiceAsync.retrieveInfo]. */ - @MustBeClosed fun retrieveInfo(): CompletableFuture> = retrieveInfo(ModelGroupRetrieveInfoParams.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt index e2993b3f..7d8d2e03 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoParams import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ModelGroupServiceAsync { @@ -27,6 +28,9 @@ class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): ModelGroupServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelGroupServiceAsync = + ModelGroupServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveInfo( params: ModelGroupRetrieveInfoParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModelGroupServiceAsync.WithRawResponse = + ModelGroupServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model_group", "info") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt index e9a95b1d..458d6e2a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.model.ModelCreateParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.model.ModelDeleteParams import ai.hanzo.api.models.model.ModelDeleteResponse import ai.hanzo.api.services.async.model.InfoServiceAsync import ai.hanzo.api.services.async.model.UpdateServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ModelServiceAsync { @@ -20,6 +21,13 @@ interface ModelServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelServiceAsync + fun info(): InfoServiceAsync fun update(): UpdateServiceAsync @@ -47,6 +55,15 @@ interface ModelServiceAsync { /** A view of [ModelServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModelServiceAsync.WithRawResponse + fun info(): InfoServiceAsync.WithRawResponse fun update(): UpdateServiceAsync.WithRawResponse @@ -55,14 +72,12 @@ interface ModelServiceAsync { * Returns a raw HTTP response for `post /model/new`, but is otherwise the same as * [ModelServiceAsync.create]. */ - @MustBeClosed fun create( params: ModelCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: ModelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -72,14 +87,12 @@ interface ModelServiceAsync { * Returns a raw HTTP response for `post /model/delete`, but is otherwise the same as * [ModelServiceAsync.delete]. */ - @MustBeClosed fun delete( params: ModelDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: ModelDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt index c333f5b7..541d24b9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.services.async.model.InfoServiceAsyncImpl import ai.hanzo.api.services.async.model.UpdateServiceAsync import ai.hanzo.api.services.async.model.UpdateServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ModelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ModelServiceAsync { @@ -38,6 +39,9 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ModelServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelServiceAsync = + ModelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun info(): InfoServiceAsync = info override fun update(): UpdateServiceAsync = update @@ -69,6 +73,13 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie UpdateServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ModelServiceAsync.WithRawResponse = + ModelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun info(): InfoServiceAsync.WithRawResponse = info override fun update(): UpdateServiceAsync.WithRawResponse = update @@ -84,6 +95,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -115,6 +127,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt index 29f626ae..6a2ded33 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.moderations.ModerationCreateParams import ai.hanzo.api.models.moderations.ModerationCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ModerationServiceAsync { @@ -16,6 +17,13 @@ interface ModerationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModerationServiceAsync + /** * The moderations endpoint is a tool you can use to check whether content complies with an LLM * Providers policies. @@ -50,30 +58,35 @@ interface ModerationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModerationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/moderations`, but is otherwise the same as * [ModerationServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(ModerationCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: ModerationCreateParams = ModerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: ModerationCreateParams = ModerationCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt index d5b65614..8f66c934 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.moderations.ModerationCreateParams import ai.hanzo.api.models.moderations.ModerationCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ModerationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ModerationServiceAsync { @@ -28,6 +29,9 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): ModerationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModerationServiceAsync = + ModerationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: ModerationCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModerationServiceAsync.WithRawResponse = + ModerationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "moderations") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt index df653cd2..8bca4194 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.openai.OpenAICreateParams @@ -15,8 +16,8 @@ import ai.hanzo.api.models.openai.OpenAIRetrieveResponse import ai.hanzo.api.models.openai.OpenAIUpdateParams import ai.hanzo.api.models.openai.OpenAIUpdateResponse import ai.hanzo.api.services.async.openai.DeploymentServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface OpenAIServiceAsync { @@ -25,6 +26,13 @@ interface OpenAIServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OpenAIServiceAsync + fun deployments(): DeploymentServiceAsync /** @@ -217,18 +225,25 @@ interface OpenAIServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OpenAIServiceAsync.WithRawResponse + fun deployments(): DeploymentServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, OpenAICreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), @@ -237,7 +252,6 @@ interface OpenAIServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), @@ -245,21 +259,18 @@ interface OpenAIServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: OpenAICreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: OpenAICreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -270,12 +281,10 @@ interface OpenAIServiceAsync { * Returns a raw HTTP response for `get /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(endpoint: String): CompletableFuture> = retrieve(endpoint, OpenAIRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), @@ -284,7 +293,6 @@ interface OpenAIServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), @@ -292,21 +300,18 @@ interface OpenAIServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: OpenAIRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: OpenAIRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -317,12 +322,10 @@ interface OpenAIServiceAsync { * Returns a raw HTTP response for `put /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, OpenAIUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), @@ -331,7 +334,6 @@ interface OpenAIServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), @@ -339,21 +341,18 @@ interface OpenAIServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: OpenAIUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: OpenAIUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -364,12 +363,10 @@ interface OpenAIServiceAsync { * Returns a raw HTTP response for `delete /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, OpenAIDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), @@ -378,7 +375,6 @@ interface OpenAIServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), @@ -386,21 +382,18 @@ interface OpenAIServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: OpenAIDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: OpenAIDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -411,12 +404,10 @@ interface OpenAIServiceAsync { * Returns a raw HTTP response for `patch /openai/{endpoint}`, but is otherwise the same as * [OpenAIServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, OpenAIPatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), @@ -425,7 +416,6 @@ interface OpenAIServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), @@ -433,21 +423,18 @@ interface OpenAIServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: OpenAIPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt index dd048789..0138ae7e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt @@ -29,6 +29,7 @@ import ai.hanzo.api.models.openai.OpenAIUpdateResponse import ai.hanzo.api.services.async.openai.DeploymentServiceAsync import ai.hanzo.api.services.async.openai.DeploymentServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -44,6 +45,9 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): OpenAIServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OpenAIServiceAsync = + OpenAIServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun deployments(): DeploymentServiceAsync = deployments override fun create( @@ -90,6 +94,13 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli DeploymentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OpenAIServiceAsync.WithRawResponse = + OpenAIServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun deployments(): DeploymentServiceAsync.WithRawResponse = deployments private val createHandler: Handler = @@ -106,6 +117,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -140,6 +152,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -173,6 +186,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -207,6 +221,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -241,6 +256,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt index a6e97930..b05b23a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.organization.OrganizationAddMemberParams @@ -19,8 +20,8 @@ import ai.hanzo.api.models.organization.OrganizationUpdateMemberResponse import ai.hanzo.api.models.organization.OrganizationUpdateParams import ai.hanzo.api.models.organization.OrganizationUpdateResponse import ai.hanzo.api.services.async.organization.InfoServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface OrganizationServiceAsync { @@ -29,6 +30,13 @@ interface OrganizationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OrganizationServiceAsync + fun info(): InfoServiceAsync /** @@ -235,20 +243,27 @@ interface OrganizationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OrganizationServiceAsync.WithRawResponse + fun info(): InfoServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /organization/new`, but is otherwise the same as * [OrganizationServiceAsync.create]. */ - @MustBeClosed fun create( params: OrganizationCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: OrganizationCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -258,26 +273,22 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `patch /organization/update`, but is otherwise the same * as [OrganizationServiceAsync.update]. */ - @MustBeClosed fun update(): CompletableFuture> = update(OrganizationUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none() ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( requestOptions: RequestOptions ): CompletableFuture> = @@ -287,26 +298,22 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `get /organization/list`, but is otherwise the same as * [OrganizationServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture>> = list(OrganizationListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [list] */ - @MustBeClosed fun list( params: OrganizationListParams = OrganizationListParams.none() ): CompletableFuture>> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture>> = @@ -316,14 +323,12 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `delete /organization/delete`, but is otherwise the same * as [OrganizationServiceAsync.delete]. */ - @MustBeClosed fun delete( params: OrganizationDeleteParams ): CompletableFuture>> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -333,14 +338,12 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `post /organization/member_add`, but is otherwise the * same as [OrganizationServiceAsync.addMember]. */ - @MustBeClosed fun addMember( params: OrganizationAddMemberParams ): CompletableFuture> = addMember(params, RequestOptions.none()) /** @see [addMember] */ - @MustBeClosed fun addMember( params: OrganizationAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -350,14 +353,12 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `delete /organization/member_delete`, but is otherwise * the same as [OrganizationServiceAsync.deleteMember]. */ - @MustBeClosed fun deleteMember( params: OrganizationDeleteMemberParams ): CompletableFuture> = deleteMember(params, RequestOptions.none()) /** @see [deleteMember] */ - @MustBeClosed fun deleteMember( params: OrganizationDeleteMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -367,14 +368,12 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `patch /organization/member_update`, but is otherwise the * same as [OrganizationServiceAsync.updateMember]. */ - @MustBeClosed fun updateMember( params: OrganizationUpdateMemberParams ): CompletableFuture> = updateMember(params, RequestOptions.none()) /** @see [updateMember] */ - @MustBeClosed fun updateMember( params: OrganizationUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt index f8ec1841..48f4107f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt @@ -32,6 +32,7 @@ import ai.hanzo.api.models.organization.OrganizationUpdateResponse import ai.hanzo.api.services.async.organization.InfoServiceAsync import ai.hanzo.api.services.async.organization.InfoServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationServiceAsync { @@ -44,6 +45,9 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption override fun withRawResponse(): OrganizationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OrganizationServiceAsync = + OrganizationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun info(): InfoServiceAsync = info override fun create( @@ -104,6 +108,13 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption InfoServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OrganizationServiceAsync.WithRawResponse = + OrganizationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun info(): InfoServiceAsync.WithRawResponse = info private val createHandler: Handler = @@ -117,6 +128,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -148,6 +160,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -179,6 +192,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "list") .build() .prepareAsync(clientOptions, params) @@ -209,6 +223,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -240,6 +255,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "member_add") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -271,6 +287,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "member_delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -302,6 +319,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "member_update") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt index dff7e0ba..9b86613a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.provider.ProviderListBudgetsParams import ai.hanzo.api.models.provider.ProviderListBudgetsResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ProviderServiceAsync { @@ -16,6 +17,13 @@ interface ProviderServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderServiceAsync + /** * Provider Budget Routing - Get Budget, Spend Details * https://docs.hanzo.ai/docs/proxy/provider_budget_routing @@ -86,30 +94,35 @@ interface ProviderServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ProviderServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /provider/budgets`, but is otherwise the same as * [ProviderServiceAsync.listBudgets]. */ - @MustBeClosed fun listBudgets(): CompletableFuture> = listBudgets(ProviderListBudgetsParams.none()) /** @see [listBudgets] */ - @MustBeClosed fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [listBudgets] */ - @MustBeClosed fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none() ): CompletableFuture> = listBudgets(params, RequestOptions.none()) /** @see [listBudgets] */ - @MustBeClosed fun listBudgets( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt index b1dced92..b7d5b739 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.provider.ProviderListBudgetsParams import ai.hanzo.api.models.provider.ProviderListBudgetsResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ProviderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ProviderServiceAsync { @@ -27,6 +28,9 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ProviderServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ProviderServiceAsync = + ProviderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun listBudgets( params: ProviderListBudgetsParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ProviderServiceAsync.WithRawResponse = + ProviderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listBudgetsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("provider", "budgets") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt index 477e48be..d43e5d80 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.rerank.RerankCreateParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.rerank.RerankCreateV1Params import ai.hanzo.api.models.rerank.RerankCreateV1Response import ai.hanzo.api.models.rerank.RerankCreateV2Params import ai.hanzo.api.models.rerank.RerankCreateV2Response -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RerankServiceAsync { @@ -20,6 +21,13 @@ interface RerankServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RerankServiceAsync + /** Rerank */ fun create(): CompletableFuture = create(RerankCreateParams.none()) @@ -81,30 +89,35 @@ interface RerankServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RerankServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /rerank`, but is otherwise the same as * [RerankServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(RerankCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: RerankCreateParams = RerankCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: RerankCreateParams = RerankCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -114,26 +127,22 @@ interface RerankServiceAsync { * Returns a raw HTTP response for `post /v1/rerank`, but is otherwise the same as * [RerankServiceAsync.createV1]. */ - @MustBeClosed fun createV1(): CompletableFuture> = createV1(RerankCreateV1Params.none()) /** @see [createV1] */ - @MustBeClosed fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [createV1] */ - @MustBeClosed fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none() ): CompletableFuture> = createV1(params, RequestOptions.none()) /** @see [createV1] */ - @MustBeClosed fun createV1( requestOptions: RequestOptions ): CompletableFuture> = @@ -143,26 +152,22 @@ interface RerankServiceAsync { * Returns a raw HTTP response for `post /v2/rerank`, but is otherwise the same as * [RerankServiceAsync.createV2]. */ - @MustBeClosed fun createV2(): CompletableFuture> = createV2(RerankCreateV2Params.none()) /** @see [createV2] */ - @MustBeClosed fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [createV2] */ - @MustBeClosed fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none() ): CompletableFuture> = createV2(params, RequestOptions.none()) /** @see [createV2] */ - @MustBeClosed fun createV2( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt index 55604f69..965dde90 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.rerank.RerankCreateV1Response import ai.hanzo.api.models.rerank.RerankCreateV2Params import ai.hanzo.api.models.rerank.RerankCreateV2Response import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class RerankServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RerankServiceAsync { @@ -32,6 +33,9 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): RerankServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RerankServiceAsync = + RerankServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: RerankCreateParams, requestOptions: RequestOptions, @@ -58,6 +62,13 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RerankServiceAsync.WithRawResponse = + RerankServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -69,6 +80,7 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("rerank") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -100,6 +112,7 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "rerank") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -131,6 +144,7 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v2", "rerank") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt index 9b35a729..bd734cf9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.responses.ResponseCreateParams @@ -11,8 +12,8 @@ import ai.hanzo.api.models.responses.ResponseDeleteResponse import ai.hanzo.api.models.responses.ResponseRetrieveParams import ai.hanzo.api.models.responses.ResponseRetrieveResponse import ai.hanzo.api.services.async.responses.InputItemServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ResponseServiceAsync { @@ -21,6 +22,13 @@ interface ResponseServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResponseServiceAsync + fun inputItems(): InputItemServiceAsync /** @@ -145,32 +153,37 @@ interface ResponseServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ResponseServiceAsync.WithRawResponse + fun inputItems(): InputItemServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /v1/responses`, but is otherwise the same as * [ResponseServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(ResponseCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: ResponseCreateParams = ResponseCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: ResponseCreateParams = ResponseCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -180,14 +193,12 @@ interface ResponseServiceAsync { * Returns a raw HTTP response for `get /v1/responses/{response_id}`, but is otherwise the * same as [ResponseServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( responseId: String ): CompletableFuture> = retrieve(responseId, ResponseRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), @@ -196,7 +207,6 @@ interface ResponseServiceAsync { retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), @@ -204,21 +214,18 @@ interface ResponseServiceAsync { retrieve(responseId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: ResponseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: ResponseRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( responseId: String, requestOptions: RequestOptions, @@ -229,12 +236,10 @@ interface ResponseServiceAsync { * Returns a raw HTTP response for `delete /v1/responses/{response_id}`, but is otherwise * the same as [ResponseServiceAsync.delete]. */ - @MustBeClosed fun delete(responseId: String): CompletableFuture> = delete(responseId, ResponseDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), @@ -243,7 +248,6 @@ interface ResponseServiceAsync { delete(params.toBuilder().responseId(responseId).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), @@ -251,21 +255,18 @@ interface ResponseServiceAsync { delete(responseId, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: ResponseDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( responseId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt index 06a1a6e1..aaa53f42 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt @@ -25,6 +25,7 @@ import ai.hanzo.api.models.responses.ResponseRetrieveResponse import ai.hanzo.api.services.async.responses.InputItemServiceAsync import ai.hanzo.api.services.async.responses.InputItemServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ResponseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -40,6 +41,9 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ResponseServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ResponseServiceAsync = + ResponseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun inputItems(): InputItemServiceAsync = inputItems override fun create( @@ -72,6 +76,13 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C InputItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ResponseServiceAsync.WithRawResponse = + ResponseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun inputItems(): InputItemServiceAsync.WithRawResponse = inputItems private val createHandler: Handler = @@ -85,6 +96,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -119,6 +131,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -152,6 +165,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt index faf0caa0..eb3265fb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.routes.RouteListParams import ai.hanzo.api.models.routes.RouteListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RouteServiceAsync { @@ -16,6 +17,13 @@ interface RouteServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteServiceAsync + /** Get a list of available routes in the FastAPI application. */ fun list(): CompletableFuture = list(RouteListParams.none()) @@ -37,30 +45,35 @@ interface RouteServiceAsync { /** A view of [RouteServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /routes`, but is otherwise the same as * [RouteServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(RouteListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: RouteListParams = RouteListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: RouteListParams = RouteListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt index 6207c375..c20fc0b2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.routes.RouteListParams import ai.hanzo.api.models.routes.RouteListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class RouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RouteServiceAsync { @@ -27,6 +28,9 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): RouteServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RouteServiceAsync = + RouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: RouteListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RouteServiceAsync.WithRawResponse = + RouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("routes") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt index d7e74df9..90bca4ce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.settings.SettingRetrieveParams import ai.hanzo.api.models.settings.SettingRetrieveResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SettingServiceAsync { @@ -16,6 +17,13 @@ interface SettingServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SettingServiceAsync + /** * Returns a list of llm level settings * @@ -62,30 +70,35 @@ interface SettingServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SettingServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /settings`, but is otherwise the same as * [SettingServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(): CompletableFuture> = retrieve(SettingRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none() ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt index 3a47de87..a34e4efc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.settings.SettingRetrieveParams import ai.hanzo.api.models.settings.SettingRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SettingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SettingServiceAsync { @@ -27,6 +28,9 @@ class SettingServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): SettingServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SettingServiceAsync = + SettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: SettingRetrieveParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class SettingServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SettingServiceAsync.WithRawResponse = + SettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class SettingServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("settings") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt index f7d300fb..9b110fb3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.spend.SpendCalculateSpendParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.spend.SpendListLogsParams import ai.hanzo.api.models.spend.SpendListLogsResponse import ai.hanzo.api.models.spend.SpendListTagsParams import ai.hanzo.api.models.spend.SpendListTagsResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SpendServiceAsync { @@ -20,6 +21,13 @@ interface SpendServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpendServiceAsync + /** * Accepts all the params of completion_cost. * @@ -170,30 +178,35 @@ interface SpendServiceAsync { /** A view of [SpendServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SpendServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /spend/calculate`, but is otherwise the same as * [SpendServiceAsync.calculateSpend]. */ - @MustBeClosed fun calculateSpend(): CompletableFuture> = calculateSpend(SpendCalculateSpendParams.none()) /** @see [calculateSpend] */ - @MustBeClosed fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [calculateSpend] */ - @MustBeClosed fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none() ): CompletableFuture> = calculateSpend(params, RequestOptions.none()) /** @see [calculateSpend] */ - @MustBeClosed fun calculateSpend( requestOptions: RequestOptions ): CompletableFuture> = @@ -203,26 +216,22 @@ interface SpendServiceAsync { * Returns a raw HTTP response for `get /spend/logs`, but is otherwise the same as * [SpendServiceAsync.listLogs]. */ - @MustBeClosed fun listLogs(): CompletableFuture>> = listLogs(SpendListLogsParams.none()) /** @see [listLogs] */ - @MustBeClosed fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [listLogs] */ - @MustBeClosed fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none() ): CompletableFuture>> = listLogs(params, RequestOptions.none()) /** @see [listLogs] */ - @MustBeClosed fun listLogs( requestOptions: RequestOptions ): CompletableFuture>> = @@ -232,26 +241,22 @@ interface SpendServiceAsync { * Returns a raw HTTP response for `get /spend/tags`, but is otherwise the same as * [SpendServiceAsync.listTags]. */ - @MustBeClosed fun listTags(): CompletableFuture>> = listTags(SpendListTagsParams.none()) /** @see [listTags] */ - @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [listTags] */ - @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): CompletableFuture>> = listTags(params, RequestOptions.none()) /** @see [listTags] */ - @MustBeClosed fun listTags( requestOptions: RequestOptions ): CompletableFuture>> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt index 6eb73f36..8cc55d70 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.spend.SpendListLogsResponse import ai.hanzo.api.models.spend.SpendListTagsParams import ai.hanzo.api.models.spend.SpendListTagsResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SpendServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SpendServiceAsync { @@ -32,6 +33,9 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): SpendServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpendServiceAsync = + SpendServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun calculateSpend( params: SpendCalculateSpendParams, requestOptions: RequestOptions, @@ -58,6 +62,13 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpendServiceAsync.WithRawResponse = + SpendServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val calculateSpendHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -69,6 +80,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("spend", "calculate") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -100,6 +112,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("spend", "logs") .build() .prepareAsync(clientOptions, params) @@ -130,6 +143,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("spend", "tags") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt index e06cc096..e395dd04 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.team.TeamAddMemberParams @@ -30,8 +31,8 @@ import ai.hanzo.api.models.team.TeamUpdateParams import ai.hanzo.api.models.team.TeamUpdateResponse import ai.hanzo.api.services.async.team.CallbackServiceAsync import ai.hanzo.api.services.async.team.ModelServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface TeamServiceAsync { @@ -40,6 +41,13 @@ interface TeamServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TeamServiceAsync + fun model(): ModelServiceAsync fun callback(): CallbackServiceAsync @@ -435,6 +443,13 @@ interface TeamServiceAsync { /** A view of [TeamServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TeamServiceAsync.WithRawResponse + fun model(): ModelServiceAsync.WithRawResponse fun callback(): CallbackServiceAsync.WithRawResponse @@ -443,26 +458,22 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/new`, but is otherwise the same as * [TeamServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(TeamCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: TeamCreateParams = TeamCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: TeamCreateParams = TeamCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -472,14 +483,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/update`, but is otherwise the same as * [TeamServiceAsync.update]. */ - @MustBeClosed fun update( params: TeamUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: TeamUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -489,26 +498,22 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `get /team/list`, but is otherwise the same as * [TeamServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(TeamListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: TeamListParams = TeamListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: TeamListParams = TeamListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -518,14 +523,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/delete`, but is otherwise the same as * [TeamServiceAsync.delete]. */ - @MustBeClosed fun delete( params: TeamDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: TeamDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -535,14 +538,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/member_add`, but is otherwise the same as * [TeamServiceAsync.addMember]. */ - @MustBeClosed fun addMember( params: TeamAddMemberParams ): CompletableFuture> = addMember(params, RequestOptions.none()) /** @see [addMember] */ - @MustBeClosed fun addMember( params: TeamAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -552,12 +553,10 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/block`, but is otherwise the same as * [TeamServiceAsync.block]. */ - @MustBeClosed fun block(params: TeamBlockParams): CompletableFuture> = block(params, RequestOptions.none()) /** @see [block] */ - @MustBeClosed fun block( params: TeamBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -567,14 +566,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/{team_id}/disable_logging`, but is otherwise * the same as [TeamServiceAsync.disableLogging]. */ - @MustBeClosed fun disableLogging( teamId: String ): CompletableFuture> = disableLogging(teamId, TeamDisableLoggingParams.none()) /** @see [disableLogging] */ - @MustBeClosed fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), @@ -583,7 +580,6 @@ interface TeamServiceAsync { disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) /** @see [disableLogging] */ - @MustBeClosed fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), @@ -591,21 +587,18 @@ interface TeamServiceAsync { disableLogging(teamId, params, RequestOptions.none()) /** @see [disableLogging] */ - @MustBeClosed fun disableLogging( params: TeamDisableLoggingParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [disableLogging] */ - @MustBeClosed fun disableLogging( params: TeamDisableLoggingParams ): CompletableFuture> = disableLogging(params, RequestOptions.none()) /** @see [disableLogging] */ - @MustBeClosed fun disableLogging( teamId: String, requestOptions: RequestOptions, @@ -616,26 +609,22 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `get /team/available`, but is otherwise the same as * [TeamServiceAsync.listAvailable]. */ - @MustBeClosed fun listAvailable(): CompletableFuture> = listAvailable(TeamListAvailableParams.none()) /** @see [listAvailable] */ - @MustBeClosed fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [listAvailable] */ - @MustBeClosed fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none() ): CompletableFuture> = listAvailable(params, RequestOptions.none()) /** @see [listAvailable] */ - @MustBeClosed fun listAvailable( requestOptions: RequestOptions ): CompletableFuture> = @@ -645,14 +634,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/member_delete`, but is otherwise the same as * [TeamServiceAsync.removeMember]. */ - @MustBeClosed fun removeMember( params: TeamRemoveMemberParams ): CompletableFuture> = removeMember(params, RequestOptions.none()) /** @see [removeMember] */ - @MustBeClosed fun removeMember( params: TeamRemoveMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -662,26 +649,22 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `get /team/info`, but is otherwise the same as * [TeamServiceAsync.retrieveInfo]. */ - @MustBeClosed fun retrieveInfo(): CompletableFuture> = retrieveInfo(TeamRetrieveInfoParams.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = @@ -691,14 +674,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/unblock`, but is otherwise the same as * [TeamServiceAsync.unblock]. */ - @MustBeClosed fun unblock( params: TeamUnblockParams ): CompletableFuture> = unblock(params, RequestOptions.none()) /** @see [unblock] */ - @MustBeClosed fun unblock( params: TeamUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -708,14 +689,12 @@ interface TeamServiceAsync { * Returns a raw HTTP response for `post /team/member_update`, but is otherwise the same as * [TeamServiceAsync.updateMember]. */ - @MustBeClosed fun updateMember( params: TeamUpdateMemberParams ): CompletableFuture> = updateMember(params, RequestOptions.none()) /** @see [updateMember] */ - @MustBeClosed fun updateMember( params: TeamUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt index 948b848b..ecb9aeeb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt @@ -45,6 +45,7 @@ import ai.hanzo.api.services.async.team.CallbackServiceAsyncImpl import ai.hanzo.api.services.async.team.ModelServiceAsync import ai.hanzo.api.services.async.team.ModelServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class TeamServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -60,6 +61,9 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): TeamServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TeamServiceAsync = + TeamServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun model(): ModelServiceAsync = model override fun callback(): CallbackServiceAsync = callback @@ -161,6 +165,13 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien CallbackServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): TeamServiceAsync.WithRawResponse = + TeamServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun model(): ModelServiceAsync.WithRawResponse = model override fun callback(): CallbackServiceAsync.WithRawResponse = callback @@ -175,6 +186,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -205,6 +217,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -235,6 +248,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "list") .build() .prepareAsync(clientOptions, params) @@ -264,6 +278,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -295,6 +310,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "member_add") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -325,6 +341,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "block") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -359,6 +376,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", params._pathParam(0), "disable_logging") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -390,6 +408,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "available") .build() .prepareAsync(clientOptions, params) @@ -420,6 +439,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "member_delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -451,6 +471,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "info") .build() .prepareAsync(clientOptions, params) @@ -481,6 +502,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "unblock") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -512,6 +534,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "member_update") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt index f9b084d2..795abdce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.test.TestPingParams import ai.hanzo.api.models.test.TestPingResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface TestServiceAsync { @@ -16,6 +17,13 @@ interface TestServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TestServiceAsync + /** * [DEPRECATED] use `/health/liveliness` instead. * @@ -44,30 +52,33 @@ interface TestServiceAsync { /** A view of [TestServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TestServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /test`, but is otherwise the same as * [TestServiceAsync.ping]. */ - @MustBeClosed fun ping(): CompletableFuture> = ping(TestPingParams.none()) /** @see [ping] */ - @MustBeClosed fun ping( params: TestPingParams = TestPingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [ping] */ - @MustBeClosed fun ping( params: TestPingParams = TestPingParams.none() ): CompletableFuture> = ping(params, RequestOptions.none()) /** @see [ping] */ - @MustBeClosed fun ping( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt index 60c5aaec..c0e4c6fe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.test.TestPingParams import ai.hanzo.api.models.test.TestPingResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class TestServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TestServiceAsync { @@ -27,6 +28,9 @@ class TestServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): TestServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TestServiceAsync = + TestServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun ping( params: TestPingParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class TestServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TestServiceAsync.WithRawResponse = + TestServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val pingHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class TestServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("test") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt index 17c2862d..17e0e5e4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.threads.ThreadCreateParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.threads.ThreadRetrieveParams import ai.hanzo.api.models.threads.ThreadRetrieveResponse import ai.hanzo.api.services.async.threads.MessageServiceAsync import ai.hanzo.api.services.async.threads.RunServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ThreadServiceAsync { @@ -20,6 +21,13 @@ interface ThreadServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ThreadServiceAsync + fun messages(): MessageServiceAsync fun runs(): RunServiceAsync @@ -90,6 +98,15 @@ interface ThreadServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ThreadServiceAsync.WithRawResponse + fun messages(): MessageServiceAsync.WithRawResponse fun runs(): RunServiceAsync.WithRawResponse @@ -98,26 +115,22 @@ interface ThreadServiceAsync { * Returns a raw HTTP response for `post /v1/threads`, but is otherwise the same as * [ThreadServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(ThreadCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: ThreadCreateParams = ThreadCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: ThreadCreateParams = ThreadCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -127,12 +140,10 @@ interface ThreadServiceAsync { * Returns a raw HTTP response for `get /v1/threads/{thread_id}`, but is otherwise the same * as [ThreadServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(threadId: String): CompletableFuture> = retrieve(threadId, ThreadRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), @@ -141,7 +152,6 @@ interface ThreadServiceAsync { retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), @@ -149,21 +159,18 @@ interface ThreadServiceAsync { retrieve(threadId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: ThreadRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( threadId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt index 36af219e..0f474d19 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt @@ -25,6 +25,7 @@ import ai.hanzo.api.services.async.threads.MessageServiceAsyncImpl import ai.hanzo.api.services.async.threads.RunServiceAsync import ai.hanzo.api.services.async.threads.RunServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ThreadServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -40,6 +41,9 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): ThreadServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ThreadServiceAsync = + ThreadServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun messages(): MessageServiceAsync = messages override fun runs(): RunServiceAsync = runs @@ -71,6 +75,13 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ThreadServiceAsync.WithRawResponse = + ThreadServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun messages(): MessageServiceAsync.WithRawResponse = messages override fun runs(): RunServiceAsync.WithRawResponse = runs @@ -86,6 +97,7 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -120,6 +132,7 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt index 709cb4b4..279edf4d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.user.UserCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.user.UserRetrieveInfoParams import ai.hanzo.api.models.user.UserRetrieveInfoResponse import ai.hanzo.api.models.user.UserUpdateParams import ai.hanzo.api.models.user.UserUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface UserServiceAsync { @@ -24,6 +25,13 @@ interface UserServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserServiceAsync + /** * Use this to create a new INTERNAL user with a budget. Internal Users can access LLM Admin UI * to make keys, request access to models. This creates a new user and generates a new api key @@ -271,30 +279,33 @@ interface UserServiceAsync { /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /user/new`, but is otherwise the same as * [UserServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(UserCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: UserCreateParams = UserCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: UserCreateParams = UserCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -304,26 +315,22 @@ interface UserServiceAsync { * Returns a raw HTTP response for `post /user/update`, but is otherwise the same as * [UserServiceAsync.update]. */ - @MustBeClosed fun update(): CompletableFuture> = update(UserUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( params: UserUpdateParams = UserUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: UserUpdateParams = UserUpdateParams.none() ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( requestOptions: RequestOptions ): CompletableFuture> = @@ -333,26 +340,22 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /user/get_users`, but is otherwise the same as * [UserServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(UserListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: UserListParams = UserListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -362,14 +365,12 @@ interface UserServiceAsync { * Returns a raw HTTP response for `post /user/delete`, but is otherwise the same as * [UserServiceAsync.delete]. */ - @MustBeClosed fun delete( params: UserDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: UserDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -379,26 +380,22 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /user/info`, but is otherwise the same as * [UserServiceAsync.retrieveInfo]. */ - @MustBeClosed fun retrieveInfo(): CompletableFuture> = retrieveInfo(UserRetrieveInfoParams.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt index 2d817fe2..c169e2ec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.user.UserRetrieveInfoResponse import ai.hanzo.api.models.user.UserUpdateParams import ai.hanzo.api.models.user.UserUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : UserServiceAsync { @@ -36,6 +37,9 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UserServiceAsync = + UserServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: UserCreateParams, requestOptions: RequestOptions, @@ -76,6 +80,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): UserServiceAsync.WithRawResponse = + UserServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -86,6 +97,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -116,6 +128,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -146,6 +159,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "get_users") .build() .prepareAsync(clientOptions, params) @@ -175,6 +189,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -206,6 +221,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "info") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt index c377e3e4..5f2b1507 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.utils.UtilGetSupportedOpenAIParamsParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.utils.UtilTokenCounterParams import ai.hanzo.api.models.utils.UtilTokenCounterResponse import ai.hanzo.api.models.utils.UtilTransformRequestParams import ai.hanzo.api.models.utils.UtilTransformRequestResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface UtilServiceAsync { @@ -20,6 +21,13 @@ interface UtilServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UtilServiceAsync + /** * Returns supported openai params for a given llm model name * @@ -66,18 +74,23 @@ interface UtilServiceAsync { /** A view of [UtilServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UtilServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /utils/supported_openai_params`, but is otherwise * the same as [UtilServiceAsync.getSupportedOpenAIParams]. */ - @MustBeClosed fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams ): CompletableFuture> = getSupportedOpenAIParams(params, RequestOptions.none()) /** @see [getSupportedOpenAIParams] */ - @MustBeClosed fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -87,14 +100,12 @@ interface UtilServiceAsync { * Returns a raw HTTP response for `post /utils/token_counter`, but is otherwise the same as * [UtilServiceAsync.tokenCounter]. */ - @MustBeClosed fun tokenCounter( params: UtilTokenCounterParams ): CompletableFuture> = tokenCounter(params, RequestOptions.none()) /** @see [tokenCounter] */ - @MustBeClosed fun tokenCounter( params: UtilTokenCounterParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -104,14 +115,12 @@ interface UtilServiceAsync { * Returns a raw HTTP response for `post /utils/transform_request`, but is otherwise the * same as [UtilServiceAsync.transformRequest]. */ - @MustBeClosed fun transformRequest( params: UtilTransformRequestParams ): CompletableFuture> = transformRequest(params, RequestOptions.none()) /** @see [transformRequest] */ - @MustBeClosed fun transformRequest( params: UtilTransformRequestParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt index aeb17449..db944d30 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.utils.UtilTokenCounterResponse import ai.hanzo.api.models.utils.UtilTransformRequestParams import ai.hanzo.api.models.utils.UtilTransformRequestResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class UtilServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : UtilServiceAsync { @@ -32,6 +33,9 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): UtilServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UtilServiceAsync = + UtilServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, requestOptions: RequestOptions, @@ -58,6 +62,13 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): UtilServiceAsync.WithRawResponse = + UtilServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val getSupportedOpenAIParamsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -69,6 +80,7 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("utils", "supported_openai_params") .build() .prepareAsync(clientOptions, params) @@ -99,6 +111,7 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("utils", "token_counter") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -130,6 +143,7 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("utils", "transform_request") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt index d502f18d..44cfe4d0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.vertexai.VertexAiCreateParams @@ -14,8 +15,8 @@ import ai.hanzo.api.models.vertexai.VertexAiRetrieveParams import ai.hanzo.api.models.vertexai.VertexAiRetrieveResponse import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import ai.hanzo.api.models.vertexai.VertexAiUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface VertexAiServiceAsync { @@ -24,6 +25,13 @@ interface VertexAiServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VertexAiServiceAsync + /** * Call LLM proxy via Vertex AI SDK. * @@ -225,16 +233,23 @@ interface VertexAiServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VertexAiServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiServiceAsync.create]. */ - @MustBeClosed fun create(endpoint: String): CompletableFuture> = create(endpoint, VertexAiCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), @@ -243,7 +258,6 @@ interface VertexAiServiceAsync { create(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), @@ -251,21 +265,18 @@ interface VertexAiServiceAsync { create(endpoint, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: VertexAiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: VertexAiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( endpoint: String, requestOptions: RequestOptions, @@ -276,14 +287,12 @@ interface VertexAiServiceAsync { * Returns a raw HTTP response for `get /vertex_ai/{endpoint}`, but is otherwise the same as * [VertexAiServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( endpoint: String ): CompletableFuture> = retrieve(endpoint, VertexAiRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), @@ -292,7 +301,6 @@ interface VertexAiServiceAsync { retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), @@ -300,21 +308,18 @@ interface VertexAiServiceAsync { retrieve(endpoint, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: VertexAiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: VertexAiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -325,12 +330,10 @@ interface VertexAiServiceAsync { * Returns a raw HTTP response for `put /vertex_ai/{endpoint}`, but is otherwise the same as * [VertexAiServiceAsync.update]. */ - @MustBeClosed fun update(endpoint: String): CompletableFuture> = update(endpoint, VertexAiUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), @@ -339,7 +342,6 @@ interface VertexAiServiceAsync { update(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), @@ -347,21 +349,18 @@ interface VertexAiServiceAsync { update(endpoint, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: VertexAiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: VertexAiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpoint: String, requestOptions: RequestOptions, @@ -372,12 +371,10 @@ interface VertexAiServiceAsync { * Returns a raw HTTP response for `delete /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiServiceAsync.delete]. */ - @MustBeClosed fun delete(endpoint: String): CompletableFuture> = delete(endpoint, VertexAiDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), @@ -386,7 +383,6 @@ interface VertexAiServiceAsync { delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), @@ -394,21 +390,18 @@ interface VertexAiServiceAsync { delete(endpoint, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: VertexAiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: VertexAiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( endpoint: String, requestOptions: RequestOptions, @@ -419,12 +412,10 @@ interface VertexAiServiceAsync { * Returns a raw HTTP response for `patch /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiServiceAsync.patch]. */ - @MustBeClosed fun patch(endpoint: String): CompletableFuture> = patch(endpoint, VertexAiPatchParams.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), @@ -433,7 +424,6 @@ interface VertexAiServiceAsync { patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), @@ -441,21 +431,18 @@ interface VertexAiServiceAsync { patch(endpoint, params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [patch] */ - @MustBeClosed fun patch( params: VertexAiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) /** @see [patch] */ - @MustBeClosed fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt index 778698e9..0c8c01dc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.vertexai.VertexAiRetrieveResponse import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import ai.hanzo.api.models.vertexai.VertexAiUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): VertexAiServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): VertexAiServiceAsync = + VertexAiServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: VertexAiCreateParams, requestOptions: RequestOptions, @@ -78,6 +82,13 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): VertexAiServiceAsync.WithRawResponse = + VertexAiServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -92,6 +103,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -126,6 +138,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -159,6 +172,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -193,6 +207,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -227,6 +242,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt index b8ee4764..77d470d4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.audio +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.audio.speech.SpeechCreateParams import ai.hanzo.api.models.audio.speech.SpeechCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SpeechServiceAsync { @@ -16,6 +17,13 @@ interface SpeechServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpeechServiceAsync + /** * Same params as: * @@ -43,30 +51,35 @@ interface SpeechServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SpeechServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/audio/speech`, but is otherwise the same as * [SpeechServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(SpeechCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: SpeechCreateParams = SpeechCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: SpeechCreateParams = SpeechCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt index b556353a..dd05d93e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.audio.speech.SpeechCreateParams import ai.hanzo.api.models.audio.speech.SpeechCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SpeechServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SpeechServiceAsync { @@ -28,6 +29,9 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): SpeechServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpeechServiceAsync = + SpeechServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SpeechCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpeechServiceAsync.WithRawResponse = + SpeechServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "audio", "speech") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt index cb176d1f..f7922b23 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.audio +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateParams import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface TranscriptionServiceAsync { @@ -16,6 +17,13 @@ interface TranscriptionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranscriptionServiceAsync + /** * Same params as: * @@ -36,18 +44,25 @@ interface TranscriptionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranscriptionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/audio/transcriptions`, but is otherwise the * same as [TranscriptionServiceAsync.create]. */ - @MustBeClosed fun create( params: TranscriptionCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt index dc141ffd..4896f1e8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateParams import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class TranscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TranscriptionServiceAsync { @@ -28,6 +29,9 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): TranscriptionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TranscriptionServiceAsync = + TranscriptionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TranscriptionServiceAsync.WithRawResponse = + TranscriptionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "audio", "transcriptions") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt index ea4b6c22..053da526 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.batches +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.batches.cancel.CancelCancelParams import ai.hanzo.api.models.batches.cancel.CancelCancelResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CancelServiceAsync { @@ -16,6 +17,13 @@ interface CancelServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CancelServiceAsync + /** * Cancel a batch. This is the equivalent of POST * https://api.openai.com/v1/batches/{batch_id}/cancel @@ -68,16 +76,23 @@ interface CancelServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CancelServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /batches/{batch_id}/cancel`, but is otherwise the * same as [CancelServiceAsync.cancel]. */ - @MustBeClosed fun cancel(batchId: String): CompletableFuture> = cancel(batchId, CancelCancelParams.none()) /** @see [cancel] */ - @MustBeClosed fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), @@ -86,7 +101,6 @@ interface CancelServiceAsync { cancel(params.toBuilder().batchId(batchId).build(), requestOptions) /** @see [cancel] */ - @MustBeClosed fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), @@ -94,21 +108,18 @@ interface CancelServiceAsync { cancel(batchId, params, RequestOptions.none()) /** @see [cancel] */ - @MustBeClosed fun cancel( params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [cancel] */ - @MustBeClosed fun cancel( params: CancelCancelParams ): CompletableFuture> = cancel(params, RequestOptions.none()) /** @see [cancel] */ - @MustBeClosed fun cancel( batchId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt index 7fb07ffd..e6fca64d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.batches.cancel.CancelCancelParams import ai.hanzo.api.models.batches.cancel.CancelCancelResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CancelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): CancelServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CancelServiceAsync = + CancelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun cancel( params: CancelCancelParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CancelServiceAsync.WithRawResponse = + CancelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val cancelHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -56,6 +67,7 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt index 34928b14..045388c2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.cache +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.cache.redis.RediRetrieveInfoParams import ai.hanzo.api.models.cache.redis.RediRetrieveInfoResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RediServiceAsync { @@ -16,6 +17,13 @@ interface RediServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RediServiceAsync + /** Endpoint for getting /redis/info */ fun retrieveInfo(): CompletableFuture = retrieveInfo(RediRetrieveInfoParams.none()) @@ -38,30 +46,33 @@ interface RediServiceAsync { /** A view of [RediServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RediServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /cache/redis/info`, but is otherwise the same as * [RediServiceAsync.retrieveInfo]. */ - @MustBeClosed fun retrieveInfo(): CompletableFuture> = retrieveInfo(RediRetrieveInfoParams.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) /** @see [retrieveInfo] */ - @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt index c52ce532..c5af150d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.cache.redis.RediRetrieveInfoParams import ai.hanzo.api.models.cache.redis.RediRetrieveInfoResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class RediServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RediServiceAsync { @@ -27,6 +28,9 @@ class RediServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): RediServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RediServiceAsync = + RediServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveInfo( params: RediRetrieveInfoParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class RediServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RediServiceAsync.WithRawResponse = + RediServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class RediServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "redis", "info") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt index e9cba727..f10d9536 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.chat +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.chat.completions.CompletionCreateParams import ai.hanzo.api.models.chat.completions.CompletionCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompletionServiceAsync { @@ -16,6 +17,13 @@ interface CompletionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompletionServiceAsync + /** * Follows the exact same API spec as `OpenAI's Chat API * https://platform.openai.com/docs/api-reference/chat` @@ -59,30 +67,35 @@ interface CompletionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompletionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/chat/completions`, but is otherwise the same as * [CompletionServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(CompletionCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt index d0bcadf2..750b6ba5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.chat.completions.CompletionCreateParams import ai.hanzo.api.models.chat.completions.CompletionCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompletionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompletionServiceAsync { @@ -28,6 +29,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): CompletionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompletionServiceAsync = + CompletionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompletionServiceAsync.WithRawResponse = + CompletionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "chat", "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt index 63033088..28c8a1ad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async.config +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointCreateParams @@ -11,8 +12,8 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListPar import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointResponse import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PassThroughEndpointServiceAsync { @@ -21,6 +22,13 @@ interface PassThroughEndpointServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PassThroughEndpointServiceAsync + /** Create new pass-through endpoint */ fun create( params: PassThroughEndpointCreateParams @@ -113,18 +121,25 @@ interface PassThroughEndpointServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PassThroughEndpointServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /config/pass_through_endpoint`, but is otherwise * the same as [PassThroughEndpointServiceAsync.create]. */ - @MustBeClosed fun create( params: PassThroughEndpointCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: PassThroughEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -134,14 +149,12 @@ interface PassThroughEndpointServiceAsync { * Returns a raw HTTP response for `post /config/pass_through_endpoint/{endpoint_id}`, but * is otherwise the same as [PassThroughEndpointServiceAsync.update]. */ - @MustBeClosed fun update( endpointId: String ): CompletableFuture> = update(endpointId, PassThroughEndpointUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), @@ -150,7 +163,6 @@ interface PassThroughEndpointServiceAsync { update(params.toBuilder().endpointId(endpointId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), @@ -158,21 +170,18 @@ interface PassThroughEndpointServiceAsync { update(endpointId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: PassThroughEndpointUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( endpointId: String, requestOptions: RequestOptions, @@ -183,26 +192,22 @@ interface PassThroughEndpointServiceAsync { * Returns a raw HTTP response for `get /config/pass_through_endpoint`, but is otherwise the * same as [PassThroughEndpointServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(PassThroughEndpointListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -212,14 +217,12 @@ interface PassThroughEndpointServiceAsync { * Returns a raw HTTP response for `delete /config/pass_through_endpoint`, but is otherwise * the same as [PassThroughEndpointServiceAsync.delete]. */ - @MustBeClosed fun delete( params: PassThroughEndpointDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: PassThroughEndpointDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt index 2b45f059..5b1c9a02 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointRespons import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PassThroughEndpointServiceAsyncImpl @@ -36,6 +37,13 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp override fun withRawResponse(): PassThroughEndpointServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): PassThroughEndpointServiceAsync = + PassThroughEndpointServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun create( params: PassThroughEndpointCreateParams, requestOptions: RequestOptions, @@ -69,6 +77,13 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PassThroughEndpointServiceAsync.WithRawResponse = + PassThroughEndpointServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -80,6 +95,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -114,6 +130,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -145,6 +162,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint") .build() .prepareAsync(clientOptions, params) @@ -175,6 +193,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt index 413fe9de..aba04aec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.engines +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.engines.chat.ChatCompleteParams import ai.hanzo.api.models.engines.chat.ChatCompleteResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ChatServiceAsync { @@ -16,6 +17,13 @@ interface ChatServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync + /** * Follows the exact same API spec as `OpenAI's Chat API * https://platform.openai.com/docs/api-reference/chat` @@ -72,16 +80,21 @@ interface ChatServiceAsync { /** A view of [ChatServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /engines/{model}/chat/completions`, but is * otherwise the same as [ChatServiceAsync.complete]. */ - @MustBeClosed fun complete(model: String): CompletableFuture> = complete(model, ChatCompleteParams.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -90,7 +103,6 @@ interface ChatServiceAsync { complete(params.toBuilder().model(model).build(), requestOptions) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -98,21 +110,18 @@ interface ChatServiceAsync { complete(model, params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [complete] */ - @MustBeClosed fun complete( params: ChatCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt index f99d1476..114a7270 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.engines.chat.ChatCompleteParams import ai.hanzo.api.models.engines.chat.ChatCompleteResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ChatServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): ChatServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatServiceAsync = + ChatServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun complete( params: ChatCompleteParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ChatServiceAsync.WithRawResponse = + ChatServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -56,6 +67,7 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("engines", params._pathParam(0), "chat", "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt index 2001df85..2fa183aa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.files +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.files.content.ContentRetrieveParams import ai.hanzo.api.models.files.content.ContentRetrieveResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ContentServiceAsync { @@ -16,6 +17,13 @@ interface ContentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContentServiceAsync + /** * Returns information about a specific file. that can be used across - Assistants API, Batch * API This is the equivalent of GET https://api.openai.com/v1/files/{file_id}/content @@ -58,11 +66,19 @@ interface ContentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ContentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /{provider}/v1/files/{file_id}/content`, but is * otherwise the same as [ContentServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( fileId: String, params: ContentRetrieveParams, @@ -70,7 +86,6 @@ interface ContentServiceAsync { retrieve(fileId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( fileId: String, params: ContentRetrieveParams, @@ -79,14 +94,12 @@ interface ContentServiceAsync { retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: ContentRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt index a46c7769..cf7b9b24 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.files.content.ContentRetrieveParams import ai.hanzo.api.models.files.content.ContentRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ContentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): ContentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ContentServiceAsync = + ContentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ContentServiceAsync.WithRawResponse = + ContentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( params._pathParam(0), "v1", diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt index 7b6c775b..1c2dd224 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async.finetuning +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.finetuning.jobs.JobCreateParams @@ -11,8 +12,8 @@ import ai.hanzo.api.models.finetuning.jobs.JobListResponse import ai.hanzo.api.models.finetuning.jobs.JobRetrieveParams import ai.hanzo.api.models.finetuning.jobs.JobRetrieveResponse import ai.hanzo.api.services.async.finetuning.jobs.CancelServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface JobServiceAsync { @@ -21,6 +22,13 @@ interface JobServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync + fun cancel(): CancelServiceAsync /** @@ -103,18 +111,23 @@ interface JobServiceAsync { /** A view of [JobServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync.WithRawResponse + fun cancel(): CancelServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /v1/fine_tuning/jobs`, but is otherwise the same as * [JobServiceAsync.create]. */ - @MustBeClosed fun create(params: JobCreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: JobCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -124,7 +137,6 @@ interface JobServiceAsync { * Returns a raw HTTP response for `get /v1/fine_tuning/jobs/{fine_tuning_job_id}`, but is * otherwise the same as [JobServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( fineTuningJobId: String, params: JobRetrieveParams, @@ -132,7 +144,6 @@ interface JobServiceAsync { retrieve(fineTuningJobId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( fineTuningJobId: String, params: JobRetrieveParams, @@ -141,14 +152,12 @@ interface JobServiceAsync { retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -158,12 +167,10 @@ interface JobServiceAsync { * Returns a raw HTTP response for `get /v1/fine_tuning/jobs`, but is otherwise the same as * [JobServiceAsync.list]. */ - @MustBeClosed fun list(params: JobListParams): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: JobListParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt index a04562c5..bead1635 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt @@ -25,6 +25,7 @@ import ai.hanzo.api.models.finetuning.jobs.JobRetrieveResponse import ai.hanzo.api.services.async.finetuning.jobs.CancelServiceAsync import ai.hanzo.api.services.async.finetuning.jobs.CancelServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -38,6 +39,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun cancel(): CancelServiceAsync = cancel override fun create( @@ -70,6 +74,13 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client CancelServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun cancel(): CancelServiceAsync.WithRawResponse = cancel private val createHandler: Handler = @@ -82,6 +93,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -116,6 +128,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -145,6 +158,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt index 1b76ab28..b7a67db8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.finetuning.jobs +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CancelServiceAsync { @@ -16,6 +17,13 @@ interface CancelServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CancelServiceAsync + /** * Cancel a fine-tuning job. * @@ -66,18 +74,25 @@ interface CancelServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CancelServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel`, * but is otherwise the same as [CancelServiceAsync.create]. */ - @MustBeClosed fun create( fineTuningJobId: String ): CompletableFuture> = create(fineTuningJobId, CancelCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), @@ -86,7 +101,6 @@ interface CancelServiceAsync { create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), @@ -94,21 +108,18 @@ interface CancelServiceAsync { create(fineTuningJobId, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: CancelCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( fineTuningJobId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt index 6bfb1375..c733f5dd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CancelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): CancelServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CancelServiceAsync = + CancelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CancelCreateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CancelServiceAsync.WithRawResponse = + CancelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -56,6 +67,7 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt index 04668be4..619ec95a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async.global +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.global.spend.SpendListTagsParams @@ -10,8 +11,8 @@ import ai.hanzo.api.models.global.spend.SpendResetParams import ai.hanzo.api.models.global.spend.SpendResetResponse import ai.hanzo.api.models.global.spend.SpendRetrieveReportParams import ai.hanzo.api.models.global.spend.SpendRetrieveReportResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SpendServiceAsync { @@ -20,6 +21,13 @@ interface SpendServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpendServiceAsync + /** * LLM Enterprise - View Spend Per Request Tag. Used by LLM UI * @@ -107,30 +115,35 @@ interface SpendServiceAsync { /** A view of [SpendServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SpendServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /global/spend/tags`, but is otherwise the same as * [SpendServiceAsync.listTags]. */ - @MustBeClosed fun listTags(): CompletableFuture>> = listTags(SpendListTagsParams.none()) /** @see [listTags] */ - @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [listTags] */ - @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): CompletableFuture>> = listTags(params, RequestOptions.none()) /** @see [listTags] */ - @MustBeClosed fun listTags( requestOptions: RequestOptions ): CompletableFuture>> = @@ -140,26 +153,22 @@ interface SpendServiceAsync { * Returns a raw HTTP response for `post /global/spend/reset`, but is otherwise the same as * [SpendServiceAsync.reset]. */ - @MustBeClosed fun reset(): CompletableFuture> = reset(SpendResetParams.none()) /** @see [reset] */ - @MustBeClosed fun reset( params: SpendResetParams = SpendResetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [reset] */ - @MustBeClosed fun reset( params: SpendResetParams = SpendResetParams.none() ): CompletableFuture> = reset(params, RequestOptions.none()) /** @see [reset] */ - @MustBeClosed fun reset( requestOptions: RequestOptions ): CompletableFuture> = @@ -169,27 +178,23 @@ interface SpendServiceAsync { * Returns a raw HTTP response for `get /global/spend/report`, but is otherwise the same as * [SpendServiceAsync.retrieveReport]. */ - @MustBeClosed fun retrieveReport(): CompletableFuture>> = retrieveReport(SpendRetrieveReportParams.none()) /** @see [retrieveReport] */ - @MustBeClosed fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [retrieveReport] */ - @MustBeClosed fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none() ): CompletableFuture>> = retrieveReport(params, RequestOptions.none()) /** @see [retrieveReport] */ - @MustBeClosed fun retrieveReport( requestOptions: RequestOptions ): CompletableFuture>> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt index 62713c16..1b65f174 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.global.spend.SpendResetResponse import ai.hanzo.api.models.global.spend.SpendRetrieveReportParams import ai.hanzo.api.models.global.spend.SpendRetrieveReportResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SpendServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SpendServiceAsync { @@ -32,6 +33,9 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): SpendServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpendServiceAsync = + SpendServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun listTags( params: SpendListTagsParams, requestOptions: RequestOptions, @@ -58,6 +62,13 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpendServiceAsync.WithRawResponse = + SpendServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listTagsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -69,6 +80,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("global", "spend", "tags") .build() .prepareAsync(clientOptions, params) @@ -98,6 +110,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("global", "spend", "reset") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -129,6 +142,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("global", "spend", "report") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt index 2b5fd7ad..c65300d1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.images +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.images.generations.GenerationCreateParams import ai.hanzo.api.models.images.generations.GenerationCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface GenerationServiceAsync { @@ -16,6 +17,13 @@ interface GenerationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GenerationServiceAsync + /** Image Generation */ fun create(): CompletableFuture = create(GenerationCreateParams.none()) @@ -41,30 +49,35 @@ interface GenerationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GenerationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/images/generations`, but is otherwise the same * as [GenerationServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(GenerationCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: GenerationCreateParams = GenerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: GenerationCreateParams = GenerationCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt index 9232b623..7d3b5dfc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.images.generations.GenerationCreateParams import ai.hanzo.api.models.images.generations.GenerationCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class GenerationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GenerationServiceAsync { @@ -28,6 +29,9 @@ class GenerationServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): GenerationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GenerationServiceAsync = + GenerationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: GenerationCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class GenerationServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GenerationServiceAsync.WithRawResponse = + GenerationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class GenerationServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "images", "generations") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsync.kt index c1f8885d..29980b6e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsync.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.services.async.key +import ai.hanzo.api.core.ClientOptions +import java.util.function.Consumer + interface RegenerateServiceAsync { /** @@ -9,9 +12,26 @@ interface RegenerateServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RegenerateServiceAsync + /** * A view of [RegenerateServiceAsync] that provides access to raw HTTP responses for each * method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RegenerateServiceAsync.WithRawResponse + } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsyncImpl.kt index 9eca5b9b..34ce294a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/key/RegenerateServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package ai.hanzo.api.services.async.key import ai.hanzo.api.core.ClientOptions +import java.util.function.Consumer class RegenerateServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RegenerateServiceAsync { @@ -13,6 +14,17 @@ class RegenerateServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): RegenerateServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RegenerateServiceAsync = + RegenerateServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RegenerateServiceAsync.WithRawResponse + RegenerateServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): RegenerateServiceAsync.WithRawResponse = + RegenerateServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt index 700d2969..78aafb45 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.model +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.model.info.InfoListParams import ai.hanzo.api.models.model.info.InfoListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface InfoServiceAsync { @@ -16,6 +17,13 @@ interface InfoServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoServiceAsync + /** * Provides more info about each model in /models, including config.yaml descriptions (except * api key and api base) @@ -66,30 +74,33 @@ interface InfoServiceAsync { /** A view of [InfoServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /model/info`, but is otherwise the same as * [InfoServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(InfoListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: InfoListParams = InfoListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: InfoListParams = InfoListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt index 892b5b75..d6172227 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.model.info.InfoListParams import ai.hanzo.api.models.model.info.InfoListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class InfoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InfoServiceAsync { @@ -27,6 +28,9 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): InfoServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InfoServiceAsync = + InfoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: InfoListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InfoServiceAsync.WithRawResponse = + InfoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "info") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt index 9f9c339e..8327e912 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt @@ -2,14 +2,15 @@ package ai.hanzo.api.services.async.model +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams import ai.hanzo.api.models.model.update.UpdatePartialResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface UpdateServiceAsync { @@ -18,6 +19,13 @@ interface UpdateServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UpdateServiceAsync + /** Edit existing model params */ fun full(params: UpdateFullParams): CompletableFuture = full(params, RequestOptions.none()) @@ -70,16 +78,23 @@ interface UpdateServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): UpdateServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /model/update`, but is otherwise the same as * [UpdateServiceAsync.full]. */ - @MustBeClosed fun full(params: UpdateFullParams): CompletableFuture> = full(params, RequestOptions.none()) /** @see [full] */ - @MustBeClosed fun full( params: UpdateFullParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -89,7 +104,6 @@ interface UpdateServiceAsync { * Returns a raw HTTP response for `patch /model/{model_id}/update`, but is otherwise the * same as [UpdateServiceAsync.partial]. */ - @MustBeClosed fun partial( modelId: String, params: UpdatePartialParams, @@ -97,7 +111,6 @@ interface UpdateServiceAsync { partial(modelId, params, RequestOptions.none()) /** @see [partial] */ - @MustBeClosed fun partial( modelId: String, params: UpdatePartialParams, @@ -106,14 +119,12 @@ interface UpdateServiceAsync { partial(params.toBuilder().modelId(modelId).build(), requestOptions) /** @see [partial] */ - @MustBeClosed fun partial( params: UpdatePartialParams ): CompletableFuture> = partial(params, RequestOptions.none()) /** @see [partial] */ - @MustBeClosed fun partial( params: UpdatePartialParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt index 180b515f..880b85bd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams import ai.hanzo.api.models.model.update.UpdatePartialResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class UpdateServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,6 +33,9 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): UpdateServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UpdateServiceAsync = + UpdateServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun full( params: UpdateFullParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): UpdateServiceAsync.WithRawResponse = + UpdateServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val fullHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -61,6 +72,7 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -95,6 +107,7 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", params._pathParam(0), "update") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt index 7a3cde97..92613e10 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.async.openai +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.openai.deployments.DeploymentCompleteParams @@ -9,8 +10,8 @@ import ai.hanzo.api.models.openai.deployments.DeploymentCompleteResponse import ai.hanzo.api.models.openai.deployments.DeploymentEmbedParams import ai.hanzo.api.models.openai.deployments.DeploymentEmbedResponse import ai.hanzo.api.services.async.openai.deployments.ChatServiceAsync -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DeploymentServiceAsync { @@ -19,6 +20,13 @@ interface DeploymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeploymentServiceAsync + fun chat(): ChatServiceAsync /** @@ -126,20 +134,27 @@ interface DeploymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeploymentServiceAsync.WithRawResponse + fun chat(): ChatServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /openai/deployments/{model}/completions`, but is * otherwise the same as [DeploymentServiceAsync.complete]. */ - @MustBeClosed fun complete( model: String ): CompletableFuture> = complete(model, DeploymentCompleteParams.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), @@ -148,7 +163,6 @@ interface DeploymentServiceAsync { complete(params.toBuilder().model(model).build(), requestOptions) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), @@ -156,21 +170,18 @@ interface DeploymentServiceAsync { complete(model, params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( params: DeploymentCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [complete] */ - @MustBeClosed fun complete( params: DeploymentCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, requestOptions: RequestOptions, @@ -181,12 +192,10 @@ interface DeploymentServiceAsync { * Returns a raw HTTP response for `post /openai/deployments/{model}/embeddings`, but is * otherwise the same as [DeploymentServiceAsync.embed]. */ - @MustBeClosed fun embed(model: String): CompletableFuture> = embed(model, DeploymentEmbedParams.none()) /** @see [embed] */ - @MustBeClosed fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), @@ -195,7 +204,6 @@ interface DeploymentServiceAsync { embed(params.toBuilder().model(model).build(), requestOptions) /** @see [embed] */ - @MustBeClosed fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), @@ -203,21 +211,18 @@ interface DeploymentServiceAsync { embed(model, params, RequestOptions.none()) /** @see [embed] */ - @MustBeClosed fun embed( params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [embed] */ - @MustBeClosed fun embed( params: DeploymentEmbedParams ): CompletableFuture> = embed(params, RequestOptions.none()) /** @see [embed] */ - @MustBeClosed fun embed( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt index 54852216..ed0db9b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.models.openai.deployments.DeploymentEmbedResponse import ai.hanzo.api.services.async.openai.deployments.ChatServiceAsync import ai.hanzo.api.services.async.openai.deployments.ChatServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -36,6 +37,9 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): DeploymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DeploymentServiceAsync = + DeploymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun chat(): ChatServiceAsync = chat override fun complete( @@ -61,6 +65,13 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: ChatServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): DeploymentServiceAsync.WithRawResponse = + DeploymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun chat(): ChatServiceAsync.WithRawResponse = chat private val completeHandler: Handler = @@ -77,6 +88,7 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", "deployments", params._pathParam(0), "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -111,6 +123,7 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", "deployments", params._pathParam(0), "embeddings") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt index e334659d..bf4c4ca1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.openai.deployments +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ChatServiceAsync { @@ -16,6 +17,13 @@ interface ChatServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync + /** * Follows the exact same API spec as `OpenAI's Chat API * https://platform.openai.com/docs/api-reference/chat` @@ -72,16 +80,21 @@ interface ChatServiceAsync { /** A view of [ChatServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /openai/deployments/{model}/chat/completions`, but * is otherwise the same as [ChatServiceAsync.complete]. */ - @MustBeClosed fun complete(model: String): CompletableFuture> = complete(model, ChatCompleteParams.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -90,7 +103,6 @@ interface ChatServiceAsync { complete(params.toBuilder().model(model).build(), requestOptions) /** @see [complete] */ - @MustBeClosed fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -98,21 +110,18 @@ interface ChatServiceAsync { complete(model, params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [complete] */ - @MustBeClosed fun complete( params: ChatCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) /** @see [complete] */ - @MustBeClosed fun complete( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt index bc82fa2a..92ebcf75 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ChatServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): ChatServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatServiceAsync = + ChatServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun complete( params: ChatCompleteParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ChatServiceAsync.WithRawResponse = + ChatServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -56,6 +67,7 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "openai", "deployments", diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt index 7df570ae..61e3617a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt @@ -2,14 +2,15 @@ package ai.hanzo.api.services.async.organization +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.organization.info.InfoDeprecatedParams import ai.hanzo.api.models.organization.info.InfoDeprecatedResponse import ai.hanzo.api.models.organization.info.InfoRetrieveParams import ai.hanzo.api.models.organization.info.InfoRetrieveResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface InfoServiceAsync { @@ -18,6 +19,13 @@ interface InfoServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoServiceAsync + /** Get the org specific information */ fun retrieve(params: InfoRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) @@ -41,18 +49,23 @@ interface InfoServiceAsync { /** A view of [InfoServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /organization/info`, but is otherwise the same as * [InfoServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( params: InfoRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: InfoRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -62,14 +75,12 @@ interface InfoServiceAsync { * Returns a raw HTTP response for `post /organization/info`, but is otherwise the same as * [InfoServiceAsync.deprecated]. */ - @MustBeClosed fun deprecated( params: InfoDeprecatedParams ): CompletableFuture> = deprecated(params, RequestOptions.none()) /** @see [deprecated] */ - @MustBeClosed fun deprecated( params: InfoDeprecatedParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt index e4339edd..392f5408 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import ai.hanzo.api.models.organization.info.InfoDeprecatedResponse import ai.hanzo.api.models.organization.info.InfoRetrieveParams import ai.hanzo.api.models.organization.info.InfoRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class InfoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InfoServiceAsync { @@ -30,6 +31,9 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): InfoServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InfoServiceAsync = + InfoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: InfoRetrieveParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InfoServiceAsync.WithRawResponse = + InfoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -60,6 +71,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "info") .build() .prepareAsync(clientOptions, params) @@ -90,6 +102,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "info") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt index 43948be3..1675ef43 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.responses +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.responses.inputitems.InputItemListParams import ai.hanzo.api.models.responses.inputitems.InputItemListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface InputItemServiceAsync { @@ -16,6 +17,13 @@ interface InputItemServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InputItemServiceAsync + /** * Get input items for a response. * @@ -65,16 +73,23 @@ interface InputItemServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InputItemServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/responses/{response_id}/input_items`, but is * otherwise the same as [InputItemServiceAsync.list]. */ - @MustBeClosed fun list(responseId: String): CompletableFuture> = list(responseId, InputItemListParams.none()) /** @see [list] */ - @MustBeClosed fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), @@ -83,7 +98,6 @@ interface InputItemServiceAsync { list(params.toBuilder().responseId(responseId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), @@ -91,21 +105,18 @@ interface InputItemServiceAsync { list(responseId, params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: InputItemListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( responseId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt index d91aaa33..0d044a35 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.responses.inputitems.InputItemListParams import ai.hanzo.api.models.responses.inputitems.InputItemListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class InputItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): InputItemServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InputItemServiceAsync = + InputItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: InputItemListParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InputItemServiceAsync.WithRawResponse = + InputItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses", params._pathParam(0), "input_items") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt index 9ba80170..0718b5ad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt @@ -2,14 +2,15 @@ package ai.hanzo.api.services.async.team +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.team.callback.CallbackAddParams import ai.hanzo.api.models.team.callback.CallbackAddResponse import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import ai.hanzo.api.models.team.callback.CallbackRetrieveResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CallbackServiceAsync { @@ -18,6 +19,13 @@ interface CallbackServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CallbackServiceAsync + /** * Get the success/failure callbacks and variables for a team * @@ -135,16 +143,23 @@ interface CallbackServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CallbackServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /team/{team_id}/callback`, but is otherwise the same * as [CallbackServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(teamId: String): CompletableFuture> = retrieve(teamId, CallbackRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), @@ -153,7 +168,6 @@ interface CallbackServiceAsync { retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), @@ -161,21 +175,18 @@ interface CallbackServiceAsync { retrieve(teamId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: CallbackRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( teamId: String, requestOptions: RequestOptions, @@ -186,7 +197,6 @@ interface CallbackServiceAsync { * Returns a raw HTTP response for `post /team/{team_id}/callback`, but is otherwise the * same as [CallbackServiceAsync.add]. */ - @MustBeClosed fun add( teamId: String, params: CallbackAddParams, @@ -194,7 +204,6 @@ interface CallbackServiceAsync { add(teamId, params, RequestOptions.none()) /** @see [add] */ - @MustBeClosed fun add( teamId: String, params: CallbackAddParams, @@ -203,14 +212,12 @@ interface CallbackServiceAsync { add(params.toBuilder().teamId(teamId).build(), requestOptions) /** @see [add] */ - @MustBeClosed fun add( params: CallbackAddParams ): CompletableFuture> = add(params, RequestOptions.none()) /** @see [add] */ - @MustBeClosed fun add( params: CallbackAddParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt index 645d5736..60df18d6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.team.callback.CallbackAddResponse import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import ai.hanzo.api.models.team.callback.CallbackRetrieveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CallbackServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,6 +33,9 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): CallbackServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CallbackServiceAsync = + CallbackServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CallbackServiceAsync.WithRawResponse = + CallbackServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -65,6 +76,7 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", params._pathParam(0), "callback") .build() .prepareAsync(clientOptions, params) @@ -98,6 +110,7 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", params._pathParam(0), "callback") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt index 5196667e..08d4ebe6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt @@ -2,14 +2,15 @@ package ai.hanzo.api.services.async.team +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.team.model.ModelAddParams import ai.hanzo.api.models.team.model.ModelAddResponse import ai.hanzo.api.models.team.model.ModelRemoveParams import ai.hanzo.api.models.team.model.ModelRemoveResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ModelServiceAsync { @@ -18,6 +19,13 @@ interface ModelServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelServiceAsync + /** * Add models to a team's allowed model list. Only proxy admin or team admin can add models. * @@ -70,16 +78,23 @@ interface ModelServiceAsync { /** A view of [ModelServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModelServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /team/model/add`, but is otherwise the same as * [ModelServiceAsync.add]. */ - @MustBeClosed fun add(params: ModelAddParams): CompletableFuture> = add(params, RequestOptions.none()) /** @see [add] */ - @MustBeClosed fun add( params: ModelAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -89,14 +104,12 @@ interface ModelServiceAsync { * Returns a raw HTTP response for `post /team/model/delete`, but is otherwise the same as * [ModelServiceAsync.remove]. */ - @MustBeClosed fun remove( params: ModelRemoveParams ): CompletableFuture> = remove(params, RequestOptions.none()) /** @see [remove] */ - @MustBeClosed fun remove( params: ModelRemoveParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt index 76929279..c11ae795 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import ai.hanzo.api.models.team.model.ModelAddResponse import ai.hanzo.api.models.team.model.ModelRemoveParams import ai.hanzo.api.models.team.model.ModelRemoveResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ModelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ModelServiceAsync { @@ -30,6 +31,9 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ModelServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelServiceAsync = + ModelServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun add( params: ModelAddParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModelServiceAsync.WithRawResponse = + ModelServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val addHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -59,6 +70,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "model", "add") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -90,6 +102,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "model", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt index f9c8a866..ce96bcce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt @@ -2,14 +2,15 @@ package ai.hanzo.api.services.async.threads +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.threads.messages.MessageCreateParams import ai.hanzo.api.models.threads.messages.MessageCreateResponse import ai.hanzo.api.models.threads.messages.MessageListParams import ai.hanzo.api.models.threads.messages.MessageListResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface MessageServiceAsync { @@ -18,6 +19,13 @@ interface MessageServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageServiceAsync + /** * Create a message. * @@ -101,16 +109,23 @@ interface MessageServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): MessageServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/threads/{thread_id}/messages`, but is otherwise * the same as [MessageServiceAsync.create]. */ - @MustBeClosed fun create(threadId: String): CompletableFuture> = create(threadId, MessageCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), @@ -119,7 +134,6 @@ interface MessageServiceAsync { create(params.toBuilder().threadId(threadId).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), @@ -127,21 +141,18 @@ interface MessageServiceAsync { create(threadId, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: MessageCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: MessageCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( threadId: String, requestOptions: RequestOptions, @@ -152,12 +163,10 @@ interface MessageServiceAsync { * Returns a raw HTTP response for `get /v1/threads/{thread_id}/messages`, but is otherwise * the same as [MessageServiceAsync.list]. */ - @MustBeClosed fun list(threadId: String): CompletableFuture> = list(threadId, MessageListParams.none()) /** @see [list] */ - @MustBeClosed fun list( threadId: String, params: MessageListParams = MessageListParams.none(), @@ -166,7 +175,6 @@ interface MessageServiceAsync { list(params.toBuilder().threadId(threadId).build(), requestOptions) /** @see [list] */ - @MustBeClosed fun list( threadId: String, params: MessageListParams = MessageListParams.none(), @@ -174,21 +182,18 @@ interface MessageServiceAsync { list(threadId, params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: MessageListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( threadId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt index 50b8a56c..abd8ac86 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.threads.messages.MessageCreateResponse import ai.hanzo.api.models.threads.messages.MessageListParams import ai.hanzo.api.models.threads.messages.MessageListResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class MessageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,6 +33,9 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): MessageServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): MessageServiceAsync = + MessageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: MessageCreateParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): MessageServiceAsync.WithRawResponse = + MessageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -65,6 +76,7 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0), "messages") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -99,6 +111,7 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0), "messages") .build() .prepareAsync(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt index aaf3ea84..d2cf549d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt @@ -2,12 +2,13 @@ package ai.hanzo.api.services.async.threads +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.threads.runs.RunCreateParams import ai.hanzo.api.models.threads.runs.RunCreateResponse -import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RunServiceAsync { @@ -16,6 +17,13 @@ interface RunServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunServiceAsync + /** * Create a run. * @@ -58,16 +66,21 @@ interface RunServiceAsync { /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/threads/{thread_id}/runs`, but is otherwise the * same as [RunServiceAsync.create]. */ - @MustBeClosed fun create(threadId: String): CompletableFuture> = create(threadId, RunCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), @@ -76,7 +89,6 @@ interface RunServiceAsync { create(params.toBuilder().threadId(threadId).build(), requestOptions) /** @see [create] */ - @MustBeClosed fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), @@ -84,19 +96,16 @@ interface RunServiceAsync { create(threadId, params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create(params: RunCreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( threadId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt index 0d1b6e4e..6edf708d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.core.prepareAsync import ai.hanzo.api.models.threads.runs.RunCreateParams import ai.hanzo.api.models.threads.runs.RunCreateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: RunCreateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0), "runs") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt index 351b8cec..1e63de16 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.active.ActiveListCallbacksParams import ai.hanzo.api.models.active.ActiveListCallbacksResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ActiveService { @@ -15,6 +17,13 @@ interface ActiveService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ActiveService + /** * Returns a list of llm level settings * @@ -59,6 +68,13 @@ interface ActiveService { /** A view of [ActiveService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ActiveService.WithRawResponse + /** * Returns a raw HTTP response for `get /active/callbacks`, but is otherwise the same as * [ActiveService.listCallbacks]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt index 33e64e0e..792b5c54 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.active.ActiveListCallbacksParams import ai.hanzo.api.models.active.ActiveListCallbacksResponse +import java.util.function.Consumer class ActiveServiceImpl internal constructor(private val clientOptions: ClientOptions) : ActiveService { @@ -26,6 +27,9 @@ class ActiveServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): ActiveService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ActiveService = + ActiveServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun listCallbacks( params: ActiveListCallbacksParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class ActiveServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ActiveService.WithRawResponse = + ActiveServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listCallbacksHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class ActiveServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("active", "callbacks") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt index 0c002390..bd3724b1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.AddAddAllowedIpResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface AddService { @@ -15,6 +17,13 @@ interface AddService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AddService + /** Add Allowed Ip */ fun addAllowedIp(params: AddAddAllowedIpParams): AddAddAllowedIpResponse = addAllowedIp(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface AddService { /** A view of [AddService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AddService.WithRawResponse + /** * Returns a raw HTTP response for `post /add/allowed_ip`, but is otherwise the same as * [AddService.addAllowedIp]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt index 56f1b0cf..1047878d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.AddAddAllowedIpResponse +import java.util.function.Consumer class AddServiceImpl internal constructor(private val clientOptions: ClientOptions) : AddService { @@ -26,6 +27,9 @@ class AddServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): AddService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AddService = + AddServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun addAllowedIp( params: AddAddAllowedIpParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class AddServiceImpl internal constructor(private val clientOptions: ClientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AddService.WithRawResponse = + AddServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val addAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class AddServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("add", "allowed_ip") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt index e728987b..0f9eee3a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.anthropic.AnthropicCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.anthropic.AnthropicRetrieveResponse import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import ai.hanzo.api.models.anthropic.AnthropicUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface AnthropicService { @@ -23,6 +25,13 @@ interface AnthropicService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AnthropicService + /** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ fun create(endpoint: String): AnthropicCreateResponse = create(endpoint, AnthropicCreateParams.none()) @@ -186,6 +195,13 @@ interface AnthropicService { /** A view of [AnthropicService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AnthropicService.WithRawResponse + /** * Returns a raw HTTP response for `post /anthropic/{endpoint}`, but is otherwise the same * as [AnthropicService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt index 8200382f..304f6a89 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.anthropic.AnthropicRetrieveParams import ai.hanzo.api.models.anthropic.AnthropicRetrieveResponse import ai.hanzo.api.models.anthropic.AnthropicUpdateParams import ai.hanzo.api.models.anthropic.AnthropicUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AnthropicServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): AnthropicService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AnthropicService = + AnthropicServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AnthropicCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AnthropicService.WithRawResponse = + AnthropicServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("anthropic", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt index b7393961..f52f194d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.assemblyai.AssemblyaiCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveResponse import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface AssemblyaiService { @@ -23,6 +25,13 @@ interface AssemblyaiService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AssemblyaiService + /** Assemblyai Proxy Route */ fun create(endpoint: String): AssemblyaiCreateResponse = create(endpoint, AssemblyaiCreateParams.none()) @@ -186,6 +195,15 @@ interface AssemblyaiService { /** A view of [AssemblyaiService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AssemblyaiService.WithRawResponse + /** * Returns a raw HTTP response for `post /assemblyai/{endpoint}`, but is otherwise the same * as [AssemblyaiService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt index 6176ea68..e1051ba3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveParams import ai.hanzo.api.models.assemblyai.AssemblyaiRetrieveResponse import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateParams import ai.hanzo.api.models.assemblyai.AssemblyaiUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AssemblyaiServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): AssemblyaiService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AssemblyaiService = + AssemblyaiServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AssemblyaiService.WithRawResponse = + AssemblyaiServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt index 582d181c..395b1780 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.assistants.AssistantCreateParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.assistants.AssistantDeleteResponse import ai.hanzo.api.models.assistants.AssistantListParams import ai.hanzo.api.models.assistants.AssistantListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface AssistantService { @@ -19,6 +21,13 @@ interface AssistantService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AssistantService + /** * Create assistant * @@ -103,6 +112,13 @@ interface AssistantService { /** A view of [AssistantService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AssistantService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/assistants`, but is otherwise the same as * [AssistantService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt index 9fb2d8dd..76ed9c7b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.assistants.AssistantDeleteParams import ai.hanzo.api.models.assistants.AssistantDeleteResponse import ai.hanzo.api.models.assistants.AssistantListParams import ai.hanzo.api.models.assistants.AssistantListResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AssistantServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -33,6 +34,9 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): AssistantService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AssistantService = + AssistantServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AssistantCreateParams, requestOptions: RequestOptions, @@ -59,6 +63,13 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AssistantService.WithRawResponse = + AssistantServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -70,6 +81,7 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "assistants") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -98,6 +110,7 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "assistants") .build() .prepare(clientOptions, params) @@ -128,6 +141,7 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "assistants", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioService.kt index be4cde3d..9dbbac2b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioService.kt @@ -2,8 +2,10 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.audio.SpeechService import ai.hanzo.api.services.blocking.audio.TranscriptionService +import java.util.function.Consumer interface AudioService { @@ -12,6 +14,13 @@ interface AudioService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudioService + fun speech(): SpeechService fun transcriptions(): TranscriptionService @@ -19,6 +28,13 @@ interface AudioService { /** A view of [AudioService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudioService.WithRawResponse + fun speech(): SpeechService.WithRawResponse fun transcriptions(): TranscriptionService.WithRawResponse diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioServiceImpl.kt index a8f04414..69317505 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AudioServiceImpl.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.services.blocking.audio.SpeechService import ai.hanzo.api.services.blocking.audio.SpeechServiceImpl import ai.hanzo.api.services.blocking.audio.TranscriptionService import ai.hanzo.api.services.blocking.audio.TranscriptionServiceImpl +import java.util.function.Consumer class AudioServiceImpl internal constructor(private val clientOptions: ClientOptions) : AudioService { @@ -23,6 +24,9 @@ class AudioServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): AudioService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AudioService = + AudioServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun speech(): SpeechService = speech override fun transcriptions(): TranscriptionService = transcriptions @@ -38,6 +42,13 @@ class AudioServiceImpl internal constructor(private val clientOptions: ClientOpt TranscriptionServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): AudioService.WithRawResponse = + AudioServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun speech(): SpeechService.WithRawResponse = speech override fun transcriptions(): TranscriptionService.WithRawResponse = transcriptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt index 3752e2e0..5e1f1568 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.azure.AzureCallParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.azure.AzurePatchResponse import ai.hanzo.api.models.azure.AzureUpdateParams import ai.hanzo.api.models.azure.AzureUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface AzureService { @@ -23,6 +25,13 @@ interface AzureService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AzureService + /** * Call any azure endpoint using the proxy. * @@ -194,6 +203,13 @@ interface AzureService { /** A view of [AzureService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AzureService.WithRawResponse + /** * Returns a raw HTTP response for `post /azure/{endpoint}`, but is otherwise the same as * [AzureService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt index 1034efc3..8436ee56 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.azure.AzurePatchParams import ai.hanzo.api.models.azure.AzurePatchResponse import ai.hanzo.api.models.azure.AzureUpdateParams import ai.hanzo.api.models.azure.AzureUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AzureServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): AzureService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AzureService = + AzureServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AzureCreateParams, requestOptions: RequestOptions, @@ -74,6 +78,13 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AzureService.WithRawResponse = + AzureServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -88,6 +99,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -119,6 +131,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -150,6 +163,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -180,6 +194,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -209,6 +224,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("azure", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt index 7f81f262..409ea3f8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.batches.BatchCancelWithProviderParams @@ -20,6 +21,7 @@ import ai.hanzo.api.models.batches.BatchRetrieveWithProviderParams import ai.hanzo.api.models.batches.BatchRetrieveWithProviderResponse import ai.hanzo.api.services.blocking.batches.CancelService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface BatchService { @@ -28,6 +30,13 @@ interface BatchService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchService + fun cancel(): CancelService /** @@ -294,6 +303,13 @@ interface BatchService { /** A view of [BatchService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchService.WithRawResponse + fun cancel(): CancelService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt index 74c5540d..3f36f888 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt @@ -32,6 +32,7 @@ import ai.hanzo.api.models.batches.BatchRetrieveWithProviderParams import ai.hanzo.api.models.batches.BatchRetrieveWithProviderResponse import ai.hanzo.api.services.blocking.batches.CancelService import ai.hanzo.api.services.blocking.batches.CancelServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -45,6 +46,9 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BatchService = + BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun cancel(): CancelService = cancel override fun create( @@ -102,6 +106,13 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt CancelServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BatchService.WithRawResponse = + BatchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun cancel(): CancelService.WithRawResponse = cancel private val createHandler: Handler = @@ -115,6 +126,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "batches") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -146,6 +158,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "batches", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -172,6 +185,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "batches") .build() .prepare(clientOptions, params) @@ -202,6 +216,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( params._pathParam(0), "v1", @@ -239,6 +254,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "batches") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -270,6 +286,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "batches") .build() .prepare(clientOptions, params) @@ -300,6 +317,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "batches", params._pathParam(1)) .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt index 835918af..6fca1e9a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.bedrock.BedrockCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.bedrock.BedrockRetrieveResponse import ai.hanzo.api.models.bedrock.BedrockUpdateParams import ai.hanzo.api.models.bedrock.BedrockUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface BedrockService { @@ -23,6 +25,13 @@ interface BedrockService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BedrockService + /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ fun create(endpoint: String): BedrockCreateResponse = create(endpoint, BedrockCreateParams.none()) @@ -181,6 +190,13 @@ interface BedrockService { /** A view of [BedrockService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BedrockService.WithRawResponse + /** * Returns a raw HTTP response for `post /bedrock/{endpoint}`, but is otherwise the same as * [BedrockService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt index 66f8820d..2afc25ba 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.bedrock.BedrockRetrieveParams import ai.hanzo.api.models.bedrock.BedrockRetrieveResponse import ai.hanzo.api.models.bedrock.BedrockUpdateParams import ai.hanzo.api.models.bedrock.BedrockUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BedrockServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): BedrockService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BedrockService = + BedrockServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: BedrockCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BedrockService.WithRawResponse = + BedrockServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("bedrock", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt index 7f0cbd71..0aeb20f8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.budget.BudgetCreateParams @@ -17,6 +18,7 @@ import ai.hanzo.api.models.budget.BudgetSettingsResponse import ai.hanzo.api.models.budget.BudgetUpdateParams import ai.hanzo.api.models.budget.BudgetUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface BudgetService { @@ -25,6 +27,13 @@ interface BudgetService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BudgetService + /** * Create a new budget object. Can apply this to teams, orgs, end-users, keys. * @@ -141,6 +150,13 @@ interface BudgetService { /** A view of [BudgetService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BudgetService.WithRawResponse + /** * Returns a raw HTTP response for `post /budget/new`, but is otherwise the same as * [BudgetService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt index 35617960..585a5570 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.budget.BudgetSettingsParams import ai.hanzo.api.models.budget.BudgetSettingsResponse import ai.hanzo.api.models.budget.BudgetUpdateParams import ai.hanzo.api.models.budget.BudgetUpdateResponse +import java.util.function.Consumer class BudgetServiceImpl internal constructor(private val clientOptions: ClientOptions) : BudgetService { @@ -37,6 +38,9 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): BudgetService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BudgetService = + BudgetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: BudgetCreateParams, requestOptions: RequestOptions, @@ -84,6 +88,13 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BudgetService.WithRawResponse = + BudgetServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -95,6 +106,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -123,6 +135,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -150,6 +163,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "list") .build() .prepare(clientOptions, params) @@ -177,6 +191,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -204,6 +219,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "info") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -232,6 +248,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("budget", "settings") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt index a7f8c211..64fdfecd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.cache.CacheDeleteParams @@ -12,6 +13,7 @@ import ai.hanzo.api.models.cache.CachePingParams import ai.hanzo.api.models.cache.CachePingResponse import ai.hanzo.api.services.blocking.cache.RediService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CacheService { @@ -20,6 +22,13 @@ interface CacheService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CacheService + fun redis(): RediService /** @@ -96,6 +105,13 @@ interface CacheService { /** A view of [CacheService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CacheService.WithRawResponse + fun redis(): RediService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt index d646fe54..b9d928ad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.models.cache.CachePingParams import ai.hanzo.api.models.cache.CachePingResponse import ai.hanzo.api.services.blocking.cache.RediService import ai.hanzo.api.services.blocking.cache.RediServiceImpl +import java.util.function.Consumer class CacheServiceImpl internal constructor(private val clientOptions: ClientOptions) : CacheService { @@ -35,6 +36,9 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): CacheService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CacheService = + CacheServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun redis(): RediService = redis override fun delete( @@ -64,6 +68,13 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt RediServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CacheService.WithRawResponse = + CacheServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun redis(): RediService.WithRawResponse = redis private val deleteHandler: Handler = @@ -77,6 +88,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "delete") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -105,6 +117,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "flushall") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -132,6 +145,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "ping") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatService.kt index 5e48d953..08b36509 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatService.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.chat.CompletionService +import java.util.function.Consumer interface ChatService { @@ -11,11 +13,25 @@ interface ChatService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService + fun completions(): CompletionService /** A view of [ChatService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService.WithRawResponse + fun completions(): CompletionService.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatServiceImpl.kt index 0a87edf6..911db136 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ChatServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.chat.CompletionService import ai.hanzo.api.services.blocking.chat.CompletionServiceImpl +import java.util.function.Consumer class ChatServiceImpl internal constructor(private val clientOptions: ClientOptions) : ChatService { @@ -16,6 +17,9 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): ChatService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatService = + ChatServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun completions(): CompletionService = completions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -25,6 +29,13 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti CompletionServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ChatService.WithRawResponse = + ChatServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun completions(): CompletionService.WithRawResponse = completions } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt index 983892db..691ddbc7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.cohere.CohereCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.cohere.CohereRetrieveResponse import ai.hanzo.api.models.cohere.CohereUpdateParams import ai.hanzo.api.models.cohere.CohereUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CohereService { @@ -23,6 +25,13 @@ interface CohereService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CohereService + /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ fun create(endpoint: String): CohereCreateResponse = create(endpoint, CohereCreateParams.none()) @@ -178,6 +187,13 @@ interface CohereService { /** A view of [CohereService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CohereService.WithRawResponse + /** * Returns a raw HTTP response for `post /cohere/{endpoint}`, but is otherwise the same as * [CohereService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt index 61d3387b..567f004f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.cohere.CohereRetrieveParams import ai.hanzo.api.models.cohere.CohereRetrieveResponse import ai.hanzo.api.models.cohere.CohereUpdateParams import ai.hanzo.api.models.cohere.CohereUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CohereServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): CohereService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CohereService = + CohereServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CohereCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CohereService.WithRawResponse = + CohereServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cohere", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt index a92e6dc1..329ece6f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.completions.CompletionCreateParams import ai.hanzo.api.models.completions.CompletionCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CompletionService { @@ -15,6 +17,13 @@ interface CompletionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompletionService + /** * Follows the exact same API spec as `OpenAI's Completions API * https://platform.openai.com/docs/api-reference/completions` @@ -51,6 +60,15 @@ interface CompletionService { /** A view of [CompletionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompletionService.WithRawResponse + /** * Returns a raw HTTP response for `post /completions`, but is otherwise the same as * [CompletionService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt index df42f0da..4542d3e9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.completions.CompletionCreateParams import ai.hanzo.api.models.completions.CompletionCreateResponse +import java.util.function.Consumer class CompletionServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompletionService { @@ -27,6 +28,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CompletionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompletionService = + CompletionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompletionService.WithRawResponse = + CompletionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigService.kt index 7a43863e..06af5ef0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigService.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.config.PassThroughEndpointService +import java.util.function.Consumer interface ConfigService { @@ -11,11 +13,25 @@ interface ConfigService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigService + fun passThroughEndpoint(): PassThroughEndpointService /** A view of [ConfigService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigService.WithRawResponse + fun passThroughEndpoint(): PassThroughEndpointService.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigServiceImpl.kt index aa850395..47ca23ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ConfigServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.config.PassThroughEndpointService import ai.hanzo.api.services.blocking.config.PassThroughEndpointServiceImpl +import java.util.function.Consumer class ConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConfigService { @@ -19,6 +20,9 @@ class ConfigServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): ConfigService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigService = + ConfigServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun passThroughEndpoint(): PassThroughEndpointService = passThroughEndpoint class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +32,13 @@ class ConfigServiceImpl internal constructor(private val clientOptions: ClientOp PassThroughEndpointServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConfigService.WithRawResponse = + ConfigServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun passThroughEndpoint(): PassThroughEndpointService.WithRawResponse = passThroughEndpoint } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt index 9971d72a..947a99ce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.credentials.CredentialCreateParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.credentials.CredentialDeleteResponse import ai.hanzo.api.models.credentials.CredentialListParams import ai.hanzo.api.models.credentials.CredentialListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CredentialService { @@ -19,6 +21,13 @@ interface CredentialService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CredentialService + /** * [BETA] endpoint. This might change unexpectedly. Stores credential in DB. Reloads credentials * in memory. @@ -84,6 +93,15 @@ interface CredentialService { /** A view of [CredentialService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CredentialService.WithRawResponse + /** * Returns a raw HTTP response for `post /credentials`, but is otherwise the same as * [CredentialService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt index 89e727f3..97d200e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.credentials.CredentialDeleteParams import ai.hanzo.api.models.credentials.CredentialDeleteResponse import ai.hanzo.api.models.credentials.CredentialListParams import ai.hanzo.api.models.credentials.CredentialListResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CredentialServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -33,6 +34,9 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CredentialService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CredentialService = + CredentialServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CredentialCreateParams, requestOptions: RequestOptions, @@ -59,6 +63,13 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CredentialService.WithRawResponse = + CredentialServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -70,6 +81,7 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("credentials") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -98,6 +110,7 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("credentials") .build() .prepare(clientOptions, params) @@ -128,6 +141,7 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("credentials", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt index 7a27a915..07c71ced 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.customer.CustomerBlockParams @@ -19,6 +20,7 @@ import ai.hanzo.api.models.customer.CustomerUnblockResponse import ai.hanzo.api.models.customer.CustomerUpdateParams import ai.hanzo.api.models.customer.CustomerUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CustomerService { @@ -27,6 +29,13 @@ interface CustomerService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CustomerService + /** * Allow creating a new Customer * @@ -230,6 +239,13 @@ interface CustomerService { /** A view of [CustomerService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CustomerService.WithRawResponse + /** * Returns a raw HTTP response for `post /customer/new`, but is otherwise the same as * [CustomerService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt index d6f3a141..fa143567 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt @@ -29,6 +29,7 @@ import ai.hanzo.api.models.customer.CustomerUnblockParams import ai.hanzo.api.models.customer.CustomerUnblockResponse import ai.hanzo.api.models.customer.CustomerUpdateParams import ai.hanzo.api.models.customer.CustomerUpdateResponse +import java.util.function.Consumer class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { @@ -39,6 +40,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): CustomerService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CustomerService = + CustomerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CustomerCreateParams, requestOptions: RequestOptions, @@ -93,6 +97,13 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CustomerService.WithRawResponse = + CustomerServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -104,6 +115,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -132,6 +144,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -160,6 +173,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "list") .build() .prepare(clientOptions, params) @@ -187,6 +201,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -215,6 +230,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "block") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -243,6 +259,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "info") .build() .prepare(clientOptions, params) @@ -270,6 +287,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("customer", "unblock") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt index 7063e359..28347298 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import ai.hanzo.api.models.delete.DeleteCreateAllowedIpResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface DeleteService { @@ -15,6 +17,13 @@ interface DeleteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeleteService + /** Delete Allowed Ip */ fun createAllowedIp(params: DeleteCreateAllowedIpParams): DeleteCreateAllowedIpResponse = createAllowedIp(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface DeleteService { /** A view of [DeleteService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeleteService.WithRawResponse + /** * Returns a raw HTTP response for `post /delete/allowed_ip`, but is otherwise the same as * [DeleteService.createAllowedIp]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt index f3730979..1e6e6655 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import ai.hanzo.api.models.delete.DeleteCreateAllowedIpResponse +import java.util.function.Consumer class DeleteServiceImpl internal constructor(private val clientOptions: ClientOptions) : DeleteService { @@ -27,6 +28,9 @@ class DeleteServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): DeleteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DeleteService = + DeleteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun createAllowedIp( params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class DeleteServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DeleteService.WithRawResponse = + DeleteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class DeleteServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("delete", "allowed_ip") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt index 84a0077d..ea8ccc9d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.embeddings.EmbeddingCreateParams import ai.hanzo.api.models.embeddings.EmbeddingCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface EmbeddingService { @@ -15,6 +17,13 @@ interface EmbeddingService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmbeddingService + /** * Follows the exact same API spec as `OpenAI's Embeddings API * https://platform.openai.com/docs/api-reference/embeddings` @@ -49,6 +58,13 @@ interface EmbeddingService { /** A view of [EmbeddingService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmbeddingService.WithRawResponse + /** * Returns a raw HTTP response for `post /embeddings`, but is otherwise the same as * [EmbeddingService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt index 8143fb14..bedce9bc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.embeddings.EmbeddingCreateParams import ai.hanzo.api.models.embeddings.EmbeddingCreateResponse +import java.util.function.Consumer class EmbeddingServiceImpl internal constructor(private val clientOptions: ClientOptions) : EmbeddingService { @@ -27,6 +28,9 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): EmbeddingService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmbeddingService = + EmbeddingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: EmbeddingCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmbeddingService.WithRawResponse = + EmbeddingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("embeddings") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt index 14c61c87..0588b494 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.engines.EngineCompleteParams @@ -10,6 +11,7 @@ import ai.hanzo.api.models.engines.EngineEmbedParams import ai.hanzo.api.models.engines.EngineEmbedResponse import ai.hanzo.api.services.blocking.engines.ChatService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface EngineService { @@ -18,6 +20,13 @@ interface EngineService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EngineService + fun chat(): ChatService /** @@ -111,6 +120,13 @@ interface EngineService { /** A view of [EngineService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EngineService.WithRawResponse + fun chat(): ChatService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt index 2c8fef26..4fcc2511 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.engines.EngineEmbedParams import ai.hanzo.api.models.engines.EngineEmbedResponse import ai.hanzo.api.services.blocking.engines.ChatService import ai.hanzo.api.services.blocking.engines.ChatServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EngineServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): EngineService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EngineService = + EngineServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun chat(): ChatService = chat override fun complete( @@ -60,6 +64,13 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp ChatServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): EngineService.WithRawResponse = + EngineServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun chat(): ChatService.WithRawResponse = chat private val completeHandler: Handler = @@ -76,6 +87,7 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("engines", params._pathParam(0), "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -107,6 +119,7 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("engines", params._pathParam(0), "embeddings") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt index 299bd46d..7789f5ce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.euassemblyai.EuAssemblyaiCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveResponse import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface EuAssemblyaiService { @@ -23,6 +25,13 @@ interface EuAssemblyaiService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EuAssemblyaiService + /** Assemblyai Proxy Route */ fun create(endpoint: String): EuAssemblyaiCreateResponse = create(endpoint, EuAssemblyaiCreateParams.none()) @@ -188,6 +197,15 @@ interface EuAssemblyaiService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EuAssemblyaiService.WithRawResponse + /** * Returns a raw HTTP response for `post /eu.assemblyai/{endpoint}`, but is otherwise the * same as [EuAssemblyaiService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt index cba8d569..d0ccbc3f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiRetrieveResponse import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateParams import ai.hanzo.api.models.euassemblyai.EuAssemblyaiUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): EuAssemblyaiService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EuAssemblyaiService = + EuAssemblyaiServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EuAssemblyaiService.WithRawResponse = + EuAssemblyaiServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("eu.assemblyai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt index d591f2bc..19666c33 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.files.FileCreateParams @@ -14,6 +15,7 @@ import ai.hanzo.api.models.files.FileRetrieveParams import ai.hanzo.api.models.files.FileRetrieveResponse import ai.hanzo.api.services.blocking.files.ContentService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface FileService { @@ -22,6 +24,13 @@ interface FileService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService + fun content(): ContentService /** @@ -163,6 +172,13 @@ interface FileService { /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FileService.WithRawResponse + fun content(): ContentService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt index ea588b1e..d32a1bfb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt @@ -27,6 +27,7 @@ import ai.hanzo.api.models.files.FileRetrieveParams import ai.hanzo.api.models.files.FileRetrieveResponse import ai.hanzo.api.services.blocking.files.ContentService import ai.hanzo.api.services.blocking.files.ContentServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { @@ -39,6 +40,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): FileService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FileService = + FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun content(): ContentService = content override fun create( @@ -75,6 +79,13 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti ContentServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FileService.WithRawResponse = + FileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun content(): ContentService.WithRawResponse = content private val createHandler: Handler = @@ -90,6 +101,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() @@ -121,6 +133,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files", params._pathParam(1)) .build() .prepare(clientOptions, params) @@ -150,6 +163,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files") .build() .prepare(clientOptions, params) @@ -179,6 +193,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments(params._pathParam(0), "v1", "files", params._pathParam(1)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningService.kt index c48607e5..ec42cec8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningService.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.finetuning.JobService +import java.util.function.Consumer interface FineTuningService { @@ -11,11 +13,27 @@ interface FineTuningService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FineTuningService + fun jobs(): JobService /** A view of [FineTuningService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): FineTuningService.WithRawResponse + fun jobs(): JobService.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningServiceImpl.kt index 0516d285..cb4e3a48 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FineTuningServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.finetuning.JobService import ai.hanzo.api.services.blocking.finetuning.JobServiceImpl +import java.util.function.Consumer class FineTuningServiceImpl internal constructor(private val clientOptions: ClientOptions) : FineTuningService { @@ -17,6 +18,9 @@ class FineTuningServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): FineTuningService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FineTuningService = + FineTuningServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun jobs(): JobService = jobs class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class FineTuningServiceImpl internal constructor(private val clientOptions: Clie JobServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FineTuningService.WithRawResponse = + FineTuningServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun jobs(): JobService.WithRawResponse = jobs } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt index 4aa122a6..80140a68 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.gemini.GeminiCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.gemini.GeminiRetrieveResponse import ai.hanzo.api.models.gemini.GeminiUpdateParams import ai.hanzo.api.models.gemini.GeminiUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface GeminiService { @@ -23,6 +25,13 @@ interface GeminiService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GeminiService + /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ fun create(endpoint: String): GeminiCreateResponse = create(endpoint, GeminiCreateParams.none()) @@ -177,6 +186,13 @@ interface GeminiService { /** A view of [GeminiService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GeminiService.WithRawResponse + /** * Returns a raw HTTP response for `post /gemini/{endpoint}`, but is otherwise the same as * [GeminiService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt index 5b3a5273..e495e100 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.gemini.GeminiRetrieveParams import ai.hanzo.api.models.gemini.GeminiRetrieveResponse import ai.hanzo.api.models.gemini.GeminiUpdateParams import ai.hanzo.api.models.gemini.GeminiUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class GeminiServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): GeminiService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GeminiService = + GeminiServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: GeminiCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GeminiService.WithRawResponse = + GeminiServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("gemini", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalService.kt index dfaaa601..c3c49859 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalService.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.global.SpendService +import java.util.function.Consumer interface GlobalService { @@ -11,11 +13,25 @@ interface GlobalService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GlobalService + fun spend(): SpendService /** A view of [GlobalService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GlobalService.WithRawResponse + fun spend(): SpendService.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalServiceImpl.kt index 51015fca..ed8ba2a6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GlobalServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.global.SpendService import ai.hanzo.api.services.blocking.global.SpendServiceImpl +import java.util.function.Consumer class GlobalServiceImpl internal constructor(private val clientOptions: ClientOptions) : GlobalService { @@ -17,6 +18,9 @@ class GlobalServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): GlobalService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GlobalService = + GlobalServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun spend(): SpendService = spend class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class GlobalServiceImpl internal constructor(private val clientOptions: ClientOp SpendServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): GlobalService.WithRawResponse = + GlobalServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun spend(): SpendService.WithRawResponse = spend } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt index 89a84a44..d654171f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.guardrails.GuardrailListParams import ai.hanzo.api.models.guardrails.GuardrailListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface GuardrailService { @@ -15,6 +17,13 @@ interface GuardrailService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GuardrailService + /** * List the guardrails that are available on the proxy server * @@ -68,6 +77,13 @@ interface GuardrailService { /** A view of [GuardrailService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GuardrailService.WithRawResponse + /** * Returns a raw HTTP response for `get /guardrails/list`, but is otherwise the same as * [GuardrailService.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt index e74d4a34..dfda49ec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.guardrails.GuardrailListParams import ai.hanzo.api.models.guardrails.GuardrailListResponse +import java.util.function.Consumer class GuardrailServiceImpl internal constructor(private val clientOptions: ClientOptions) : GuardrailService { @@ -26,6 +27,9 @@ class GuardrailServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): GuardrailService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GuardrailService = + GuardrailServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: GuardrailListParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class GuardrailServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GuardrailService.WithRawResponse = + GuardrailServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class GuardrailServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("guardrails", "list") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt index 726074f4..4442b3ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.health.HealthCheckAllParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.health.HealthCheckReadinessResponse import ai.hanzo.api.models.health.HealthCheckServicesParams import ai.hanzo.api.models.health.HealthCheckServicesResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface HealthService { @@ -23,6 +25,13 @@ interface HealthService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HealthService + /** * 🚨 USE `/health/liveliness` to health check the proxy 🚨 * @@ -133,6 +142,13 @@ interface HealthService { /** A view of [HealthService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HealthService.WithRawResponse + /** * Returns a raw HTTP response for `get /health`, but is otherwise the same as * [HealthService.checkAll]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt index b6cc9474..2a7950c2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.models.health.HealthCheckReadinessParams import ai.hanzo.api.models.health.HealthCheckReadinessResponse import ai.hanzo.api.models.health.HealthCheckServicesParams import ai.hanzo.api.models.health.HealthCheckServicesResponse +import java.util.function.Consumer class HealthServiceImpl internal constructor(private val clientOptions: ClientOptions) : HealthService { @@ -34,6 +35,9 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): HealthService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HealthService = + HealthServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun checkAll( params: HealthCheckAllParams, requestOptions: RequestOptions, @@ -74,6 +78,13 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): HealthService.WithRawResponse = + HealthServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val checkAllHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -85,6 +96,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health") .build() .prepare(clientOptions, params) @@ -112,6 +124,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "liveliness") .build() .prepare(clientOptions, params) @@ -139,6 +152,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "liveness") .build() .prepare(clientOptions, params) @@ -166,6 +180,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "readiness") .build() .prepare(clientOptions, params) @@ -193,6 +208,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("health", "services") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageService.kt index 5244b09b..f8f5e0b4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageService.kt @@ -2,7 +2,9 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.images.GenerationService +import java.util.function.Consumer interface ImageService { @@ -11,11 +13,25 @@ interface ImageService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ImageService + fun generations(): GenerationService /** A view of [ImageService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ImageService.WithRawResponse + fun generations(): GenerationService.WithRawResponse } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageServiceImpl.kt index 708eb251..75831e4a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ImageServiceImpl.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.services.blocking.images.GenerationService import ai.hanzo.api.services.blocking.images.GenerationServiceImpl +import java.util.function.Consumer class ImageServiceImpl internal constructor(private val clientOptions: ClientOptions) : ImageService { @@ -17,6 +18,9 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): ImageService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ImageService = + ImageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun generations(): GenerationService = generations class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class ImageServiceImpl internal constructor(private val clientOptions: ClientOpt GenerationServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ImageService.WithRawResponse = + ImageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun generations(): GenerationService.WithRawResponse = generations } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt index 64c5e1d1..cccd22af 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.key.GenerateKeyResponse @@ -24,6 +25,7 @@ import ai.hanzo.api.models.key.KeyUpdateResponse import ai.hanzo.api.services.blocking.key.RegenerateService import com.google.errorprone.annotations.MustBeClosed import java.util.Optional +import java.util.function.Consumer interface KeyService { @@ -32,6 +34,13 @@ interface KeyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KeyService + fun regenerate(): RegenerateService /** @@ -473,6 +482,13 @@ interface KeyService { /** A view of [KeyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KeyService.WithRawResponse + fun regenerate(): RegenerateService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt index ba1f440d..4def9ab4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt @@ -36,6 +36,7 @@ import ai.hanzo.api.models.key.KeyUpdateResponse import ai.hanzo.api.services.blocking.key.RegenerateService import ai.hanzo.api.services.blocking.key.RegenerateServiceImpl import java.util.Optional +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class KeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : KeyService { @@ -48,6 +49,9 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): KeyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): KeyService = + KeyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun regenerate(): RegenerateService = regenerate override fun update( @@ -119,6 +123,13 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio RegenerateServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): KeyService.WithRawResponse = + KeyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun regenerate(): RegenerateService.WithRawResponse = regenerate private val updateHandler: Handler = @@ -131,6 +142,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -158,6 +170,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "list") .build() .prepare(clientOptions, params) @@ -184,6 +197,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -212,6 +226,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "block") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -240,6 +255,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "health") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -268,6 +284,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "generate") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -299,6 +316,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", params._pathParam(0), "regenerate") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -327,6 +345,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "info") .build() .prepare(clientOptions, params) @@ -353,6 +372,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("key", "unblock") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt index 0de1955c..4fb0b2e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.langfuse.LangfuseCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.langfuse.LangfuseRetrieveResponse import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import ai.hanzo.api.models.langfuse.LangfuseUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface LangfuseService { @@ -23,6 +25,13 @@ interface LangfuseService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LangfuseService + /** * Call Langfuse via LLM proxy. Works with Langfuse SDK. * @@ -204,6 +213,13 @@ interface LangfuseService { /** A view of [LangfuseService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LangfuseService.WithRawResponse + /** * Returns a raw HTTP response for `post /langfuse/{endpoint}`, but is otherwise the same as * [LangfuseService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt index 5a4775b4..4e5b550b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.langfuse.LangfuseRetrieveParams import ai.hanzo.api.models.langfuse.LangfuseRetrieveResponse import ai.hanzo.api.models.langfuse.LangfuseUpdateParams import ai.hanzo.api.models.langfuse.LangfuseUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class LangfuseServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): LangfuseService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): LangfuseService = + LangfuseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: LangfuseCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): LangfuseService.WithRawResponse = + LangfuseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("langfuse", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt index a4e2a142..02532a16 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoParams import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ModelGroupService { @@ -15,6 +17,13 @@ interface ModelGroupService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelGroupService + /** * Get information about all the deployments on llm proxy, including config.yaml descriptions * (except api key and api base) @@ -174,6 +183,15 @@ interface ModelGroupService { /** A view of [ModelGroupService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModelGroupService.WithRawResponse + /** * Returns a raw HTTP response for `get /model_group/info`, but is otherwise the same as * [ModelGroupService.retrieveInfo]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt index 5b072efb..e2de0524 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoParams import ai.hanzo.api.models.modelgroup.ModelGroupRetrieveInfoResponse +import java.util.function.Consumer class ModelGroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : ModelGroupService { @@ -26,6 +27,9 @@ class ModelGroupServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ModelGroupService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelGroupService = + ModelGroupServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveInfo( params: ModelGroupRetrieveInfoParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class ModelGroupServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModelGroupService.WithRawResponse = + ModelGroupServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class ModelGroupServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model_group", "info") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt index 008597cc..7c75c065 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.model.ModelCreateParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.model.ModelDeleteResponse import ai.hanzo.api.services.blocking.model.InfoService import ai.hanzo.api.services.blocking.model.UpdateService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ModelService { @@ -19,6 +21,13 @@ interface ModelService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelService + fun info(): InfoService fun update(): UpdateService @@ -46,6 +55,13 @@ interface ModelService { /** A view of [ModelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelService.WithRawResponse + fun info(): InfoService.WithRawResponse fun update(): UpdateService.WithRawResponse diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt index 6eefd999..6338e447 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.services.blocking.model.InfoService import ai.hanzo.api.services.blocking.model.InfoServiceImpl import ai.hanzo.api.services.blocking.model.UpdateService import ai.hanzo.api.services.blocking.model.UpdateServiceImpl +import java.util.function.Consumer class ModelServiceImpl internal constructor(private val clientOptions: ClientOptions) : ModelService { @@ -37,6 +38,9 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): ModelService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelService = + ModelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun info(): InfoService = info override fun update(): UpdateService = update @@ -68,6 +72,13 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt UpdateServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ModelService.WithRawResponse = + ModelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun info(): InfoService.WithRawResponse = info override fun update(): UpdateService.WithRawResponse = update @@ -83,6 +94,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -111,6 +123,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt index ae8f2b3b..f4a6d24d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.moderations.ModerationCreateParams import ai.hanzo.api.models.moderations.ModerationCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ModerationService { @@ -15,6 +17,13 @@ interface ModerationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModerationService + /** * The moderations endpoint is a tool you can use to check whether content complies with an LLM * Providers policies. @@ -45,6 +54,15 @@ interface ModerationService { /** A view of [ModerationService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ModerationService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/moderations`, but is otherwise the same as * [ModerationService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt index ad66f1f7..71c19002 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.moderations.ModerationCreateParams import ai.hanzo.api.models.moderations.ModerationCreateResponse +import java.util.function.Consumer class ModerationServiceImpl internal constructor(private val clientOptions: ClientOptions) : ModerationService { @@ -27,6 +28,9 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ModerationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModerationService = + ModerationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: ModerationCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModerationService.WithRawResponse = + ModerationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "moderations") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt index 7ee0a553..993d0766 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.openai.OpenAICreateParams @@ -16,6 +17,7 @@ import ai.hanzo.api.models.openai.OpenAIUpdateParams import ai.hanzo.api.models.openai.OpenAIUpdateResponse import ai.hanzo.api.services.blocking.openai.DeploymentService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface OpenAIService { @@ -24,6 +26,13 @@ interface OpenAIService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OpenAIService + fun deployments(): DeploymentService /** @@ -190,6 +199,13 @@ interface OpenAIService { /** A view of [OpenAIService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OpenAIService.WithRawResponse + fun deployments(): DeploymentService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt index acd96040..922ab4ae 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt @@ -28,6 +28,7 @@ import ai.hanzo.api.models.openai.OpenAIUpdateParams import ai.hanzo.api.models.openai.OpenAIUpdateResponse import ai.hanzo.api.services.blocking.openai.DeploymentService import ai.hanzo.api.services.blocking.openai.DeploymentServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -41,6 +42,9 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): OpenAIService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OpenAIService = + OpenAIServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun deployments(): DeploymentService = deployments override fun create( @@ -87,6 +91,13 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp DeploymentServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OpenAIService.WithRawResponse = + OpenAIServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun deployments(): DeploymentService.WithRawResponse = deployments private val createHandler: Handler = @@ -103,6 +114,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -134,6 +146,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -164,6 +177,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -195,6 +209,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -226,6 +241,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt index 46046421..984cb991 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.organization.OrganizationAddMemberParams @@ -20,6 +21,7 @@ import ai.hanzo.api.models.organization.OrganizationUpdateParams import ai.hanzo.api.models.organization.OrganizationUpdateResponse import ai.hanzo.api.services.blocking.organization.InfoService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface OrganizationService { @@ -28,6 +30,13 @@ interface OrganizationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OrganizationService + fun info(): InfoService /** @@ -225,6 +234,15 @@ interface OrganizationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OrganizationService.WithRawResponse + fun info(): InfoService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt index 8f79137e..2f3ca7a6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt @@ -31,6 +31,7 @@ import ai.hanzo.api.models.organization.OrganizationUpdateParams import ai.hanzo.api.models.organization.OrganizationUpdateResponse import ai.hanzo.api.services.blocking.organization.InfoService import ai.hanzo.api.services.blocking.organization.InfoServiceImpl +import java.util.function.Consumer class OrganizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationService { @@ -43,6 +44,9 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): OrganizationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): OrganizationService = + OrganizationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun info(): InfoService = info override fun create( @@ -103,6 +107,13 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl InfoServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): OrganizationService.WithRawResponse = + OrganizationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun info(): InfoService.WithRawResponse = info private val createHandler: Handler = @@ -116,6 +127,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -144,6 +156,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -172,6 +185,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "list") .build() .prepare(clientOptions, params) @@ -199,6 +213,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -227,6 +242,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "member_add") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -255,6 +271,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "member_delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -283,6 +300,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "member_update") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt index 3a445fa8..70bb6708 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.provider.ProviderListBudgetsParams import ai.hanzo.api.models.provider.ProviderListBudgetsResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ProviderService { @@ -15,6 +17,13 @@ interface ProviderService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderService + /** * Provider Budget Routing - Get Budget, Spend Details * https://docs.hanzo.ai/docs/proxy/provider_budget_routing @@ -80,6 +89,13 @@ interface ProviderService { /** A view of [ProviderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderService.WithRawResponse + /** * Returns a raw HTTP response for `get /provider/budgets`, but is otherwise the same as * [ProviderService.listBudgets]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt index af049c40..b9aeace8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.provider.ProviderListBudgetsParams import ai.hanzo.api.models.provider.ProviderListBudgetsResponse +import java.util.function.Consumer class ProviderServiceImpl internal constructor(private val clientOptions: ClientOptions) : ProviderService { @@ -26,6 +27,9 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): ProviderService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ProviderService = + ProviderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun listBudgets( params: ProviderListBudgetsParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ProviderService.WithRawResponse = + ProviderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listBudgetsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("provider", "budgets") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt index e764c3ba..9bca8589 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.rerank.RerankCreateParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.rerank.RerankCreateV1Response import ai.hanzo.api.models.rerank.RerankCreateV2Params import ai.hanzo.api.models.rerank.RerankCreateV2Response import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface RerankService { @@ -19,6 +21,13 @@ interface RerankService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RerankService + /** Rerank */ fun create(): RerankCreateResponse = create(RerankCreateParams.none()) @@ -75,6 +84,13 @@ interface RerankService { /** A view of [RerankService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RerankService.WithRawResponse + /** * Returns a raw HTTP response for `post /rerank`, but is otherwise the same as * [RerankService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt index 76cb2ce0..f029887e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.rerank.RerankCreateV1Params import ai.hanzo.api.models.rerank.RerankCreateV1Response import ai.hanzo.api.models.rerank.RerankCreateV2Params import ai.hanzo.api.models.rerank.RerankCreateV2Response +import java.util.function.Consumer class RerankServiceImpl internal constructor(private val clientOptions: ClientOptions) : RerankService { @@ -31,6 +32,9 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): RerankService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RerankService = + RerankServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: RerankCreateParams, requestOptions: RequestOptions, @@ -57,6 +61,13 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RerankService.WithRawResponse = + RerankServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -68,6 +79,7 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("rerank") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -96,6 +108,7 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "rerank") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -124,6 +137,7 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v2", "rerank") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt index e4f3f5c9..a02c1473 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.responses.ResponseCreateParams @@ -12,6 +13,7 @@ import ai.hanzo.api.models.responses.ResponseRetrieveParams import ai.hanzo.api.models.responses.ResponseRetrieveResponse import ai.hanzo.api.services.blocking.responses.InputItemService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ResponseService { @@ -20,6 +22,13 @@ interface ResponseService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResponseService + fun inputItems(): InputItemService /** @@ -134,6 +143,13 @@ interface ResponseService { /** A view of [ResponseService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResponseService.WithRawResponse + fun inputItems(): InputItemService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt index 4c1565d1..d28e35fd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.models.responses.ResponseRetrieveParams import ai.hanzo.api.models.responses.ResponseRetrieveResponse import ai.hanzo.api.services.blocking.responses.InputItemService import ai.hanzo.api.services.blocking.responses.InputItemServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ResponseServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): ResponseService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ResponseService = + ResponseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun inputItems(): InputItemService = inputItems override fun create( @@ -69,6 +73,13 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client InputItemServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ResponseService.WithRawResponse = + ResponseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun inputItems(): InputItemService.WithRawResponse = inputItems private val createHandler: Handler = @@ -82,6 +93,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -113,6 +125,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -143,6 +156,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt index 27ae28e9..d21319b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.routes.RouteListParams import ai.hanzo.api.models.routes.RouteListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface RouteService { @@ -15,6 +17,13 @@ interface RouteService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteService + /** Get a list of available routes in the FastAPI application. */ fun list(): RouteListResponse = list(RouteListParams.none()) @@ -35,6 +44,13 @@ interface RouteService { /** A view of [RouteService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteService.WithRawResponse + /** * Returns a raw HTTP response for `get /routes`, but is otherwise the same as * [RouteService.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt index 5b2f9cfe..c05b2393 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.routes.RouteListParams import ai.hanzo.api.models.routes.RouteListResponse +import java.util.function.Consumer class RouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : RouteService { @@ -26,6 +27,9 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): RouteService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RouteService = + RouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list(params: RouteListParams, requestOptions: RequestOptions): RouteListResponse = // get /routes withRawResponse().list(params, requestOptions).parse() @@ -35,6 +39,13 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RouteService.WithRawResponse = + RouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -45,6 +56,7 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("routes") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt index 1dc13e88..ee1987ea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.settings.SettingRetrieveParams import ai.hanzo.api.models.settings.SettingRetrieveResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface SettingService { @@ -15,6 +17,13 @@ interface SettingService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SettingService + /** * Returns a list of llm level settings * @@ -58,6 +67,13 @@ interface SettingService { /** A view of [SettingService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SettingService.WithRawResponse + /** * Returns a raw HTTP response for `get /settings`, but is otherwise the same as * [SettingService.retrieve]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt index 9e1f167a..c6ff0c6f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.settings.SettingRetrieveParams import ai.hanzo.api.models.settings.SettingRetrieveResponse +import java.util.function.Consumer class SettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : SettingService { @@ -26,6 +27,9 @@ class SettingServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): SettingService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SettingService = + SettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: SettingRetrieveParams, requestOptions: RequestOptions, @@ -38,6 +42,13 @@ class SettingServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SettingService.WithRawResponse = + SettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class SettingServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("settings") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt index cf01e2ac..911be7c5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.spend.SpendCalculateSpendParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.spend.SpendListLogsResponse import ai.hanzo.api.models.spend.SpendListTagsParams import ai.hanzo.api.models.spend.SpendListTagsResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface SpendService { @@ -19,6 +21,13 @@ interface SpendService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpendService + /** * Accepts all the params of completion_cost. * @@ -164,6 +173,13 @@ interface SpendService { /** A view of [SpendService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpendService.WithRawResponse + /** * Returns a raw HTTP response for `post /spend/calculate`, but is otherwise the same as * [SpendService.calculateSpend]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt index 973f3b23..0b5fa6e7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.spend.SpendListLogsParams import ai.hanzo.api.models.spend.SpendListLogsResponse import ai.hanzo.api.models.spend.SpendListTagsParams import ai.hanzo.api.models.spend.SpendListTagsResponse +import java.util.function.Consumer class SpendServiceImpl internal constructor(private val clientOptions: ClientOptions) : SpendService { @@ -31,6 +32,9 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): SpendService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpendService = + SpendServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun calculateSpend( params: SpendCalculateSpendParams, requestOptions: RequestOptions, @@ -57,6 +61,13 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpendService.WithRawResponse = + SpendServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val calculateSpendHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -68,6 +79,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("spend", "calculate") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -96,6 +108,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("spend", "logs") .build() .prepare(clientOptions, params) @@ -123,6 +136,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("spend", "tags") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt index 99dcd4dd..44f60e51 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.team.TeamAddMemberParams @@ -31,6 +32,7 @@ import ai.hanzo.api.models.team.TeamUpdateResponse import ai.hanzo.api.services.blocking.team.CallbackService import ai.hanzo.api.services.blocking.team.ModelService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface TeamService { @@ -39,6 +41,13 @@ interface TeamService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TeamService + fun model(): ModelService fun callback(): CallbackService @@ -421,6 +430,13 @@ interface TeamService { /** A view of [TeamService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TeamService.WithRawResponse + fun model(): ModelService.WithRawResponse fun callback(): CallbackService.WithRawResponse diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt index f217ec7b..ae97643f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt @@ -44,6 +44,7 @@ import ai.hanzo.api.services.blocking.team.CallbackService import ai.hanzo.api.services.blocking.team.CallbackServiceImpl import ai.hanzo.api.services.blocking.team.ModelService import ai.hanzo.api.services.blocking.team.ModelServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class TeamServiceImpl internal constructor(private val clientOptions: ClientOptions) : TeamService { @@ -58,6 +59,9 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): TeamService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TeamService = + TeamServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun model(): ModelService = model override fun callback(): CallbackService = callback @@ -153,6 +157,13 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti CallbackServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): TeamService.WithRawResponse = + TeamServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun model(): ModelService.WithRawResponse = model override fun callback(): CallbackService.WithRawResponse = callback @@ -167,6 +178,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -194,6 +206,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -221,6 +234,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "list") .build() .prepare(clientOptions, params) @@ -247,6 +261,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -275,6 +290,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "member_add") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -302,6 +318,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "block") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -333,6 +350,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", params._pathParam(0), "disable_logging") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -361,6 +379,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "available") .build() .prepare(clientOptions, params) @@ -388,6 +407,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "member_delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -416,6 +436,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "info") .build() .prepare(clientOptions, params) @@ -443,6 +464,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "unblock") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -471,6 +493,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "member_update") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt index 39bec354..e20da335 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.test.TestPingParams import ai.hanzo.api.models.test.TestPingResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface TestService { @@ -15,6 +17,13 @@ interface TestService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TestService + /** * [DEPRECATED] use `/health/liveliness` instead. * @@ -43,6 +52,13 @@ interface TestService { /** A view of [TestService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TestService.WithRawResponse + /** * Returns a raw HTTP response for `get /test`, but is otherwise the same as * [TestService.ping]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt index 4e647377..ecde0ed1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.test.TestPingParams import ai.hanzo.api.models.test.TestPingResponse +import java.util.function.Consumer class TestServiceImpl internal constructor(private val clientOptions: ClientOptions) : TestService { @@ -25,6 +26,9 @@ class TestServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): TestService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TestService = + TestServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun ping(params: TestPingParams, requestOptions: RequestOptions): TestPingResponse = // get /test withRawResponse().ping(params, requestOptions).parse() @@ -34,6 +38,13 @@ class TestServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TestService.WithRawResponse = + TestServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val pingHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -44,6 +55,7 @@ class TestServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("test") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt index c5719534..e93300d5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.threads.ThreadCreateParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.threads.ThreadRetrieveResponse import ai.hanzo.api.services.blocking.threads.MessageService import ai.hanzo.api.services.blocking.threads.RunService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ThreadService { @@ -19,6 +21,13 @@ interface ThreadService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ThreadService + fun messages(): MessageService fun runs(): RunService @@ -83,6 +92,13 @@ interface ThreadService { /** A view of [ThreadService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ThreadService.WithRawResponse + fun messages(): MessageService.WithRawResponse fun runs(): RunService.WithRawResponse diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt index 59212ca4..c79265da 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.services.blocking.threads.MessageService import ai.hanzo.api.services.blocking.threads.MessageServiceImpl import ai.hanzo.api.services.blocking.threads.RunService import ai.hanzo.api.services.blocking.threads.RunServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ThreadServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -39,6 +40,9 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): ThreadService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ThreadService = + ThreadServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun messages(): MessageService = messages override fun runs(): RunService = runs @@ -70,6 +74,13 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp RunServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ThreadService.WithRawResponse = + ThreadServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun messages(): MessageService.WithRawResponse = messages override fun runs(): RunService.WithRawResponse = runs @@ -85,6 +96,7 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -116,6 +128,7 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0)) .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt index 57db4526..86b05648 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.user.UserCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.user.UserRetrieveInfoResponse import ai.hanzo.api.models.user.UserUpdateParams import ai.hanzo.api.models.user.UserUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface UserService { @@ -23,6 +25,13 @@ interface UserService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserService + /** * Use this to create a new INTERNAL user with a budget. Internal Users can access LLM Admin UI * to make keys, request access to models. This creates a new user and generates a new api key @@ -266,6 +275,13 @@ interface UserService { /** A view of [UserService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserService.WithRawResponse + /** * Returns a raw HTTP response for `post /user/new`, but is otherwise the same as * [UserService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt index 9b6cdd71..c324d5ff 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt @@ -25,6 +25,7 @@ import ai.hanzo.api.models.user.UserRetrieveInfoParams import ai.hanzo.api.models.user.UserRetrieveInfoResponse import ai.hanzo.api.models.user.UserUpdateParams import ai.hanzo.api.models.user.UserUpdateResponse +import java.util.function.Consumer class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { @@ -34,6 +35,9 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): UserService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UserService = + UserServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: UserCreateParams, requestOptions: RequestOptions, @@ -71,6 +75,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): UserService.WithRawResponse = + UserServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -81,6 +92,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "new") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -108,6 +120,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -135,6 +148,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "get_users") .build() .prepare(clientOptions, params) @@ -161,6 +175,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -189,6 +204,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("user", "info") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt index c525f52e..40ad3d72 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.utils.UtilGetSupportedOpenAIParamsParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.utils.UtilTokenCounterResponse import ai.hanzo.api.models.utils.UtilTransformRequestParams import ai.hanzo.api.models.utils.UtilTransformRequestResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface UtilService { @@ -19,6 +21,13 @@ interface UtilService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UtilService + /** * Returns supported openai params for a given llm model name * @@ -63,6 +72,13 @@ interface UtilService { /** A view of [UtilService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UtilService.WithRawResponse + /** * Returns a raw HTTP response for `get /utils/supported_openai_params`, but is otherwise * the same as [UtilService.getSupportedOpenAIParams]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt index 148200bb..5841e564 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.utils.UtilTokenCounterParams import ai.hanzo.api.models.utils.UtilTokenCounterResponse import ai.hanzo.api.models.utils.UtilTransformRequestParams import ai.hanzo.api.models.utils.UtilTransformRequestResponse +import java.util.function.Consumer class UtilServiceImpl internal constructor(private val clientOptions: ClientOptions) : UtilService { @@ -30,6 +31,9 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): UtilService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UtilService = + UtilServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, requestOptions: RequestOptions, @@ -56,6 +60,13 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): UtilService.WithRawResponse = + UtilServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val getSupportedOpenAIParamsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -67,6 +78,7 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("utils", "supported_openai_params") .build() .prepare(clientOptions, params) @@ -94,6 +106,7 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("utils", "token_counter") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -122,6 +135,7 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("utils", "transform_request") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt index 721c0b76..22663562 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.vertexai.VertexAiCreateParams @@ -15,6 +16,7 @@ import ai.hanzo.api.models.vertexai.VertexAiRetrieveResponse import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import ai.hanzo.api.models.vertexai.VertexAiUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface VertexAiService { @@ -23,6 +25,13 @@ interface VertexAiService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VertexAiService + /** * Call LLM proxy via Vertex AI SDK. * @@ -204,6 +213,13 @@ interface VertexAiService { /** A view of [VertexAiService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VertexAiService.WithRawResponse + /** * Returns a raw HTTP response for `post /vertex_ai/{endpoint}`, but is otherwise the same * as [VertexAiService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt index 7acf5c1b..7c4fc474 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt @@ -26,6 +26,7 @@ import ai.hanzo.api.models.vertexai.VertexAiRetrieveParams import ai.hanzo.api.models.vertexai.VertexAiRetrieveResponse import ai.hanzo.api.models.vertexai.VertexAiUpdateParams import ai.hanzo.api.models.vertexai.VertexAiUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class VertexAiServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): VertexAiService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): VertexAiService = + VertexAiServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: VertexAiCreateParams, requestOptions: RequestOptions, @@ -77,6 +81,13 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): VertexAiService.WithRawResponse = + VertexAiServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -91,6 +102,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +134,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -152,6 +165,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -183,6 +197,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -214,6 +229,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("vertex_ai", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt index f809b7a9..fdcfcd32 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.audio +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.audio.speech.SpeechCreateParams import ai.hanzo.api.models.audio.speech.SpeechCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface SpeechService { @@ -15,6 +17,13 @@ interface SpeechService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpeechService + /** * Same params as: * @@ -39,6 +48,13 @@ interface SpeechService { /** A view of [SpeechService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpeechService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/audio/speech`, but is otherwise the same as * [SpeechService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt index 7e2e3a62..bb990a33 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.audio.speech.SpeechCreateParams import ai.hanzo.api.models.audio.speech.SpeechCreateResponse +import java.util.function.Consumer class SpeechServiceImpl internal constructor(private val clientOptions: ClientOptions) : SpeechService { @@ -27,6 +28,9 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): SpeechService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpeechService = + SpeechServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SpeechCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpeechService.WithRawResponse = + SpeechServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "audio", "speech") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt index 5a589375..8972f093 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.audio +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateParams import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface TranscriptionService { @@ -15,6 +17,13 @@ interface TranscriptionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranscriptionService + /** * Same params as: * @@ -34,6 +43,15 @@ interface TranscriptionService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranscriptionService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/audio/transcriptions`, but is otherwise the * same as [TranscriptionService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt index 3f930956..b76669e7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateParams import ai.hanzo.api.models.audio.transcriptions.TranscriptionCreateResponse +import java.util.function.Consumer class TranscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : TranscriptionService { @@ -27,6 +28,9 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): TranscriptionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): TranscriptionService = + TranscriptionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): TranscriptionService.WithRawResponse = + TranscriptionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "audio", "transcriptions") .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt index 74483f2f..ce4a1fe5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.batches +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.batches.cancel.CancelCancelParams import ai.hanzo.api.models.batches.cancel.CancelCancelResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CancelService { @@ -15,6 +17,13 @@ interface CancelService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CancelService + /** * Cancel a batch. This is the equivalent of POST * https://api.openai.com/v1/batches/{batch_id}/cancel @@ -60,6 +69,13 @@ interface CancelService { /** A view of [CancelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CancelService.WithRawResponse + /** * Returns a raw HTTP response for `post /batches/{batch_id}/cancel`, but is otherwise the * same as [CancelService.cancel]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt index b01468c5..34cac9ab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.batches.cancel.CancelCancelParams import ai.hanzo.api.models.batches.cancel.CancelCancelResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CancelServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): CancelService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CancelService = + CancelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun cancel( params: CancelCancelParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CancelService.WithRawResponse = + CancelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val cancelHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("batches", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt index c37e62f8..7a530f93 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.cache +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.cache.redis.RediRetrieveInfoParams import ai.hanzo.api.models.cache.redis.RediRetrieveInfoResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface RediService { @@ -15,6 +17,13 @@ interface RediService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RediService + /** Endpoint for getting /redis/info */ fun retrieveInfo(): RediRetrieveInfoResponse = retrieveInfo(RediRetrieveInfoParams.none()) @@ -36,6 +45,13 @@ interface RediService { /** A view of [RediService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RediService.WithRawResponse + /** * Returns a raw HTTP response for `get /cache/redis/info`, but is otherwise the same as * [RediService.retrieveInfo]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt index ecaaa8cb..c0537ce0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.cache.redis.RediRetrieveInfoParams import ai.hanzo.api.models.cache.redis.RediRetrieveInfoResponse +import java.util.function.Consumer class RediServiceImpl internal constructor(private val clientOptions: ClientOptions) : RediService { @@ -25,6 +26,9 @@ class RediServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): RediService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RediService = + RediServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveInfo( params: RediRetrieveInfoParams, requestOptions: RequestOptions, @@ -37,6 +41,13 @@ class RediServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RediService.WithRawResponse = + RediServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -48,6 +59,7 @@ class RediServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("cache", "redis", "info") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt index c8f53110..bbdaf223 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.chat +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.chat.completions.CompletionCreateParams import ai.hanzo.api.models.chat.completions.CompletionCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CompletionService { @@ -15,6 +17,13 @@ interface CompletionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompletionService + /** * Follows the exact same API spec as `OpenAI's Chat API * https://platform.openai.com/docs/api-reference/chat` @@ -54,6 +63,15 @@ interface CompletionService { /** A view of [CompletionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompletionService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/chat/completions`, but is otherwise the same as * [CompletionService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt index 3d4dbd51..19fd27a3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.chat.completions.CompletionCreateParams import ai.hanzo.api.models.chat.completions.CompletionCreateResponse +import java.util.function.Consumer class CompletionServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompletionService { @@ -27,6 +28,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): CompletionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompletionService = + CompletionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompletionService.WithRawResponse = + CompletionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "chat", "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt index 0ac8654b..6a33d646 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.config +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointCreateParams @@ -12,6 +13,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointRespons import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface PassThroughEndpointService { @@ -20,6 +22,13 @@ interface PassThroughEndpointService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PassThroughEndpointService + /** Create new pass-through endpoint */ fun create(params: PassThroughEndpointCreateParams): PassThroughEndpointCreateResponse = create(params, RequestOptions.none()) @@ -107,6 +116,15 @@ interface PassThroughEndpointService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PassThroughEndpointService.WithRawResponse + /** * Returns a raw HTTP response for `post /config/pass_through_endpoint`, but is otherwise * the same as [PassThroughEndpointService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt index eea09eac..ac263f5b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt @@ -23,6 +23,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListPar import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointResponse import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PassThroughEndpointServiceImpl @@ -34,6 +35,11 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp override fun withRawResponse(): PassThroughEndpointService.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): PassThroughEndpointService = + PassThroughEndpointServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: PassThroughEndpointCreateParams, requestOptions: RequestOptions, @@ -67,6 +73,13 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PassThroughEndpointService.WithRawResponse = + PassThroughEndpointServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -78,6 +91,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -109,6 +123,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -137,6 +152,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint") .build() .prepare(clientOptions, params) @@ -164,6 +180,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("config", "pass_through_endpoint") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt index c0c66c05..21f28c1b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.engines +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.engines.chat.ChatCompleteParams import ai.hanzo.api.models.engines.chat.ChatCompleteResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ChatService { @@ -15,6 +17,13 @@ interface ChatService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService + /** * Follows the exact same API spec as `OpenAI's Chat API * https://platform.openai.com/docs/api-reference/chat` @@ -66,6 +75,13 @@ interface ChatService { /** A view of [ChatService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService.WithRawResponse + /** * Returns a raw HTTP response for `post /engines/{model}/chat/completions`, but is * otherwise the same as [ChatService.complete]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt index 01c5f53b..b38025ec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.engines.chat.ChatCompleteParams import ai.hanzo.api.models.engines.chat.ChatCompleteResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ChatServiceImpl internal constructor(private val clientOptions: ClientOptions) : ChatService { @@ -28,6 +29,9 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): ChatService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatService = + ChatServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun complete( params: ChatCompleteParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ChatService.WithRawResponse = + ChatServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("engines", params._pathParam(0), "chat", "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt index da602fa6..1467ab4b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.files +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.files.content.ContentRetrieveParams import ai.hanzo.api.models.files.content.ContentRetrieveResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ContentService { @@ -15,6 +17,13 @@ interface ContentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContentService + /** * Returns information about a specific file. that can be used across - Assistants API, Batch * API This is the equivalent of GET https://api.openai.com/v1/files/{file_id}/content @@ -52,6 +61,13 @@ interface ContentService { /** A view of [ContentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContentService.WithRawResponse + /** * Returns a raw HTTP response for `get /{provider}/v1/files/{file_id}/content`, but is * otherwise the same as [ContentService.retrieve]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt index e4bd8ebc..7ce25d87 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.files.content.ContentRetrieveParams import ai.hanzo.api.models.files.content.ContentRetrieveResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ContentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +29,9 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): ContentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ContentService = + ContentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ContentService.WithRawResponse = + ContentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( params._pathParam(0), "v1", diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt index 31b1624b..e0a2ef4c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.finetuning +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.finetuning.jobs.JobCreateParams @@ -12,6 +13,7 @@ import ai.hanzo.api.models.finetuning.jobs.JobRetrieveParams import ai.hanzo.api.models.finetuning.jobs.JobRetrieveResponse import ai.hanzo.api.services.blocking.finetuning.jobs.CancelService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface JobService { @@ -20,6 +22,13 @@ interface JobService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService + fun cancel(): CancelService /** @@ -97,6 +106,13 @@ interface JobService { /** A view of [JobService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService.WithRawResponse + fun cancel(): CancelService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt index eae05661..5f34b86e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt @@ -24,6 +24,7 @@ import ai.hanzo.api.models.finetuning.jobs.JobRetrieveParams import ai.hanzo.api.models.finetuning.jobs.JobRetrieveResponse import ai.hanzo.api.services.blocking.finetuning.jobs.CancelService import ai.hanzo.api.services.blocking.finetuning.jobs.CancelServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -36,6 +37,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun cancel(): CancelService = cancel override fun create( @@ -65,6 +69,13 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio CancelServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun cancel(): CancelService.WithRawResponse = cancel private val createHandler: Handler = @@ -77,6 +88,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -108,6 +120,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -134,6 +147,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt index dec15ec7..b78de5a4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.finetuning.jobs +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CancelService { @@ -15,6 +17,13 @@ interface CancelService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CancelService + /** * Cancel a fine-tuning job. * @@ -59,6 +68,13 @@ interface CancelService { /** A view of [CancelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CancelService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel`, * but is otherwise the same as [CancelService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt index a2432999..446a0186 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateParams import ai.hanzo.api.models.finetuning.jobs.cancel.CancelCreateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CancelServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): CancelService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CancelService = + CancelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: CancelCreateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CancelService.WithRawResponse = + CancelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "fine_tuning", "jobs", params._pathParam(0), "cancel") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt index c8541ba2..aaa5480d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.global +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.global.spend.SpendListTagsParams @@ -11,6 +12,7 @@ import ai.hanzo.api.models.global.spend.SpendResetResponse import ai.hanzo.api.models.global.spend.SpendRetrieveReportParams import ai.hanzo.api.models.global.spend.SpendRetrieveReportResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface SpendService { @@ -19,6 +21,13 @@ interface SpendService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpendService + /** * LLM Enterprise - View Spend Per Request Tag. Used by LLM UI * @@ -101,6 +110,13 @@ interface SpendService { /** A view of [SpendService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SpendService.WithRawResponse + /** * Returns a raw HTTP response for `get /global/spend/tags`, but is otherwise the same as * [SpendService.listTags]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt index 0c0b4c63..6ede6dfe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt @@ -21,6 +21,7 @@ import ai.hanzo.api.models.global.spend.SpendResetParams import ai.hanzo.api.models.global.spend.SpendResetResponse import ai.hanzo.api.models.global.spend.SpendRetrieveReportParams import ai.hanzo.api.models.global.spend.SpendRetrieveReportResponse +import java.util.function.Consumer class SpendServiceImpl internal constructor(private val clientOptions: ClientOptions) : SpendService { @@ -31,6 +32,9 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): SpendService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SpendService = + SpendServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun listTags( params: SpendListTagsParams, requestOptions: RequestOptions, @@ -57,6 +61,13 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SpendService.WithRawResponse = + SpendServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listTagsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -68,6 +79,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("global", "spend", "tags") .build() .prepare(clientOptions, params) @@ -94,6 +106,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("global", "spend", "reset") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -122,6 +135,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("global", "spend", "report") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt index a80ec7bb..32984638 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.images +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.images.generations.GenerationCreateParams import ai.hanzo.api.models.images.generations.GenerationCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface GenerationService { @@ -15,6 +17,13 @@ interface GenerationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): GenerationService + /** Image Generation */ fun create(): GenerationCreateResponse = create(GenerationCreateParams.none()) @@ -36,6 +45,15 @@ interface GenerationService { /** A view of [GenerationService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): GenerationService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/images/generations`, but is otherwise the same * as [GenerationService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt index 40638ebd..fffca83d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.images.generations.GenerationCreateParams import ai.hanzo.api.models.images.generations.GenerationCreateResponse +import java.util.function.Consumer class GenerationServiceImpl internal constructor(private val clientOptions: ClientOptions) : GenerationService { @@ -27,6 +28,9 @@ class GenerationServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): GenerationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): GenerationService = + GenerationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: GenerationCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class GenerationServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): GenerationService.WithRawResponse = + GenerationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class GenerationServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "images", "generations") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateService.kt index 44d28b9e..06e80dc9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateService.kt @@ -2,6 +2,9 @@ package ai.hanzo.api.services.blocking.key +import ai.hanzo.api.core.ClientOptions +import java.util.function.Consumer + interface RegenerateService { /** @@ -9,6 +12,23 @@ interface RegenerateService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RegenerateService + /** A view of [RegenerateService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RegenerateService.WithRawResponse + } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateServiceImpl.kt index a20d0dae..04a3f698 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/key/RegenerateServiceImpl.kt @@ -3,6 +3,7 @@ package ai.hanzo.api.services.blocking.key import ai.hanzo.api.core.ClientOptions +import java.util.function.Consumer class RegenerateServiceImpl internal constructor(private val clientOptions: ClientOptions) : RegenerateService { @@ -13,6 +14,17 @@ class RegenerateServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): RegenerateService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RegenerateService = + RegenerateServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RegenerateService.WithRawResponse + RegenerateService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): RegenerateService.WithRawResponse = + RegenerateServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt index 0a581482..6542e8c2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.model +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.model.info.InfoListParams import ai.hanzo.api.models.model.info.InfoListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface InfoService { @@ -15,6 +17,13 @@ interface InfoService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoService + /** * Provides more info about each model in /models, including config.yaml descriptions (except * api key and api base) @@ -65,6 +74,13 @@ interface InfoService { /** A view of [InfoService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoService.WithRawResponse + /** * Returns a raw HTTP response for `get /model/info`, but is otherwise the same as * [InfoService.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt index 70b7dd2e..d26a8647 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt @@ -16,6 +16,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.model.info.InfoListParams import ai.hanzo.api.models.model.info.InfoListResponse +import java.util.function.Consumer class InfoServiceImpl internal constructor(private val clientOptions: ClientOptions) : InfoService { @@ -25,6 +26,9 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): InfoService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InfoService = + InfoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list(params: InfoListParams, requestOptions: RequestOptions): InfoListResponse = // get /model/info withRawResponse().list(params, requestOptions).parse() @@ -34,6 +38,13 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InfoService.WithRawResponse = + InfoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -44,6 +55,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "info") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt index 35a030ca..5c62a43c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.model +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.model.update.UpdateFullParams @@ -9,6 +10,7 @@ import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams import ai.hanzo.api.models.model.update.UpdatePartialResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface UpdateService { @@ -17,6 +19,13 @@ interface UpdateService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UpdateService + /** Edit existing model params */ fun full(params: UpdateFullParams): UpdateFullResponse = full(params, RequestOptions.none()) @@ -63,6 +72,13 @@ interface UpdateService { /** A view of [UpdateService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UpdateService.WithRawResponse + /** * Returns a raw HTTP response for `post /model/update`, but is otherwise the same as * [UpdateService.full]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt index 7f63037e..6586928b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt @@ -20,6 +20,7 @@ import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams import ai.hanzo.api.models.model.update.UpdatePartialResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class UpdateServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): UpdateService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): UpdateService = + UpdateServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun full( params: UpdateFullParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): UpdateService.WithRawResponse = + UpdateServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val fullHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -60,6 +71,7 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", "update") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -91,6 +103,7 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("model", params._pathParam(0), "update") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt index dca21507..d8ea71e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.openai +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.openai.deployments.DeploymentCompleteParams @@ -10,6 +11,7 @@ import ai.hanzo.api.models.openai.deployments.DeploymentEmbedParams import ai.hanzo.api.models.openai.deployments.DeploymentEmbedResponse import ai.hanzo.api.services.blocking.openai.deployments.ChatService import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface DeploymentService { @@ -18,6 +20,13 @@ interface DeploymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DeploymentService + fun chat(): ChatService /** @@ -113,6 +122,15 @@ interface DeploymentService { /** A view of [DeploymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DeploymentService.WithRawResponse + fun chat(): ChatService.WithRawResponse /** diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt index ae4161c2..e322f076 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt @@ -22,6 +22,7 @@ import ai.hanzo.api.models.openai.deployments.DeploymentEmbedParams import ai.hanzo.api.models.openai.deployments.DeploymentEmbedResponse import ai.hanzo.api.services.blocking.openai.deployments.ChatService import ai.hanzo.api.services.blocking.openai.deployments.ChatServiceImpl +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class DeploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): DeploymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DeploymentService = + DeploymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun chat(): ChatService = chat override fun complete( @@ -60,6 +64,13 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie ChatServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): DeploymentService.WithRawResponse = + DeploymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun chat(): ChatService.WithRawResponse = chat private val completeHandler: Handler = @@ -76,6 +87,7 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", "deployments", params._pathParam(0), "completions") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -107,6 +119,7 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("openai", "deployments", params._pathParam(0), "embeddings") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt index f6be7bad..13b234ac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.openai.deployments +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ChatService { @@ -15,6 +17,13 @@ interface ChatService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService + /** * Follows the exact same API spec as `OpenAI's Chat API * https://platform.openai.com/docs/api-reference/chat` @@ -66,6 +75,13 @@ interface ChatService { /** A view of [ChatService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ChatService.WithRawResponse + /** * Returns a raw HTTP response for `post /openai/deployments/{model}/chat/completions`, but * is otherwise the same as [ChatService.complete]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt index 2387541b..d0f71ccb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteParams import ai.hanzo.api.models.openai.deployments.chat.ChatCompleteResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ChatServiceImpl internal constructor(private val clientOptions: ClientOptions) : ChatService { @@ -28,6 +29,9 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): ChatService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ChatService = + ChatServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun complete( params: ChatCompleteParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ChatService.WithRawResponse = + ChatServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments( "openai", "deployments", diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt index b888725d..94b63ac9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.organization +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.organization.info.InfoDeprecatedParams @@ -9,6 +10,7 @@ import ai.hanzo.api.models.organization.info.InfoDeprecatedResponse import ai.hanzo.api.models.organization.info.InfoRetrieveParams import ai.hanzo.api.models.organization.info.InfoRetrieveResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface InfoService { @@ -17,6 +19,13 @@ interface InfoService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoService + /** Get the org specific information */ fun retrieve(params: InfoRetrieveParams): InfoRetrieveResponse = retrieve(params, RequestOptions.none()) @@ -40,6 +49,13 @@ interface InfoService { /** A view of [InfoService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InfoService.WithRawResponse + /** * Returns a raw HTTP response for `get /organization/info`, but is otherwise the same as * [InfoService.retrieve]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt index e6254fc5..0cb47ed8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.models.organization.info.InfoDeprecatedParams import ai.hanzo.api.models.organization.info.InfoDeprecatedResponse import ai.hanzo.api.models.organization.info.InfoRetrieveParams import ai.hanzo.api.models.organization.info.InfoRetrieveResponse +import java.util.function.Consumer class InfoServiceImpl internal constructor(private val clientOptions: ClientOptions) : InfoService { @@ -28,6 +29,9 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): InfoService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InfoService = + InfoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: InfoRetrieveParams, requestOptions: RequestOptions, @@ -47,6 +51,13 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InfoService.WithRawResponse = + InfoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -58,6 +69,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "info") .build() .prepare(clientOptions, params) @@ -85,6 +97,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("organization", "info") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt index e737f888..83d12b99 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.responses +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.responses.inputitems.InputItemListParams import ai.hanzo.api.models.responses.inputitems.InputItemListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface InputItemService { @@ -15,6 +17,13 @@ interface InputItemService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InputItemService + /** * Get input items for a response. * @@ -59,6 +68,13 @@ interface InputItemService { /** A view of [InputItemService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InputItemService.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/responses/{response_id}/input_items`, but is * otherwise the same as [InputItemService.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt index 47eb7f7d..1052562e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt @@ -17,6 +17,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.responses.inputitems.InputItemListParams import ai.hanzo.api.models.responses.inputitems.InputItemListResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class InputItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +29,9 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): InputItemService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): InputItemService = + InputItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: InputItemListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): InputItemService.WithRawResponse = + InputItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "responses", params._pathParam(0), "input_items") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt index 6c558863..dfbbc139 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.team +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.team.callback.CallbackAddParams @@ -9,6 +10,7 @@ import ai.hanzo.api.models.team.callback.CallbackAddResponse import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import ai.hanzo.api.models.team.callback.CallbackRetrieveResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface CallbackService { @@ -17,6 +19,13 @@ interface CallbackService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CallbackService + /** * Get the success/failure callbacks and variables for a team * @@ -127,6 +136,13 @@ interface CallbackService { /** A view of [CallbackService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CallbackService.WithRawResponse + /** * Returns a raw HTTP response for `get /team/{team_id}/callback`, but is otherwise the same * as [CallbackService.retrieve]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt index e4e33bfe..4331a6b8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt @@ -20,6 +20,7 @@ import ai.hanzo.api.models.team.callback.CallbackAddParams import ai.hanzo.api.models.team.callback.CallbackAddResponse import ai.hanzo.api.models.team.callback.CallbackRetrieveParams import ai.hanzo.api.models.team.callback.CallbackRetrieveResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class CallbackServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): CallbackService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CallbackService = + CallbackServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CallbackService.WithRawResponse = + CallbackServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -64,6 +75,7 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", params._pathParam(0), "callback") .build() .prepare(clientOptions, params) @@ -94,6 +106,7 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", params._pathParam(0), "callback") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt index f4531234..d774bcba 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.team +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.team.model.ModelAddParams @@ -9,6 +10,7 @@ import ai.hanzo.api.models.team.model.ModelAddResponse import ai.hanzo.api.models.team.model.ModelRemoveParams import ai.hanzo.api.models.team.model.ModelRemoveResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface ModelService { @@ -17,6 +19,13 @@ interface ModelService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelService + /** * Add models to a team's allowed model list. Only proxy admin or team admin can add models. * @@ -68,6 +77,13 @@ interface ModelService { /** A view of [ModelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ModelService.WithRawResponse + /** * Returns a raw HTTP response for `post /team/model/add`, but is otherwise the same as * [ModelService.add]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt index 9dae2c95..1436fed1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt @@ -19,6 +19,7 @@ import ai.hanzo.api.models.team.model.ModelAddParams import ai.hanzo.api.models.team.model.ModelAddResponse import ai.hanzo.api.models.team.model.ModelRemoveParams import ai.hanzo.api.models.team.model.ModelRemoveResponse +import java.util.function.Consumer class ModelServiceImpl internal constructor(private val clientOptions: ClientOptions) : ModelService { @@ -29,6 +30,9 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): ModelService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ModelService = + ModelServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun add(params: ModelAddParams, requestOptions: RequestOptions): ModelAddResponse = // post /team/model/add withRawResponse().add(params, requestOptions).parse() @@ -45,6 +49,13 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ModelService.WithRawResponse = + ModelServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val addHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "model", "add") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -83,6 +95,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("team", "model", "delete") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt index fca14c5c..6e1c4399 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.services.blocking.threads +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.threads.messages.MessageCreateParams @@ -9,6 +10,7 @@ import ai.hanzo.api.models.threads.messages.MessageCreateResponse import ai.hanzo.api.models.threads.messages.MessageListParams import ai.hanzo.api.models.threads.messages.MessageListResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface MessageService { @@ -17,6 +19,13 @@ interface MessageService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageService + /** * Create a message. * @@ -88,6 +97,13 @@ interface MessageService { /** A view of [MessageService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/threads/{thread_id}/messages`, but is otherwise * the same as [MessageService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt index 94573bdf..a099d2fe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt @@ -20,6 +20,7 @@ import ai.hanzo.api.models.threads.messages.MessageCreateParams import ai.hanzo.api.models.threads.messages.MessageCreateResponse import ai.hanzo.api.models.threads.messages.MessageListParams import ai.hanzo.api.models.threads.messages.MessageListResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class MessageServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): MessageService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): MessageService = + MessageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: MessageCreateParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): MessageService.WithRawResponse = + MessageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -64,6 +75,7 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0), "messages") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -95,6 +107,7 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0), "messages") .build() .prepare(clientOptions, params) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt index 06a92975..ba2bcc24 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.services.blocking.threads +import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.threads.runs.RunCreateParams import ai.hanzo.api.models.threads.runs.RunCreateResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface RunService { @@ -15,6 +17,13 @@ interface RunService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunService + /** * Create a run. * @@ -51,6 +60,13 @@ interface RunService { /** A view of [RunService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RunService.WithRawResponse + /** * Returns a raw HTTP response for `post /v1/threads/{thread_id}/runs`, but is otherwise the * same as [RunService.create]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt index 7f1d1195..9a3a9939 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt @@ -18,6 +18,7 @@ import ai.hanzo.api.core.http.parseable import ai.hanzo.api.core.prepare import ai.hanzo.api.models.threads.runs.RunCreateParams import ai.hanzo.api.models.threads.runs.RunCreateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { @@ -28,6 +29,9 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: RunCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -53,6 +64,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "threads", params._pathParam(0), "runs") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ClientOptionsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ClientOptionsTest.kt new file mode 100644 index 00000000..d24148e2 --- /dev/null +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/ClientOptionsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.hanzo.api.core + +import ai.hanzo.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt index 72ebdb82..deb04eb1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt @@ -20,11 +20,13 @@ import org.junit.jupiter.params.provider.ValueSource internal class RetryingHttpClientTest { private var openResponseCount = 0 + private lateinit var baseUrl: String private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() httpClient = object : HttpClient { @@ -75,7 +77,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -97,7 +103,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -139,7 +149,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -187,6 +201,7 @@ internal class RetryingHttpClientTest { retryingClient.execute( HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(baseUrl) .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), @@ -223,7 +238,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) diff --git a/hanzo-java-example/build.gradle.kts b/hanzo-java-example/build.gradle.kts index 727f6203..e1e4a27d 100644 --- a/hanzo-java-example/build.gradle.kts +++ b/hanzo-java-example/build.gradle.kts @@ -17,5 +17,12 @@ tasks.withType().configureEach { } application { - mainClass = "ai.hanzo.api.example.Main" + // Use `./gradlew :hanzo-java-example:run` to run `Main` + // Use `./gradlew :hanzo-java-example:run -Dexample=Something` to run `SomethingExample` + mainClass = "ai.hanzo.api.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" } From 4e8ff890138cf98a46038bf5ca5484820136929a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 6 Sep 2025 13:34:02 +0000 Subject: [PATCH 34/75] chore: configure new SDK language --- .github/workflows/ci.yml | 29 ++- .github/workflows/publish-sonatype.yml | 4 +- .gitignore | 2 +- .stats.yml | 2 +- README.md | 60 ++++- build.gradle.kts | 13 ++ buildSrc/build.gradle.kts | 1 - .../src/main/kotlin/hanzo.java.gradle.kts | 94 +++++++- .../src/main/kotlin/hanzo.kotlin.gradle.kts | 82 ++++++- gradle.properties | 7 +- .../api/client/okhttp/HanzoOkHttpClient.kt | 186 +++++++++++++--- .../client/okhttp/HanzoOkHttpClientAsync.kt | 186 +++++++++++++--- .../hanzo/api/client/okhttp/OkHttpClient.kt | 31 +++ .../kotlin/ai/hanzo/api/client/HanzoClient.kt | 12 +- .../ai/hanzo/api/client/HanzoClientAsync.kt | 12 +- .../hanzo/api/client/HanzoClientAsyncImpl.kt | 12 +- .../ai/hanzo/api/client/HanzoClientImpl.kt | 12 +- .../kotlin/ai/hanzo/api/core/ClientOptions.kt | 183 +++++++++++++++- .../core/PhantomReachableExecutorService.kt | 58 +++++ .../main/kotlin/ai/hanzo/api/core/Timeout.kt | 8 +- .../main/kotlin/ai/hanzo/api/core/Utils.kt | 23 ++ .../hanzo/api/core/handlers/ErrorHandler.kt | 26 +-- .../kotlin/ai/hanzo/api/core/http/Headers.kt | 41 +++- .../ai/hanzo/api/core/http/QueryParams.kt | 41 ++++ .../hanzo/api/core/http/RetryingHttpClient.kt | 8 +- .../api/errors/HanzoRetryableException.kt | 14 ++ .../hanzo/api/models/ClientGetHomeParams.kt | 8 +- .../hanzo/api/models/ClientGetHomeResponse.kt | 4 +- .../active/ActiveListCallbacksParams.kt | 8 +- .../active/ActiveListCallbacksResponse.kt | 5 +- .../api/models/add/AddAddAllowedIpParams.kt | 9 +- .../api/models/add/AddAddAllowedIpResponse.kt | 5 +- .../ai/hanzo/api/models/add/IpAddress.kt | 6 +- .../models/anthropic/AnthropicCreateParams.kt | 12 +- .../anthropic/AnthropicCreateResponse.kt | 5 +- .../models/anthropic/AnthropicDeleteParams.kt | 12 +- .../anthropic/AnthropicDeleteResponse.kt | 5 +- .../models/anthropic/AnthropicModifyParams.kt | 12 +- .../anthropic/AnthropicModifyResponse.kt | 5 +- .../anthropic/AnthropicRetrieveParams.kt | 9 +- .../anthropic/AnthropicRetrieveResponse.kt | 5 +- .../models/anthropic/AnthropicUpdateParams.kt | 12 +- .../anthropic/AnthropicUpdateResponse.kt | 5 +- .../assemblyai/AssemblyaiCreateParams.kt | 12 +- .../assemblyai/AssemblyaiCreateResponse.kt | 5 +- .../assemblyai/AssemblyaiDeleteParams.kt | 12 +- .../assemblyai/AssemblyaiDeleteResponse.kt | 5 +- .../assemblyai/AssemblyaiPatchParams.kt | 12 +- .../assemblyai/AssemblyaiPatchResponse.kt | 5 +- .../assemblyai/AssemblyaiRetrieveParams.kt | 9 +- .../assemblyai/AssemblyaiRetrieveResponse.kt | 5 +- .../assemblyai/AssemblyaiUpdateParams.kt | 12 +- .../assemblyai/AssemblyaiUpdateResponse.kt | 5 +- .../assistants/AssistantCreateParams.kt | 11 +- .../assistants/AssistantCreateResponse.kt | 5 +- .../assistants/AssistantDeleteParams.kt | 17 +- .../assistants/AssistantDeleteResponse.kt | 5 +- .../models/assistants/AssistantListParams.kt | 8 +- .../assistants/AssistantListResponse.kt | 4 +- .../models/audio/speech/SpeechCreateParams.kt | 11 +- .../audio/speech/SpeechCreateResponse.kt | 4 +- .../TranscriptionCreateParams.kt | 102 +++++++-- .../TranscriptionCreateResponse.kt | 5 +- .../hanzo/api/models/azure/AzureCallParams.kt | 9 +- .../api/models/azure/AzureCallResponse.kt | 4 +- .../api/models/azure/AzureCreateParams.kt | 12 +- .../api/models/azure/AzureCreateResponse.kt | 4 +- .../api/models/azure/AzureDeleteParams.kt | 12 +- .../api/models/azure/AzureDeleteResponse.kt | 4 +- .../api/models/azure/AzurePatchParams.kt | 12 +- .../api/models/azure/AzurePatchResponse.kt | 4 +- .../api/models/azure/AzureUpdateParams.kt | 12 +- .../api/models/azure/AzureUpdateResponse.kt | 4 +- .../batches/BatchCancelWithProviderParams.kt | 19 +- .../BatchCancelWithProviderResponse.kt | 5 +- .../api/models/batches/BatchCreateParams.kt | 12 +- .../api/models/batches/BatchCreateResponse.kt | 4 +- .../batches/BatchCreateWithProviderParams.kt | 12 +- .../BatchCreateWithProviderResponse.kt | 5 +- .../api/models/batches/BatchListParams.kt | 12 +- .../api/models/batches/BatchListResponse.kt | 4 +- .../batches/BatchListWithProviderParams.kt | 12 +- .../batches/BatchListWithProviderResponse.kt | 5 +- .../api/models/batches/BatchRetrieveParams.kt | 11 +- .../models/batches/BatchRetrieveResponse.kt | 4 +- .../BatchRetrieveWithProviderParams.kt | 11 +- .../BatchRetrieveWithProviderResponse.kt | 5 +- .../batches/cancel/CancelCancelParams.kt | 19 +- .../batches/cancel/CancelCancelResponse.kt | 4 +- .../api/models/bedrock/BedrockCreateParams.kt | 12 +- .../models/bedrock/BedrockCreateResponse.kt | 4 +- .../api/models/bedrock/BedrockDeleteParams.kt | 12 +- .../models/bedrock/BedrockDeleteResponse.kt | 4 +- .../api/models/bedrock/BedrockPatchParams.kt | 12 +- .../models/bedrock/BedrockPatchResponse.kt | 4 +- .../models/bedrock/BedrockRetrieveParams.kt | 9 +- .../models/bedrock/BedrockRetrieveResponse.kt | 5 +- .../api/models/bedrock/BedrockUpdateParams.kt | 12 +- .../models/bedrock/BedrockUpdateResponse.kt | 4 +- .../api/models/budget/BudgetCreateParams.kt | 9 +- .../api/models/budget/BudgetCreateResponse.kt | 4 +- .../api/models/budget/BudgetDeleteParams.kt | 15 +- .../api/models/budget/BudgetDeleteResponse.kt | 4 +- .../api/models/budget/BudgetInfoParams.kt | 15 +- .../api/models/budget/BudgetInfoResponse.kt | 4 +- .../api/models/budget/BudgetListParams.kt | 8 +- .../api/models/budget/BudgetListResponse.kt | 4 +- .../ai/hanzo/api/models/budget/BudgetNew.kt | 31 ++- .../api/models/budget/BudgetSettingsParams.kt | 9 +- .../models/budget/BudgetSettingsResponse.kt | 4 +- .../api/models/budget/BudgetUpdateParams.kt | 9 +- .../api/models/budget/BudgetUpdateResponse.kt | 4 +- .../api/models/cache/CacheDeleteParams.kt | 11 +- .../api/models/cache/CacheDeleteResponse.kt | 4 +- .../api/models/cache/CacheFlushAllParams.kt | 11 +- .../api/models/cache/CacheFlushAllResponse.kt | 4 +- .../hanzo/api/models/cache/CachePingParams.kt | 8 +- .../api/models/cache/CachePingResponse.kt | 23 +- .../cache/redis/RediRetrieveInfoParams.kt | 8 +- .../cache/redis/RediRetrieveInfoResponse.kt | 5 +- .../completions/CompletionCreateParams.kt | 12 +- .../completions/CompletionCreateResponse.kt | 5 +- .../api/models/cohere/CohereCreateParams.kt | 12 +- .../api/models/cohere/CohereCreateResponse.kt | 4 +- .../api/models/cohere/CohereDeleteParams.kt | 12 +- .../api/models/cohere/CohereDeleteResponse.kt | 4 +- .../api/models/cohere/CohereModifyParams.kt | 12 +- .../api/models/cohere/CohereModifyResponse.kt | 4 +- .../api/models/cohere/CohereRetrieveParams.kt | 9 +- .../models/cohere/CohereRetrieveResponse.kt | 4 +- .../api/models/cohere/CohereUpdateParams.kt | 12 +- .../api/models/cohere/CohereUpdateResponse.kt | 4 +- .../completions/CompletionCreateParams.kt | 12 +- .../completions/CompletionCreateResponse.kt | 5 +- .../PassThroughEndpointCreateParams.kt | 10 +- .../PassThroughEndpointCreateResponse.kt | 5 +- .../PassThroughEndpointDeleteParams.kt | 12 +- .../PassThroughEndpointListParams.kt | 10 +- .../PassThroughEndpointResponse.kt | 6 +- .../PassThroughEndpointUpdateParams.kt | 12 +- .../PassThroughEndpointUpdateResponse.kt | 5 +- .../PassThroughGenericEndpoint.kt | 8 +- .../credentials/CredentialCreateParams.kt | 30 ++- .../credentials/CredentialCreateResponse.kt | 5 +- .../credentials/CredentialDeleteParams.kt | 17 +- .../credentials/CredentialDeleteResponse.kt | 5 +- .../api/models/credentials/CredentialItem.kt | 12 +- .../credentials/CredentialListParams.kt | 8 +- .../credentials/CredentialListResponse.kt | 4 +- .../hanzo/api/models/customer/BlockUsers.kt | 6 +- .../models/customer/CustomerBlockParams.kt | 10 +- .../models/customer/CustomerBlockResponse.kt | 4 +- .../models/customer/CustomerCreateParams.kt | 52 ++++- .../models/customer/CustomerCreateResponse.kt | 4 +- .../models/customer/CustomerDeleteParams.kt | 15 +- .../models/customer/CustomerDeleteResponse.kt | 4 +- .../api/models/customer/CustomerListParams.kt | 8 +- .../models/customer/CustomerListResponse.kt | 52 ++++- .../customer/CustomerRetrieveInfoParams.kt | 9 +- .../customer/CustomerRetrieveInfoResponse.kt | 52 ++++- .../models/customer/CustomerUnblockParams.kt | 10 +- .../customer/CustomerUnblockResponse.kt | 5 +- .../models/customer/CustomerUpdateParams.kt | 38 +++- .../models/customer/CustomerUpdateResponse.kt | 4 +- .../delete/DeleteCreateAllowedIpParams.kt | 9 +- .../delete/DeleteCreateAllowedIpResponse.kt | 5 +- .../embeddings/EmbeddingCreateParams.kt | 12 +- .../embeddings/EmbeddingCreateResponse.kt | 5 +- .../models/engines/EngineCompleteParams.kt | 12 +- .../models/engines/EngineCompleteResponse.kt | 4 +- .../api/models/engines/EngineEmbedParams.kt | 12 +- .../api/models/engines/EngineEmbedResponse.kt | 4 +- .../models/engines/chat/ChatCompleteParams.kt | 12 +- .../engines/chat/ChatCompleteResponse.kt | 4 +- .../euassemblyai/EuAssemblyaiCreateParams.kt | 12 +- .../EuAssemblyaiCreateResponse.kt | 5 +- .../euassemblyai/EuAssemblyaiDeleteParams.kt | 12 +- .../EuAssemblyaiDeleteResponse.kt | 5 +- .../euassemblyai/EuAssemblyaiPatchParams.kt | 12 +- .../euassemblyai/EuAssemblyaiPatchResponse.kt | 5 +- .../EuAssemblyaiRetrieveParams.kt | 9 +- .../EuAssemblyaiRetrieveResponse.kt | 5 +- .../euassemblyai/EuAssemblyaiUpdateParams.kt | 12 +- .../EuAssemblyaiUpdateResponse.kt | 5 +- .../api/models/files/FileCreateParams.kt | 95 ++++++-- .../api/models/files/FileCreateResponse.kt | 4 +- .../api/models/files/FileDeleteParams.kt | 19 +- .../api/models/files/FileDeleteResponse.kt | 4 +- .../hanzo/api/models/files/FileListParams.kt | 11 +- .../api/models/files/FileListResponse.kt | 4 +- .../api/models/files/FileRetrieveParams.kt | 11 +- .../api/models/files/FileRetrieveResponse.kt | 4 +- .../files/content/ContentRetrieveParams.kt | 11 +- .../files/content/ContentRetrieveResponse.kt | 5 +- .../models/finetuning/jobs/JobCreateParams.kt | 64 ++++-- .../finetuning/jobs/JobCreateResponse.kt | 4 +- .../models/finetuning/jobs/JobListParams.kt | 14 +- .../models/finetuning/jobs/JobListResponse.kt | 4 +- .../finetuning/jobs/JobRetrieveParams.kt | 13 +- .../finetuning/jobs/JobRetrieveResponse.kt | 4 +- .../jobs/cancel/CancelCreateParams.kt | 17 +- .../jobs/cancel/CancelCreateResponse.kt | 4 +- .../api/models/gemini/GeminiCreateParams.kt | 12 +- .../api/models/gemini/GeminiCreateResponse.kt | 4 +- .../api/models/gemini/GeminiDeleteParams.kt | 12 +- .../api/models/gemini/GeminiDeleteResponse.kt | 4 +- .../api/models/gemini/GeminiPatchParams.kt | 12 +- .../api/models/gemini/GeminiPatchResponse.kt | 4 +- .../api/models/gemini/GeminiRetrieveParams.kt | 9 +- .../models/gemini/GeminiRetrieveResponse.kt | 4 +- .../api/models/gemini/GeminiUpdateParams.kt | 12 +- .../api/models/gemini/GeminiUpdateResponse.kt | 4 +- .../global/spend/SpendListTagsParams.kt | 12 +- .../global/spend/SpendListTagsResponse.kt | 78 +++++-- .../models/global/spend/SpendResetParams.kt | 11 +- .../models/global/spend/SpendResetResponse.kt | 4 +- .../global/spend/SpendRetrieveReportParams.kt | 28 ++- .../spend/SpendRetrieveReportResponse.kt | 78 +++++-- .../models/guardrails/GuardrailListParams.kt | 8 +- .../guardrails/GuardrailListResponse.kt | 37 ++-- .../api/models/health/HealthCheckAllParams.kt | 9 +- .../models/health/HealthCheckAllResponse.kt | 4 +- .../health/HealthCheckLivelinessParams.kt | 8 +- .../health/HealthCheckLivelinessResponse.kt | 5 +- .../health/HealthCheckLivenessParams.kt | 8 +- .../health/HealthCheckLivenessResponse.kt | 5 +- .../health/HealthCheckReadinessParams.kt | 8 +- .../health/HealthCheckReadinessResponse.kt | 5 +- .../health/HealthCheckServicesParams.kt | 11 +- .../health/HealthCheckServicesResponse.kt | 5 +- .../generations/GenerationCreateParams.kt | 11 +- .../generations/GenerationCreateResponse.kt | 5 +- .../hanzo/api/models/key/BlockKeyRequest.kt | 6 +- .../api/models/key/GenerateKeyResponse.kt | 75 ++++++- .../ai/hanzo/api/models/key/KeyBlockParams.kt | 11 +- .../hanzo/api/models/key/KeyBlockResponse.kt | 75 ++++++- .../api/models/key/KeyCheckHealthParams.kt | 11 +- .../api/models/key/KeyCheckHealthResponse.kt | 23 +- .../hanzo/api/models/key/KeyDeleteParams.kt | 18 +- .../hanzo/api/models/key/KeyDeleteResponse.kt | 4 +- .../hanzo/api/models/key/KeyGenerateParams.kt | 76 ++++++- .../ai/hanzo/api/models/key/KeyListParams.kt | 28 ++- .../hanzo/api/models/key/KeyListResponse.kt | 158 ++++++++++++-- .../models/key/KeyRegenerateByKeyParams.kt | 18 +- .../api/models/key/KeyRetrieveInfoParams.kt | 9 +- .../api/models/key/KeyRetrieveInfoResponse.kt | 5 +- .../hanzo/api/models/key/KeyUnblockParams.kt | 11 +- .../api/models/key/KeyUnblockResponse.kt | 4 +- .../hanzo/api/models/key/KeyUpdateParams.kt | 76 ++++++- .../hanzo/api/models/key/KeyUpdateResponse.kt | 4 +- .../key/regenerate/RegenerateKeyRequest.kt | 67 +++++- .../models/langfuse/LangfuseCreateParams.kt | 12 +- .../models/langfuse/LangfuseCreateResponse.kt | 4 +- .../models/langfuse/LangfuseDeleteParams.kt | 12 +- .../models/langfuse/LangfuseDeleteResponse.kt | 4 +- .../models/langfuse/LangfusePatchParams.kt | 12 +- .../models/langfuse/LangfusePatchResponse.kt | 4 +- .../models/langfuse/LangfuseRetrieveParams.kt | 9 +- .../langfuse/LangfuseRetrieveResponse.kt | 5 +- .../models/langfuse/LangfuseUpdateParams.kt | 12 +- .../models/langfuse/LangfuseUpdateResponse.kt | 4 +- .../ConfigurableClientsideParamsCustomAuth.kt | 6 +- .../api/models/model/ModelCreateParams.kt | 114 ++++++++-- .../api/models/model/ModelCreateResponse.kt | 4 +- .../api/models/model/ModelDeleteParams.kt | 15 +- .../api/models/model/ModelDeleteResponse.kt | 4 +- .../ai/hanzo/api/models/model/ModelInfo.kt | 33 ++- .../api/models/model/info/InfoListParams.kt | 10 +- .../api/models/model/info/InfoListResponse.kt | 4 +- .../models/model/update/UpdateDeployment.kt | 105 +++++++-- .../models/model/update/UpdateFullParams.kt | 10 +- .../models/model/update/UpdateFullResponse.kt | 4 +- .../model/update/UpdatePartialParams.kt | 11 +- .../model/update/UpdatePartialResponse.kt | 4 +- .../ModelGroupRetrieveInfoParams.kt | 10 +- .../ModelGroupRetrieveInfoResponse.kt | 5 +- .../api/models/models/ModelListParams.kt | 11 +- .../api/models/models/ModelListResponse.kt | 4 +- .../moderations/ModerationCreateParams.kt | 11 +- .../moderations/ModerationCreateResponse.kt | 5 +- .../api/models/openai/OpenAICreateParams.kt | 12 +- .../api/models/openai/OpenAICreateResponse.kt | 4 +- .../api/models/openai/OpenAIDeleteParams.kt | 12 +- .../api/models/openai/OpenAIDeleteResponse.kt | 4 +- .../api/models/openai/OpenAIPatchParams.kt | 12 +- .../api/models/openai/OpenAIPatchResponse.kt | 4 +- .../api/models/openai/OpenAIRetrieveParams.kt | 9 +- .../models/openai/OpenAIRetrieveResponse.kt | 4 +- .../api/models/openai/OpenAIUpdateParams.kt | 12 +- .../api/models/openai/OpenAIUpdateResponse.kt | 4 +- .../deployments/DeploymentCompleteParams.kt | 12 +- .../deployments/DeploymentCompleteResponse.kt | 5 +- .../deployments/DeploymentEmbedParams.kt | 12 +- .../deployments/DeploymentEmbedResponse.kt | 5 +- .../deployments/chat/ChatCompleteParams.kt | 12 +- .../deployments/chat/ChatCompleteResponse.kt | 4 +- .../api/models/organization/OrgMember.kt | 14 +- .../OrganizationAddMemberParams.kt | 29 ++- .../OrganizationAddMemberResponse.kt | 168 ++++++++++++-- .../organization/OrganizationCreateParams.kt | 44 +++- .../OrganizationCreateResponse.kt | 31 ++- .../OrganizationDeleteMemberParams.kt | 21 +- .../OrganizationDeleteMemberResponse.kt | 5 +- .../organization/OrganizationDeleteParams.kt | 15 +- .../OrganizationDeleteResponse.kt | 183 +++++++++++++--- .../organization/OrganizationListParams.kt | 8 +- .../organization/OrganizationListResponse.kt | 183 +++++++++++++--- .../OrganizationUpdateMemberParams.kt | 34 ++- .../OrganizationUpdateMemberResponse.kt | 54 ++++- .../organization/OrganizationUpdateParams.kt | 36 ++- .../OrganizationUpdateResponse.kt | 183 +++++++++++++--- .../organization/info/InfoDeprecatedParams.kt | 15 +- .../info/InfoDeprecatedResponse.kt | 4 +- .../organization/info/InfoRetrieveParams.kt | 10 +- .../organization/info/InfoRetrieveResponse.kt | 183 +++++++++++++--- .../provider/ProviderListBudgetsParams.kt | 8 +- .../provider/ProviderListBudgetsResponse.kt | 10 +- .../api/models/rerank/RerankCreateParams.kt | 11 +- .../api/models/rerank/RerankCreateResponse.kt | 4 +- .../api/models/rerank/RerankCreateV1Params.kt | 11 +- .../models/rerank/RerankCreateV1Response.kt | 4 +- .../api/models/rerank/RerankCreateV2Params.kt | 11 +- .../models/rerank/RerankCreateV2Response.kt | 4 +- .../models/responses/ResponseCreateParams.kt | 11 +- .../responses/ResponseCreateResponse.kt | 4 +- .../models/responses/ResponseDeleteParams.kt | 12 +- .../responses/ResponseDeleteResponse.kt | 4 +- .../responses/ResponseRetrieveParams.kt | 10 +- .../responses/ResponseRetrieveResponse.kt | 5 +- .../inputitems/InputItemListParams.kt | 10 +- .../inputitems/InputItemListResponse.kt | 4 +- .../api/models/routes/RouteListParams.kt | 8 +- .../api/models/routes/RouteListResponse.kt | 4 +- .../models/settings/SettingRetrieveParams.kt | 8 +- .../settings/SettingRetrieveResponse.kt | 5 +- .../models/spend/SpendCalculateSpendParams.kt | 21 +- .../spend/SpendCalculateSpendResponse.kt | 5 +- .../api/models/spend/SpendListLogsParams.kt | 22 +- .../api/models/spend/SpendListLogsResponse.kt | 78 +++++-- .../api/models/spend/SpendListTagsParams.kt | 11 +- .../api/models/spend/SpendListTagsResponse.kt | 78 +++++-- .../hanzo/api/models/team/BlockTeamRequest.kt | 6 +- .../kotlin/ai/hanzo/api/models/team/Member.kt | 14 +- .../api/models/team/TeamAddMemberParams.kt | 29 ++- .../api/models/team/TeamAddMemberResponse.kt | 206 +++++++++++++++--- .../hanzo/api/models/team/TeamBlockParams.kt | 10 +- .../api/models/team/TeamBlockResponse.kt | 4 +- .../hanzo/api/models/team/TeamCreateParams.kt | 54 ++++- .../api/models/team/TeamCreateResponse.kt | 67 +++++- .../hanzo/api/models/team/TeamDeleteParams.kt | 17 +- .../api/models/team/TeamDeleteResponse.kt | 4 +- .../models/team/TeamDisableLoggingParams.kt | 12 +- .../models/team/TeamDisableLoggingResponse.kt | 5 +- .../models/team/TeamListAvailableParams.kt | 10 +- .../models/team/TeamListAvailableResponse.kt | 5 +- .../hanzo/api/models/team/TeamListParams.kt | 11 +- .../hanzo/api/models/team/TeamListResponse.kt | 4 +- .../api/models/team/TeamRemoveMemberParams.kt | 21 +- .../models/team/TeamRemoveMemberResponse.kt | 5 +- .../api/models/team/TeamRetrieveInfoParams.kt | 9 +- .../models/team/TeamRetrieveInfoResponse.kt | 5 +- .../api/models/team/TeamUnblockParams.kt | 10 +- .../api/models/team/TeamUnblockResponse.kt | 4 +- .../api/models/team/TeamUpdateMemberParams.kt | 25 ++- .../models/team/TeamUpdateMemberResponse.kt | 13 +- .../hanzo/api/models/team/TeamUpdateParams.kt | 48 +++- .../api/models/team/TeamUpdateResponse.kt | 4 +- .../models/team/callback/CallbackAddParams.kt | 30 ++- .../team/callback/CallbackAddResponse.kt | 4 +- .../team/callback/CallbackRetrieveParams.kt | 9 +- .../team/callback/CallbackRetrieveResponse.kt | 5 +- .../api/models/team/model/ModelAddParams.kt | 16 +- .../api/models/team/model/ModelAddResponse.kt | 4 +- .../models/team/model/ModelRemoveParams.kt | 16 +- .../models/team/model/ModelRemoveResponse.kt | 4 +- .../hanzo/api/models/test/TestPingParams.kt | 8 +- .../hanzo/api/models/test/TestPingResponse.kt | 4 +- .../api/models/threads/ThreadCreateParams.kt | 11 +- .../models/threads/ThreadCreateResponse.kt | 4 +- .../models/threads/ThreadRetrieveParams.kt | 9 +- .../models/threads/ThreadRetrieveResponse.kt | 4 +- .../threads/messages/MessageCreateParams.kt | 12 +- .../threads/messages/MessageCreateResponse.kt | 4 +- .../threads/messages/MessageListParams.kt | 9 +- .../threads/messages/MessageListResponse.kt | 4 +- .../models/threads/runs/RunCreateParams.kt | 12 +- .../models/threads/runs/RunCreateResponse.kt | 4 +- .../hanzo/api/models/user/UserCreateParams.kt | 76 ++++++- .../api/models/user/UserCreateResponse.kt | 85 +++++++- .../hanzo/api/models/user/UserDeleteParams.kt | 17 +- .../api/models/user/UserDeleteResponse.kt | 4 +- .../hanzo/api/models/user/UserListParams.kt | 13 +- .../hanzo/api/models/user/UserListResponse.kt | 4 +- .../api/models/user/UserRetrieveInfoParams.kt | 9 +- .../models/user/UserRetrieveInfoResponse.kt | 5 +- .../hanzo/api/models/user/UserUpdateParams.kt | 70 +++++- .../api/models/user/UserUpdateResponse.kt | 4 +- .../UtilGetSupportedOpenAIParamsParams.kt | 9 +- .../UtilGetSupportedOpenAIParamsResponse.kt | 5 +- .../models/utils/UtilTokenCounterParams.kt | 21 +- .../models/utils/UtilTokenCounterResponse.kt | 13 +- .../utils/UtilTransformRequestParams.kt | 22 +- .../utils/UtilTransformRequestResponse.kt | 19 +- .../models/vertexai/VertexAiCreateParams.kt | 12 +- .../models/vertexai/VertexAiCreateResponse.kt | 4 +- .../models/vertexai/VertexAiDeleteParams.kt | 12 +- .../models/vertexai/VertexAiDeleteResponse.kt | 4 +- .../models/vertexai/VertexAiPatchParams.kt | 12 +- .../models/vertexai/VertexAiPatchResponse.kt | 4 +- .../models/vertexai/VertexAiRetrieveParams.kt | 9 +- .../vertexai/VertexAiRetrieveResponse.kt | 5 +- .../models/vertexai/VertexAiUpdateParams.kt | 12 +- .../models/vertexai/VertexAiUpdateResponse.kt | 4 +- .../api/services/async/ActiveServiceAsync.kt | 12 +- .../services/async/ActiveServiceAsyncImpl.kt | 10 +- .../api/services/async/AddServiceAsync.kt | 4 +- .../api/services/async/AddServiceAsyncImpl.kt | 10 +- .../services/async/AnthropicServiceAsync.kt | 100 ++++----- .../async/AnthropicServiceAsyncImpl.kt | 22 +- .../services/async/AssemblyaiServiceAsync.kt | 100 ++++----- .../async/AssemblyaiServiceAsyncImpl.kt | 22 +- .../services/async/AssistantServiceAsync.kt | 44 ++-- .../async/AssistantServiceAsyncImpl.kt | 16 +- .../api/services/async/AzureServiceAsync.kt | 100 ++++----- .../services/async/AzureServiceAsyncImpl.kt | 24 +- .../api/services/async/BatchServiceAsync.kt | 108 ++++----- .../services/async/BatchServiceAsyncImpl.kt | 29 +-- .../api/services/async/BedrockServiceAsync.kt | 100 ++++----- .../services/async/BedrockServiceAsyncImpl.kt | 22 +- .../api/services/async/BudgetServiceAsync.kt | 32 +-- .../services/async/BudgetServiceAsyncImpl.kt | 27 +-- .../api/services/async/CacheServiceAsync.kt | 36 +-- .../services/async/CacheServiceAsyncImpl.kt | 17 +- .../api/services/async/CohereServiceAsync.kt | 100 ++++----- .../services/async/CohereServiceAsyncImpl.kt | 22 +- .../services/async/CompletionServiceAsync.kt | 12 +- .../async/CompletionServiceAsyncImpl.kt | 10 +- .../services/async/CredentialServiceAsync.kt | 36 +-- .../async/CredentialServiceAsyncImpl.kt | 16 +- .../services/async/CustomerServiceAsync.kt | 36 +-- .../async/CustomerServiceAsyncImpl.kt | 28 +-- .../api/services/async/DeleteServiceAsync.kt | 4 +- .../services/async/DeleteServiceAsyncImpl.kt | 10 +- .../services/async/EmbeddingServiceAsync.kt | 12 +- .../async/EmbeddingServiceAsyncImpl.kt | 10 +- .../api/services/async/EngineServiceAsync.kt | 40 ++-- .../services/async/EngineServiceAsyncImpl.kt | 13 +- .../async/EuAssemblyaiServiceAsync.kt | 100 ++++----- .../async/EuAssemblyaiServiceAsyncImpl.kt | 22 +- .../api/services/async/FileServiceAsync.kt | 56 ++--- .../services/async/FileServiceAsyncImpl.kt | 22 +- .../api/services/async/GeminiServiceAsync.kt | 100 ++++----- .../services/async/GeminiServiceAsyncImpl.kt | 22 +- .../services/async/GuardrailServiceAsync.kt | 12 +- .../async/GuardrailServiceAsyncImpl.kt | 10 +- .../api/services/async/HealthServiceAsync.kt | 52 ++--- .../services/async/HealthServiceAsyncImpl.kt | 22 +- .../api/services/async/KeyServiceAsync.kt | 92 ++++---- .../api/services/async/KeyServiceAsyncImpl.kt | 38 ++-- .../services/async/LangfuseServiceAsync.kt | 100 ++++----- .../async/LangfuseServiceAsyncImpl.kt | 22 +- .../services/async/ModelGroupServiceAsync.kt | 12 +- .../async/ModelGroupServiceAsyncImpl.kt | 10 +- .../api/services/async/ModelServiceAsync.kt | 8 +- .../services/async/ModelServiceAsyncImpl.kt | 13 +- .../services/async/ModerationServiceAsync.kt | 12 +- .../async/ModerationServiceAsyncImpl.kt | 10 +- .../api/services/async/OpenAIServiceAsync.kt | 100 ++++----- .../services/async/OpenAIServiceAsyncImpl.kt | 22 +- .../async/OrganizationServiceAsync.kt | 44 ++-- .../async/OrganizationServiceAsyncImpl.kt | 28 +-- .../services/async/ProviderServiceAsync.kt | 12 +- .../async/ProviderServiceAsyncImpl.kt | 10 +- .../api/services/async/RerankServiceAsync.kt | 36 +-- .../services/async/RerankServiceAsyncImpl.kt | 16 +- .../services/async/ResponseServiceAsync.kt | 52 ++--- .../async/ResponseServiceAsyncImpl.kt | 16 +- .../api/services/async/RouteServiceAsync.kt | 12 +- .../services/async/RouteServiceAsyncImpl.kt | 11 +- .../api/services/async/SettingServiceAsync.kt | 12 +- .../services/async/SettingServiceAsyncImpl.kt | 10 +- .../api/services/async/SpendServiceAsync.kt | 36 +-- .../services/async/SpendServiceAsyncImpl.kt | 16 +- .../api/services/async/TeamServiceAsync.kt | 96 ++++---- .../services/async/TeamServiceAsyncImpl.kt | 48 ++-- .../api/services/async/TestServiceAsync.kt | 12 +- .../services/async/TestServiceAsyncImpl.kt | 11 +- .../api/services/async/ThreadServiceAsync.kt | 32 +-- .../services/async/ThreadServiceAsyncImpl.kt | 13 +- .../api/services/async/UserServiceAsync.kt | 52 ++--- .../services/async/UserServiceAsyncImpl.kt | 26 +-- .../api/services/async/UtilServiceAsync.kt | 12 +- .../services/async/UtilServiceAsyncImpl.kt | 16 +- .../services/async/VertexAiServiceAsync.kt | 100 ++++----- .../async/VertexAiServiceAsyncImpl.kt | 22 +- .../async/audio/SpeechServiceAsync.kt | 12 +- .../async/audio/SpeechServiceAsyncImpl.kt | 10 +- .../async/audio/TranscriptionServiceAsync.kt | 4 +- .../audio/TranscriptionServiceAsyncImpl.kt | 10 +- .../async/batches/CancelServiceAsync.kt | 20 +- .../async/batches/CancelServiceAsyncImpl.kt | 10 +- .../services/async/cache/RediServiceAsync.kt | 12 +- .../async/cache/RediServiceAsyncImpl.kt | 10 +- .../async/chat/CompletionServiceAsync.kt | 12 +- .../async/chat/CompletionServiceAsyncImpl.kt | 10 +- .../config/PassThroughEndpointServiceAsync.kt | 40 ++-- .../PassThroughEndpointServiceAsyncImpl.kt | 19 +- .../async/engines/ChatServiceAsync.kt | 20 +- .../async/engines/ChatServiceAsyncImpl.kt | 10 +- .../async/files/ContentServiceAsync.kt | 12 +- .../async/files/ContentServiceAsyncImpl.kt | 10 +- .../async/finetuning/JobServiceAsync.kt | 20 +- .../async/finetuning/JobServiceAsyncImpl.kt | 18 +- .../finetuning/jobs/CancelServiceAsync.kt | 20 +- .../finetuning/jobs/CancelServiceAsyncImpl.kt | 10 +- .../async/global/SpendServiceAsync.kt | 36 +-- .../async/global/SpendServiceAsyncImpl.kt | 17 +- .../async/images/GenerationServiceAsync.kt | 12 +- .../images/GenerationServiceAsyncImpl.kt | 10 +- .../services/async/model/InfoServiceAsync.kt | 12 +- .../async/model/InfoServiceAsyncImpl.kt | 11 +- .../async/model/UpdateServiceAsync.kt | 16 +- .../async/model/UpdateServiceAsyncImpl.kt | 14 +- .../async/openai/DeploymentServiceAsync.kt | 40 ++-- .../openai/DeploymentServiceAsyncImpl.kt | 13 +- .../openai/deployments/ChatServiceAsync.kt | 20 +- .../deployments/ChatServiceAsyncImpl.kt | 10 +- .../async/organization/InfoServiceAsync.kt | 8 +- .../organization/InfoServiceAsyncImpl.kt | 13 +- .../async/responses/InputItemServiceAsync.kt | 20 +- .../responses/InputItemServiceAsyncImpl.kt | 10 +- .../async/team/CallbackServiceAsync.kt | 32 +-- .../async/team/CallbackServiceAsyncImpl.kt | 13 +- .../services/async/team/ModelServiceAsync.kt | 8 +- .../async/team/ModelServiceAsyncImpl.kt | 14 +- .../async/threads/MessageServiceAsync.kt | 40 ++-- .../async/threads/MessageServiceAsyncImpl.kt | 13 +- .../services/async/threads/RunServiceAsync.kt | 20 +- .../async/threads/RunServiceAsyncImpl.kt | 11 +- .../api/services/blocking/ActiveService.kt | 12 +- .../services/blocking/ActiveServiceImpl.kt | 10 +- .../hanzo/api/services/blocking/AddService.kt | 4 +- .../api/services/blocking/AddServiceImpl.kt | 10 +- .../api/services/blocking/AnthropicService.kt | 100 ++++----- .../services/blocking/AnthropicServiceImpl.kt | 22 +- .../services/blocking/AssemblyaiService.kt | 100 ++++----- .../blocking/AssemblyaiServiceImpl.kt | 22 +- .../api/services/blocking/AssistantService.kt | 44 ++-- .../services/blocking/AssistantServiceImpl.kt | 16 +- .../api/services/blocking/AzureService.kt | 100 ++++----- .../api/services/blocking/AzureServiceImpl.kt | 24 +- .../api/services/blocking/BatchService.kt | 108 ++++----- .../api/services/blocking/BatchServiceImpl.kt | 29 +-- .../api/services/blocking/BedrockService.kt | 100 ++++----- .../services/blocking/BedrockServiceImpl.kt | 22 +- .../api/services/blocking/BudgetService.kt | 32 +-- .../services/blocking/BudgetServiceImpl.kt | 27 +-- .../api/services/blocking/CacheService.kt | 36 +-- .../api/services/blocking/CacheServiceImpl.kt | 17 +- .../api/services/blocking/CohereService.kt | 100 ++++----- .../services/blocking/CohereServiceImpl.kt | 22 +- .../services/blocking/CompletionService.kt | 12 +- .../blocking/CompletionServiceImpl.kt | 10 +- .../services/blocking/CredentialService.kt | 36 +-- .../blocking/CredentialServiceImpl.kt | 16 +- .../api/services/blocking/CustomerService.kt | 36 +-- .../services/blocking/CustomerServiceImpl.kt | 28 +-- .../api/services/blocking/DeleteService.kt | 4 +- .../services/blocking/DeleteServiceImpl.kt | 10 +- .../api/services/blocking/EmbeddingService.kt | 12 +- .../services/blocking/EmbeddingServiceImpl.kt | 10 +- .../api/services/blocking/EngineService.kt | 40 ++-- .../services/blocking/EngineServiceImpl.kt | 13 +- .../services/blocking/EuAssemblyaiService.kt | 100 ++++----- .../blocking/EuAssemblyaiServiceImpl.kt | 22 +- .../api/services/blocking/FileService.kt | 56 ++--- .../api/services/blocking/FileServiceImpl.kt | 22 +- .../api/services/blocking/GeminiService.kt | 100 ++++----- .../services/blocking/GeminiServiceImpl.kt | 22 +- .../api/services/blocking/GuardrailService.kt | 12 +- .../services/blocking/GuardrailServiceImpl.kt | 10 +- .../api/services/blocking/HealthService.kt | 52 ++--- .../services/blocking/HealthServiceImpl.kt | 22 +- .../hanzo/api/services/blocking/KeyService.kt | 92 ++++---- .../api/services/blocking/KeyServiceImpl.kt | 38 ++-- .../api/services/blocking/LangfuseService.kt | 100 ++++----- .../services/blocking/LangfuseServiceImpl.kt | 22 +- .../services/blocking/ModelGroupService.kt | 12 +- .../blocking/ModelGroupServiceImpl.kt | 10 +- .../api/services/blocking/ModelService.kt | 8 +- .../api/services/blocking/ModelServiceImpl.kt | 13 +- .../services/blocking/ModerationService.kt | 12 +- .../blocking/ModerationServiceImpl.kt | 10 +- .../api/services/blocking/OpenAIService.kt | 100 ++++----- .../services/blocking/OpenAIServiceImpl.kt | 22 +- .../services/blocking/OrganizationService.kt | 44 ++-- .../blocking/OrganizationServiceImpl.kt | 28 +-- .../api/services/blocking/ProviderService.kt | 12 +- .../services/blocking/ProviderServiceImpl.kt | 10 +- .../api/services/blocking/RerankService.kt | 36 +-- .../services/blocking/RerankServiceImpl.kt | 16 +- .../api/services/blocking/ResponseService.kt | 52 ++--- .../services/blocking/ResponseServiceImpl.kt | 16 +- .../api/services/blocking/RouteService.kt | 12 +- .../api/services/blocking/RouteServiceImpl.kt | 11 +- .../api/services/blocking/SettingService.kt | 12 +- .../services/blocking/SettingServiceImpl.kt | 10 +- .../api/services/blocking/SpendService.kt | 36 +-- .../api/services/blocking/SpendServiceImpl.kt | 16 +- .../api/services/blocking/TeamService.kt | 96 ++++---- .../api/services/blocking/TeamServiceImpl.kt | 48 ++-- .../api/services/blocking/TestService.kt | 12 +- .../api/services/blocking/TestServiceImpl.kt | 11 +- .../api/services/blocking/ThreadService.kt | 32 +-- .../services/blocking/ThreadServiceImpl.kt | 13 +- .../api/services/blocking/UserService.kt | 52 ++--- .../api/services/blocking/UserServiceImpl.kt | 26 +-- .../api/services/blocking/UtilService.kt | 12 +- .../api/services/blocking/UtilServiceImpl.kt | 16 +- .../api/services/blocking/VertexAiService.kt | 100 ++++----- .../services/blocking/VertexAiServiceImpl.kt | 22 +- .../services/blocking/audio/SpeechService.kt | 12 +- .../blocking/audio/SpeechServiceImpl.kt | 10 +- .../blocking/audio/TranscriptionService.kt | 4 +- .../audio/TranscriptionServiceImpl.kt | 10 +- .../blocking/batches/CancelService.kt | 20 +- .../blocking/batches/CancelServiceImpl.kt | 10 +- .../services/blocking/cache/RediService.kt | 12 +- .../blocking/cache/RediServiceImpl.kt | 10 +- .../blocking/chat/CompletionService.kt | 12 +- .../blocking/chat/CompletionServiceImpl.kt | 10 +- .../config/PassThroughEndpointService.kt | 40 ++-- .../config/PassThroughEndpointServiceImpl.kt | 19 +- .../services/blocking/engines/ChatService.kt | 20 +- .../blocking/engines/ChatServiceImpl.kt | 10 +- .../services/blocking/files/ContentService.kt | 12 +- .../blocking/files/ContentServiceImpl.kt | 10 +- .../blocking/finetuning/JobService.kt | 20 +- .../blocking/finetuning/JobServiceImpl.kt | 18 +- .../blocking/finetuning/jobs/CancelService.kt | 20 +- .../finetuning/jobs/CancelServiceImpl.kt | 10 +- .../services/blocking/global/SpendService.kt | 36 +-- .../blocking/global/SpendServiceImpl.kt | 17 +- .../blocking/images/GenerationService.kt | 12 +- .../blocking/images/GenerationServiceImpl.kt | 10 +- .../services/blocking/model/InfoService.kt | 12 +- .../blocking/model/InfoServiceImpl.kt | 11 +- .../services/blocking/model/UpdateService.kt | 16 +- .../blocking/model/UpdateServiceImpl.kt | 14 +- .../blocking/openai/DeploymentService.kt | 40 ++-- .../blocking/openai/DeploymentServiceImpl.kt | 13 +- .../openai/deployments/ChatService.kt | 20 +- .../openai/deployments/ChatServiceImpl.kt | 10 +- .../blocking/organization/InfoService.kt | 8 +- .../blocking/organization/InfoServiceImpl.kt | 13 +- .../blocking/responses/InputItemService.kt | 20 +- .../responses/InputItemServiceImpl.kt | 10 +- .../services/blocking/team/CallbackService.kt | 32 +-- .../blocking/team/CallbackServiceImpl.kt | 13 +- .../services/blocking/team/ModelService.kt | 8 +- .../blocking/team/ModelServiceImpl.kt | 14 +- .../blocking/threads/MessageService.kt | 40 ++-- .../blocking/threads/MessageServiceImpl.kt | 13 +- .../services/blocking/threads/RunService.kt | 20 +- .../blocking/threads/RunServiceImpl.kt | 11 +- .../META-INF/proguard/hanzo-java-core.pro | 32 +++ .../api/core/http/RetryingHttpClientTest.kt | 77 +++++++ .../api/models/ClientGetHomeParamsTest.kt | 2 - .../api/models/ClientGetHomeResponseTest.kt | 3 - .../active/ActiveListCallbacksParamsTest.kt | 2 - .../active/ActiveListCallbacksResponseTest.kt | 3 - .../models/add/AddAddAllowedIpParamsTest.kt | 3 - .../models/add/AddAddAllowedIpResponseTest.kt | 3 - .../ai/hanzo/api/models/add/IpAddressTest.kt | 3 - .../anthropic/AnthropicCreateParamsTest.kt | 3 - .../anthropic/AnthropicCreateResponseTest.kt | 3 - .../anthropic/AnthropicDeleteParamsTest.kt | 3 - .../anthropic/AnthropicDeleteResponseTest.kt | 3 - .../anthropic/AnthropicModifyParamsTest.kt | 3 - .../anthropic/AnthropicModifyResponseTest.kt | 3 - .../anthropic/AnthropicRetrieveParamsTest.kt | 3 - .../AnthropicRetrieveResponseTest.kt | 3 - .../anthropic/AnthropicUpdateParamsTest.kt | 3 - .../anthropic/AnthropicUpdateResponseTest.kt | 3 - .../assemblyai/AssemblyaiCreateParamsTest.kt | 3 - .../AssemblyaiCreateResponseTest.kt | 3 - .../assemblyai/AssemblyaiDeleteParamsTest.kt | 3 - .../AssemblyaiDeleteResponseTest.kt | 3 - .../assemblyai/AssemblyaiPatchParamsTest.kt | 3 - .../assemblyai/AssemblyaiPatchResponseTest.kt | 3 - .../AssemblyaiRetrieveParamsTest.kt | 3 - .../AssemblyaiRetrieveResponseTest.kt | 3 - .../assemblyai/AssemblyaiUpdateParamsTest.kt | 3 - .../AssemblyaiUpdateResponseTest.kt | 3 - .../assistants/AssistantCreateParamsTest.kt | 2 - .../assistants/AssistantCreateResponseTest.kt | 3 - .../assistants/AssistantDeleteParamsTest.kt | 3 - .../assistants/AssistantDeleteResponseTest.kt | 3 - .../assistants/AssistantListParamsTest.kt | 2 - .../assistants/AssistantListResponseTest.kt | 3 - .../audio/speech/SpeechCreateParamsTest.kt | 2 - .../audio/speech/SpeechCreateResponseTest.kt | 3 - .../TranscriptionCreateParamsTest.kt | 3 - .../TranscriptionCreateResponseTest.kt | 3 - .../api/models/azure/AzureCallParamsTest.kt | 3 - .../api/models/azure/AzureCallResponseTest.kt | 3 - .../api/models/azure/AzureCreateParamsTest.kt | 3 - .../models/azure/AzureCreateResponseTest.kt | 3 - .../api/models/azure/AzureDeleteParamsTest.kt | 3 - .../models/azure/AzureDeleteResponseTest.kt | 3 - .../api/models/azure/AzurePatchParamsTest.kt | 3 - .../models/azure/AzurePatchResponseTest.kt | 3 - .../api/models/azure/AzureUpdateParamsTest.kt | 3 - .../models/azure/AzureUpdateResponseTest.kt | 3 - .../BatchCancelWithProviderParamsTest.kt | 3 - .../BatchCancelWithProviderResponseTest.kt | 3 - .../models/batches/BatchCreateParamsTest.kt | 4 - .../models/batches/BatchCreateResponseTest.kt | 3 - .../BatchCreateWithProviderParamsTest.kt | 3 - .../BatchCreateWithProviderResponseTest.kt | 3 - .../api/models/batches/BatchListParamsTest.kt | 4 - .../models/batches/BatchListResponseTest.kt | 3 - .../BatchListWithProviderParamsTest.kt | 5 - .../BatchListWithProviderResponseTest.kt | 3 - .../models/batches/BatchRetrieveParamsTest.kt | 5 - .../batches/BatchRetrieveResponseTest.kt | 3 - .../BatchRetrieveWithProviderParamsTest.kt | 3 - .../BatchRetrieveWithProviderResponseTest.kt | 3 - .../batches/cancel/CancelCancelParamsTest.kt | 5 - .../cancel/CancelCancelResponseTest.kt | 3 - .../models/bedrock/BedrockCreateParamsTest.kt | 3 - .../bedrock/BedrockCreateResponseTest.kt | 3 - .../models/bedrock/BedrockDeleteParamsTest.kt | 3 - .../bedrock/BedrockDeleteResponseTest.kt | 3 - .../models/bedrock/BedrockPatchParamsTest.kt | 3 - .../bedrock/BedrockPatchResponseTest.kt | 3 - .../bedrock/BedrockRetrieveParamsTest.kt | 3 - .../bedrock/BedrockRetrieveResponseTest.kt | 3 - .../models/bedrock/BedrockUpdateParamsTest.kt | 3 - .../bedrock/BedrockUpdateResponseTest.kt | 3 - .../models/budget/BudgetCreateParamsTest.kt | 4 - .../models/budget/BudgetCreateResponseTest.kt | 3 - .../models/budget/BudgetDeleteParamsTest.kt | 3 - .../models/budget/BudgetDeleteResponseTest.kt | 3 - .../api/models/budget/BudgetInfoParamsTest.kt | 3 - .../models/budget/BudgetInfoResponseTest.kt | 3 - .../api/models/budget/BudgetListParamsTest.kt | 2 - .../models/budget/BudgetListResponseTest.kt | 3 - .../hanzo/api/models/budget/BudgetNewTest.kt | 3 - .../models/budget/BudgetSettingsParamsTest.kt | 3 - .../budget/BudgetSettingsResponseTest.kt | 3 - .../models/budget/BudgetUpdateParamsTest.kt | 4 - .../models/budget/BudgetUpdateResponseTest.kt | 3 - .../api/models/cache/CacheDeleteParamsTest.kt | 2 - .../models/cache/CacheDeleteResponseTest.kt | 3 - .../models/cache/CacheFlushAllParamsTest.kt | 2 - .../models/cache/CacheFlushAllResponseTest.kt | 3 - .../api/models/cache/CachePingParamsTest.kt | 2 - .../api/models/cache/CachePingResponseTest.kt | 3 - .../cache/redis/RediRetrieveInfoParamsTest.kt | 2 - .../redis/RediRetrieveInfoResponseTest.kt | 3 - .../completions/CompletionCreateParamsTest.kt | 4 - .../CompletionCreateResponseTest.kt | 3 - .../models/cohere/CohereCreateParamsTest.kt | 3 - .../models/cohere/CohereCreateResponseTest.kt | 3 - .../models/cohere/CohereDeleteParamsTest.kt | 3 - .../models/cohere/CohereDeleteResponseTest.kt | 3 - .../models/cohere/CohereModifyParamsTest.kt | 3 - .../models/cohere/CohereModifyResponseTest.kt | 3 - .../models/cohere/CohereRetrieveParamsTest.kt | 3 - .../cohere/CohereRetrieveResponseTest.kt | 3 - .../models/cohere/CohereUpdateParamsTest.kt | 3 - .../models/cohere/CohereUpdateResponseTest.kt | 3 - .../completions/CompletionCreateParamsTest.kt | 4 - .../CompletionCreateResponseTest.kt | 3 - .../PassThroughEndpointCreateParamsTest.kt | 3 - .../PassThroughEndpointCreateResponseTest.kt | 3 - .../PassThroughEndpointDeleteParamsTest.kt | 3 - .../PassThroughEndpointListParamsTest.kt | 4 - .../PassThroughEndpointResponseTest.kt | 3 - .../PassThroughEndpointUpdateParamsTest.kt | 3 - .../PassThroughEndpointUpdateResponseTest.kt | 3 - .../PassThroughGenericEndpointTest.kt | 3 - .../credentials/CredentialCreateParamsTest.kt | 4 - .../CredentialCreateResponseTest.kt | 3 - .../credentials/CredentialDeleteParamsTest.kt | 3 - .../CredentialDeleteResponseTest.kt | 3 - .../models/credentials/CredentialItemTest.kt | 3 - .../credentials/CredentialListParamsTest.kt | 2 - .../credentials/CredentialListResponseTest.kt | 3 - .../api/models/customer/BlockUsersTest.kt | 3 - .../customer/CustomerBlockParamsTest.kt | 3 - .../customer/CustomerBlockResponseTest.kt | 3 - .../customer/CustomerCreateParamsTest.kt | 4 - .../customer/CustomerCreateResponseTest.kt | 3 - .../customer/CustomerDeleteParamsTest.kt | 3 - .../customer/CustomerDeleteResponseTest.kt | 3 - .../models/customer/CustomerListParamsTest.kt | 2 - .../customer/CustomerListResponseTest.kt | 3 - .../CustomerRetrieveInfoParamsTest.kt | 3 - .../CustomerRetrieveInfoResponseTest.kt | 3 - .../customer/CustomerUnblockParamsTest.kt | 3 - .../customer/CustomerUnblockResponseTest.kt | 3 - .../customer/CustomerUpdateParamsTest.kt | 4 - .../customer/CustomerUpdateResponseTest.kt | 3 - .../delete/DeleteCreateAllowedIpParamsTest.kt | 3 - .../DeleteCreateAllowedIpResponseTest.kt | 3 - .../embeddings/EmbeddingCreateParamsTest.kt | 4 - .../embeddings/EmbeddingCreateResponseTest.kt | 3 - .../engines/EngineCompleteParamsTest.kt | 3 - .../engines/EngineCompleteResponseTest.kt | 3 - .../models/engines/EngineEmbedParamsTest.kt | 3 - .../models/engines/EngineEmbedResponseTest.kt | 3 - .../engines/chat/ChatCompleteParamsTest.kt | 3 - .../engines/chat/ChatCompleteResponseTest.kt | 3 - .../EuAssemblyaiCreateParamsTest.kt | 3 - .../EuAssemblyaiCreateResponseTest.kt | 3 - .../EuAssemblyaiDeleteParamsTest.kt | 3 - .../EuAssemblyaiDeleteResponseTest.kt | 3 - .../EuAssemblyaiPatchParamsTest.kt | 3 - .../EuAssemblyaiPatchResponseTest.kt | 3 - .../EuAssemblyaiRetrieveParamsTest.kt | 3 - .../EuAssemblyaiRetrieveResponseTest.kt | 3 - .../EuAssemblyaiUpdateParamsTest.kt | 3 - .../EuAssemblyaiUpdateResponseTest.kt | 3 - .../api/models/files/FileCreateParamsTest.kt | 5 - .../models/files/FileCreateResponseTest.kt | 3 - .../api/models/files/FileDeleteParamsTest.kt | 3 - .../models/files/FileDeleteResponseTest.kt | 3 - .../api/models/files/FileListParamsTest.kt | 5 - .../api/models/files/FileListResponseTest.kt | 3 - .../models/files/FileRetrieveParamsTest.kt | 3 - .../models/files/FileRetrieveResponseTest.kt | 3 - .../content/ContentRetrieveParamsTest.kt | 3 - .../content/ContentRetrieveResponseTest.kt | 3 - .../finetuning/jobs/JobCreateParamsTest.kt | 4 - .../finetuning/jobs/JobCreateResponseTest.kt | 3 - .../finetuning/jobs/JobListParamsTest.kt | 4 - .../finetuning/jobs/JobListResponseTest.kt | 3 - .../finetuning/jobs/JobRetrieveParamsTest.kt | 4 - .../jobs/JobRetrieveResponseTest.kt | 3 - .../jobs/cancel/CancelCreateParamsTest.kt | 3 - .../jobs/cancel/CancelCreateResponseTest.kt | 3 - .../models/gemini/GeminiCreateParamsTest.kt | 3 - .../models/gemini/GeminiCreateResponseTest.kt | 3 - .../models/gemini/GeminiDeleteParamsTest.kt | 3 - .../models/gemini/GeminiDeleteResponseTest.kt | 3 - .../models/gemini/GeminiPatchParamsTest.kt | 3 - .../models/gemini/GeminiPatchResponseTest.kt | 3 - .../models/gemini/GeminiRetrieveParamsTest.kt | 3 - .../gemini/GeminiRetrieveResponseTest.kt | 3 - .../models/gemini/GeminiUpdateParamsTest.kt | 3 - .../models/gemini/GeminiUpdateResponseTest.kt | 3 - .../global/spend/SpendListTagsParamsTest.kt | 4 - .../global/spend/SpendListTagsResponseTest.kt | 3 - .../global/spend/SpendResetParamsTest.kt | 2 - .../global/spend/SpendResetResponseTest.kt | 3 - .../spend/SpendRetrieveReportParamsTest.kt | 4 - .../spend/SpendRetrieveReportResponseTest.kt | 3 - .../guardrails/GuardrailListParamsTest.kt | 2 - .../guardrails/GuardrailListResponseTest.kt | 3 - .../models/health/HealthCheckAllParamsTest.kt | 4 - .../health/HealthCheckAllResponseTest.kt | 3 - .../health/HealthCheckLivelinessParamsTest.kt | 2 - .../HealthCheckLivelinessResponseTest.kt | 3 - .../health/HealthCheckLivenessParamsTest.kt | 2 - .../health/HealthCheckLivenessResponseTest.kt | 3 - .../health/HealthCheckReadinessParamsTest.kt | 2 - .../HealthCheckReadinessResponseTest.kt | 3 - .../health/HealthCheckServicesParamsTest.kt | 3 - .../health/HealthCheckServicesResponseTest.kt | 3 - .../generations/GenerationCreateParamsTest.kt | 2 - .../GenerationCreateResponseTest.kt | 3 - .../api/models/key/BlockKeyRequestTest.kt | 3 - .../api/models/key/GenerateKeyResponseTest.kt | 3 - .../api/models/key/KeyBlockParamsTest.kt | 6 - .../api/models/key/KeyBlockResponseTest.kt | 3 - .../models/key/KeyCheckHealthParamsTest.kt | 2 - .../models/key/KeyCheckHealthResponseTest.kt | 3 - .../api/models/key/KeyDeleteParamsTest.kt | 6 - .../api/models/key/KeyDeleteResponseTest.kt | 3 - .../api/models/key/KeyGenerateParamsTest.kt | 6 - .../hanzo/api/models/key/KeyListParamsTest.kt | 4 - .../api/models/key/KeyListResponseTest.kt | 3 - .../key/KeyRegenerateByKeyParamsTest.kt | 7 - .../models/key/KeyRetrieveInfoParamsTest.kt | 4 - .../models/key/KeyRetrieveInfoResponseTest.kt | 3 - .../api/models/key/KeyUnblockParamsTest.kt | 6 - .../api/models/key/KeyUnblockResponseTest.kt | 3 - .../api/models/key/KeyUpdateParamsTest.kt | 6 - .../api/models/key/KeyUpdateResponseTest.kt | 3 - .../regenerate/RegenerateKeyRequestTest.kt | 3 - .../langfuse/LangfuseCreateParamsTest.kt | 3 - .../langfuse/LangfuseCreateResponseTest.kt | 3 - .../langfuse/LangfuseDeleteParamsTest.kt | 3 - .../langfuse/LangfuseDeleteResponseTest.kt | 3 - .../langfuse/LangfusePatchParamsTest.kt | 3 - .../langfuse/LangfusePatchResponseTest.kt | 3 - .../langfuse/LangfuseRetrieveParamsTest.kt | 3 - .../langfuse/LangfuseRetrieveResponseTest.kt | 3 - .../langfuse/LangfuseUpdateParamsTest.kt | 3 - .../langfuse/LangfuseUpdateResponseTest.kt | 3 - ...figurableClientsideParamsCustomAuthTest.kt | 3 - .../api/models/model/ModelCreateParamsTest.kt | 4 - .../models/model/ModelCreateResponseTest.kt | 3 - .../api/models/model/ModelDeleteParamsTest.kt | 3 - .../models/model/ModelDeleteResponseTest.kt | 3 - .../hanzo/api/models/model/ModelInfoTest.kt | 3 - .../models/model/info/InfoListParamsTest.kt | 4 - .../models/model/info/InfoListResponseTest.kt | 3 - .../model/update/UpdateDeploymentTest.kt | 3 - .../model/update/UpdateFullParamsTest.kt | 4 - .../model/update/UpdateFullResponseTest.kt | 3 - .../model/update/UpdatePartialParamsTest.kt | 5 - .../model/update/UpdatePartialResponseTest.kt | 3 - .../ModelGroupRetrieveInfoParamsTest.kt | 4 - .../ModelGroupRetrieveInfoResponseTest.kt | 3 - .../api/models/models/ModelListParamsTest.kt | 4 - .../models/models/ModelListResponseTest.kt | 3 - .../moderations/ModerationCreateParamsTest.kt | 2 - .../ModerationCreateResponseTest.kt | 3 - .../models/openai/OpenAICreateParamsTest.kt | 3 - .../models/openai/OpenAICreateResponseTest.kt | 3 - .../models/openai/OpenAIDeleteParamsTest.kt | 3 - .../models/openai/OpenAIDeleteResponseTest.kt | 3 - .../models/openai/OpenAIPatchParamsTest.kt | 3 - .../models/openai/OpenAIPatchResponseTest.kt | 3 - .../models/openai/OpenAIRetrieveParamsTest.kt | 3 - .../openai/OpenAIRetrieveResponseTest.kt | 3 - .../models/openai/OpenAIUpdateParamsTest.kt | 3 - .../models/openai/OpenAIUpdateResponseTest.kt | 3 - .../DeploymentCompleteParamsTest.kt | 3 - .../DeploymentCompleteResponseTest.kt | 3 - .../deployments/DeploymentEmbedParamsTest.kt | 3 - .../DeploymentEmbedResponseTest.kt | 3 - .../chat/ChatCompleteParamsTest.kt | 3 - .../chat/ChatCompleteResponseTest.kt | 3 - .../api/models/organization/OrgMemberTest.kt | 3 - .../OrganizationAddMemberParamsTest.kt | 4 - .../OrganizationAddMemberResponseTest.kt | 3 - .../OrganizationCreateParamsTest.kt | 4 - .../OrganizationCreateResponseTest.kt | 3 - .../OrganizationDeleteMemberParamsTest.kt | 4 - .../OrganizationDeleteMemberResponseTest.kt | 3 - .../OrganizationDeleteParamsTest.kt | 3 - .../OrganizationDeleteResponseTest.kt | 3 - .../OrganizationListParamsTest.kt | 2 - .../OrganizationListResponseTest.kt | 3 - .../OrganizationUpdateMemberParamsTest.kt | 4 - .../OrganizationUpdateMemberResponseTest.kt | 3 - .../OrganizationUpdateParamsTest.kt | 4 - .../OrganizationUpdateResponseTest.kt | 3 - .../info/InfoDeprecatedParamsTest.kt | 3 - .../info/InfoDeprecatedResponseTest.kt | 3 - .../info/InfoRetrieveParamsTest.kt | 3 - .../info/InfoRetrieveResponseTest.kt | 3 - .../provider/ProviderListBudgetsParamsTest.kt | 2 - .../ProviderListBudgetsResponseTest.kt | 3 - .../models/rerank/RerankCreateParamsTest.kt | 2 - .../models/rerank/RerankCreateResponseTest.kt | 3 - .../models/rerank/RerankCreateV1ParamsTest.kt | 2 - .../rerank/RerankCreateV1ResponseTest.kt | 3 - .../models/rerank/RerankCreateV2ParamsTest.kt | 2 - .../rerank/RerankCreateV2ResponseTest.kt | 3 - .../responses/ResponseCreateParamsTest.kt | 2 - .../responses/ResponseCreateResponseTest.kt | 3 - .../responses/ResponseDeleteParamsTest.kt | 3 - .../responses/ResponseDeleteResponseTest.kt | 3 - .../responses/ResponseRetrieveParamsTest.kt | 3 - .../responses/ResponseRetrieveResponseTest.kt | 3 - .../inputitems/InputItemListParamsTest.kt | 3 - .../inputitems/InputItemListResponseTest.kt | 3 - .../api/models/routes/RouteListParamsTest.kt | 2 - .../models/routes/RouteListResponseTest.kt | 3 - .../settings/SettingRetrieveParamsTest.kt | 2 - .../settings/SettingRetrieveResponseTest.kt | 3 - .../spend/SpendCalculateSpendParamsTest.kt | 4 - .../spend/SpendCalculateSpendResponseTest.kt | 3 - .../models/spend/SpendListLogsParamsTest.kt | 4 - .../models/spend/SpendListLogsResponseTest.kt | 3 - .../models/spend/SpendListTagsParamsTest.kt | 4 - .../models/spend/SpendListTagsResponseTest.kt | 3 - .../api/models/team/BlockTeamRequestTest.kt | 3 - .../ai/hanzo/api/models/team/MemberTest.kt | 3 - .../models/team/TeamAddMemberParamsTest.kt | 4 - .../models/team/TeamAddMemberResponseTest.kt | 3 - .../api/models/team/TeamBlockParamsTest.kt | 3 - .../api/models/team/TeamBlockResponseTest.kt | 3 - .../api/models/team/TeamCreateParamsTest.kt | 6 - .../api/models/team/TeamCreateResponseTest.kt | 3 - .../api/models/team/TeamDeleteParamsTest.kt | 6 - .../api/models/team/TeamDeleteResponseTest.kt | 3 - .../team/TeamDisableLoggingParamsTest.kt | 3 - .../team/TeamDisableLoggingResponseTest.kt | 3 - .../team/TeamListAvailableParamsTest.kt | 4 - .../team/TeamListAvailableResponseTest.kt | 3 - .../api/models/team/TeamListParamsTest.kt | 4 - .../api/models/team/TeamListResponseTest.kt | 3 - .../models/team/TeamRemoveMemberParamsTest.kt | 4 - .../team/TeamRemoveMemberResponseTest.kt | 3 - .../models/team/TeamRetrieveInfoParamsTest.kt | 4 - .../team/TeamRetrieveInfoResponseTest.kt | 3 - .../api/models/team/TeamUnblockParamsTest.kt | 3 - .../models/team/TeamUnblockResponseTest.kt | 3 - .../models/team/TeamUpdateMemberParamsTest.kt | 4 - .../team/TeamUpdateMemberResponseTest.kt | 3 - .../api/models/team/TeamUpdateParamsTest.kt | 6 - .../api/models/team/TeamUpdateResponseTest.kt | 3 - .../team/callback/CallbackAddParamsTest.kt | 7 - .../team/callback/CallbackAddResponseTest.kt | 3 - .../callback/CallbackRetrieveParamsTest.kt | 3 - .../callback/CallbackRetrieveResponseTest.kt | 3 - .../models/team/model/ModelAddParamsTest.kt | 3 - .../models/team/model/ModelAddResponseTest.kt | 3 - .../team/model/ModelRemoveParamsTest.kt | 3 - .../team/model/ModelRemoveResponseTest.kt | 3 - .../api/models/test/TestPingParamsTest.kt | 2 - .../api/models/test/TestPingResponseTest.kt | 3 - .../models/threads/ThreadCreateParamsTest.kt | 2 - .../threads/ThreadCreateResponseTest.kt | 3 - .../threads/ThreadRetrieveParamsTest.kt | 3 - .../threads/ThreadRetrieveResponseTest.kt | 3 - .../messages/MessageCreateParamsTest.kt | 3 - .../messages/MessageCreateResponseTest.kt | 3 - .../threads/messages/MessageListParamsTest.kt | 3 - .../messages/MessageListResponseTest.kt | 3 - .../threads/runs/RunCreateParamsTest.kt | 3 - .../threads/runs/RunCreateResponseTest.kt | 3 - .../api/models/user/UserCreateParamsTest.kt | 4 - .../api/models/user/UserCreateResponseTest.kt | 3 - .../api/models/user/UserDeleteParamsTest.kt | 6 - .../api/models/user/UserDeleteResponseTest.kt | 3 - .../api/models/user/UserListParamsTest.kt | 4 - .../api/models/user/UserListResponseTest.kt | 3 - .../models/user/UserRetrieveInfoParamsTest.kt | 4 - .../user/UserRetrieveInfoResponseTest.kt | 3 - .../api/models/user/UserUpdateParamsTest.kt | 4 - .../api/models/user/UserUpdateResponseTest.kt | 3 - .../UtilGetSupportedOpenAIParamsParamsTest.kt | 3 - ...tilGetSupportedOpenAIParamsResponseTest.kt | 3 - .../utils/UtilTokenCounterParamsTest.kt | 4 - .../utils/UtilTokenCounterResponseTest.kt | 3 - .../utils/UtilTransformRequestParamsTest.kt | 3 - .../utils/UtilTransformRequestResponseTest.kt | 3 - .../vertexai/VertexAiCreateParamsTest.kt | 3 - .../vertexai/VertexAiCreateResponseTest.kt | 3 - .../vertexai/VertexAiDeleteParamsTest.kt | 3 - .../vertexai/VertexAiDeleteResponseTest.kt | 3 - .../vertexai/VertexAiPatchParamsTest.kt | 3 - .../vertexai/VertexAiPatchResponseTest.kt | 3 - .../vertexai/VertexAiRetrieveParamsTest.kt | 3 - .../vertexai/VertexAiRetrieveResponseTest.kt | 3 - .../vertexai/VertexAiUpdateParamsTest.kt | 3 - .../vertexai/VertexAiUpdateResponseTest.kt | 3 - .../hanzo/api/services/ErrorHandlingTest.kt | 146 ++++++++++++- .../hanzo/api/services/ServiceParamsTest.kt | 2 +- .../services/async/ActiveServiceAsyncTest.kt | 2 +- .../api/services/async/AddServiceAsyncTest.kt | 2 +- .../async/AnthropicServiceAsyncTest.kt | 10 +- .../async/AssemblyaiServiceAsyncTest.kt | 10 +- .../async/AssistantServiceAsyncTest.kt | 6 +- .../services/async/AzureServiceAsyncTest.kt | 10 +- .../services/async/BatchServiceAsyncTest.kt | 14 +- .../services/async/BedrockServiceAsyncTest.kt | 10 +- .../services/async/BudgetServiceAsyncTest.kt | 12 +- .../services/async/CacheServiceAsyncTest.kt | 6 +- .../services/async/CohereServiceAsyncTest.kt | 10 +- .../async/CompletionServiceAsyncTest.kt | 2 +- .../async/CredentialServiceAsyncTest.kt | 6 +- .../async/CustomerServiceAsyncTest.kt | 14 +- .../services/async/DeleteServiceAsyncTest.kt | 2 +- .../async/EmbeddingServiceAsyncTest.kt | 2 +- .../services/async/EngineServiceAsyncTest.kt | 4 +- .../async/EuAssemblyaiServiceAsyncTest.kt | 10 +- .../services/async/FileServiceAsyncTest.kt | 8 +- .../services/async/GeminiServiceAsyncTest.kt | 10 +- .../async/GuardrailServiceAsyncTest.kt | 2 +- .../services/async/HealthServiceAsyncTest.kt | 10 +- .../api/services/async/KeyServiceAsyncTest.kt | 18 +- .../async/LangfuseServiceAsyncTest.kt | 10 +- .../async/ModelGroupServiceAsyncTest.kt | 2 +- .../services/async/ModelServiceAsyncTest.kt | 4 +- .../async/ModerationServiceAsyncTest.kt | 2 +- .../services/async/OpenAIServiceAsyncTest.kt | 10 +- .../async/OrganizationServiceAsyncTest.kt | 14 +- .../async/ProviderServiceAsyncTest.kt | 2 +- .../services/async/RerankServiceAsyncTest.kt | 6 +- .../async/ResponseServiceAsyncTest.kt | 6 +- .../services/async/RouteServiceAsyncTest.kt | 2 +- .../services/async/SettingServiceAsyncTest.kt | 2 +- .../services/async/SpendServiceAsyncTest.kt | 6 +- .../services/async/TeamServiceAsyncTest.kt | 24 +- .../services/async/TestServiceAsyncTest.kt | 2 +- .../services/async/ThreadServiceAsyncTest.kt | 4 +- .../services/async/UserServiceAsyncTest.kt | 10 +- .../services/async/UtilServiceAsyncTest.kt | 6 +- .../async/VertexAiServiceAsyncTest.kt | 10 +- .../async/audio/SpeechServiceAsyncTest.kt | 2 +- .../audio/TranscriptionServiceAsyncTest.kt | 2 +- .../async/batches/CancelServiceAsyncTest.kt | 2 +- .../async/cache/RediServiceAsyncTest.kt | 2 +- .../async/chat/CompletionServiceAsyncTest.kt | 2 +- .../PassThroughEndpointServiceAsyncTest.kt | 8 +- .../async/engines/ChatServiceAsyncTest.kt | 2 +- .../async/files/ContentServiceAsyncTest.kt | 2 +- .../async/finetuning/JobServiceAsyncTest.kt | 6 +- .../finetuning/jobs/CancelServiceAsyncTest.kt | 2 +- .../async/global/SpendServiceAsyncTest.kt | 6 +- .../images/GenerationServiceAsyncTest.kt | 2 +- .../async/model/InfoServiceAsyncTest.kt | 2 +- .../async/model/UpdateServiceAsyncTest.kt | 4 +- .../openai/DeploymentServiceAsyncTest.kt | 4 +- .../deployments/ChatServiceAsyncTest.kt | 2 +- .../organization/InfoServiceAsyncTest.kt | 4 +- .../responses/InputItemServiceAsyncTest.kt | 2 +- .../async/team/CallbackServiceAsyncTest.kt | 4 +- .../async/team/ModelServiceAsyncTest.kt | 4 +- .../async/threads/MessageServiceAsyncTest.kt | 4 +- .../async/threads/RunServiceAsyncTest.kt | 2 +- .../services/blocking/ActiveServiceTest.kt | 2 +- .../api/services/blocking/AddServiceTest.kt | 2 +- .../services/blocking/AnthropicServiceTest.kt | 10 +- .../blocking/AssemblyaiServiceTest.kt | 10 +- .../services/blocking/AssistantServiceTest.kt | 6 +- .../api/services/blocking/AzureServiceTest.kt | 10 +- .../api/services/blocking/BatchServiceTest.kt | 14 +- .../services/blocking/BedrockServiceTest.kt | 10 +- .../services/blocking/BudgetServiceTest.kt | 12 +- .../api/services/blocking/CacheServiceTest.kt | 6 +- .../services/blocking/CohereServiceTest.kt | 10 +- .../blocking/CompletionServiceTest.kt | 2 +- .../blocking/CredentialServiceTest.kt | 6 +- .../services/blocking/CustomerServiceTest.kt | 14 +- .../services/blocking/DeleteServiceTest.kt | 2 +- .../services/blocking/EmbeddingServiceTest.kt | 2 +- .../services/blocking/EngineServiceTest.kt | 4 +- .../blocking/EuAssemblyaiServiceTest.kt | 10 +- .../api/services/blocking/FileServiceTest.kt | 8 +- .../services/blocking/GeminiServiceTest.kt | 10 +- .../services/blocking/GuardrailServiceTest.kt | 2 +- .../services/blocking/HealthServiceTest.kt | 10 +- .../api/services/blocking/KeyServiceTest.kt | 18 +- .../services/blocking/LangfuseServiceTest.kt | 10 +- .../blocking/ModelGroupServiceTest.kt | 2 +- .../api/services/blocking/ModelServiceTest.kt | 4 +- .../blocking/ModerationServiceTest.kt | 2 +- .../services/blocking/OpenAIServiceTest.kt | 10 +- .../blocking/OrganizationServiceTest.kt | 14 +- .../services/blocking/ProviderServiceTest.kt | 2 +- .../services/blocking/RerankServiceTest.kt | 6 +- .../services/blocking/ResponseServiceTest.kt | 6 +- .../api/services/blocking/RouteServiceTest.kt | 2 +- .../services/blocking/SettingServiceTest.kt | 2 +- .../api/services/blocking/SpendServiceTest.kt | 6 +- .../api/services/blocking/TeamServiceTest.kt | 24 +- .../api/services/blocking/TestServiceTest.kt | 2 +- .../services/blocking/ThreadServiceTest.kt | 4 +- .../api/services/blocking/UserServiceTest.kt | 10 +- .../api/services/blocking/UtilServiceTest.kt | 6 +- .../services/blocking/VertexAiServiceTest.kt | 10 +- .../blocking/audio/SpeechServiceTest.kt | 2 +- .../audio/TranscriptionServiceTest.kt | 2 +- .../blocking/batches/CancelServiceTest.kt | 2 +- .../blocking/cache/RediServiceTest.kt | 2 +- .../blocking/chat/CompletionServiceTest.kt | 2 +- .../config/PassThroughEndpointServiceTest.kt | 8 +- .../blocking/engines/ChatServiceTest.kt | 2 +- .../blocking/files/ContentServiceTest.kt | 2 +- .../blocking/finetuning/JobServiceTest.kt | 6 +- .../finetuning/jobs/CancelServiceTest.kt | 2 +- .../blocking/global/SpendServiceTest.kt | 6 +- .../blocking/images/GenerationServiceTest.kt | 2 +- .../blocking/model/InfoServiceTest.kt | 2 +- .../blocking/model/UpdateServiceTest.kt | 4 +- .../blocking/openai/DeploymentServiceTest.kt | 4 +- .../openai/deployments/ChatServiceTest.kt | 2 +- .../blocking/organization/InfoServiceTest.kt | 4 +- .../responses/InputItemServiceTest.kt | 2 +- .../blocking/team/CallbackServiceTest.kt | 4 +- .../blocking/team/ModelServiceTest.kt | 4 +- .../blocking/threads/MessageServiceTest.kt | 4 +- .../blocking/threads/RunServiceTest.kt | 2 +- hanzo-java-example/build.gradle.kts | 2 +- hanzo-java-proguard-test/build.gradle.kts | 101 +++++++++ .../api/proguard/ProGuardCompatibilityTest.kt | 119 ++++++++++ hanzo-java-proguard-test/test.pro | 9 + scripts/build | 8 + scripts/format | 17 +- scripts/java-format | 7 + scripts/kotlin-format | 7 + scripts/lint | 19 +- scripts/mock | 4 +- scripts/test | 4 +- settings.gradle.kts | 16 +- 1194 files changed, 10208 insertions(+), 6805 deletions(-) create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableExecutorService.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoRetryableException.kt create mode 100644 hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro create mode 100644 hanzo-java-proguard-test/build.gradle.kts create mode 100644 hanzo-java-proguard-test/src/test/kotlin/ai/hanzo/api/proguard/ProGuardCompatibilityTest.kt create mode 100644 hanzo-java-proguard-test/test.pro create mode 100755 scripts/build create mode 100755 scripts/java-format create mode 100755 scripts/kotlin-format diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d632595..fdde8e99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: jobs: lint: - timeout-minutes: 10 + timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork @@ -36,8 +36,33 @@ jobs: - name: Run lints run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build SDK + run: ./scripts/build + test: - timeout-minutes: 10 + timeout-minutes: 15 name: test runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 33f86979..7bfbe407 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -22,7 +22,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral -Dorg.gradle.jvmargs="-Xmx8g" --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.HANZO_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.HANZO_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/.gitignore b/.gitignore index 4e81838d..b1346e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ .gradle .idea .kotlin -build +build/ codegen.log kls_database.db diff --git a/.stats.yml b/.stats.yml index affe3eef..7c3c5481 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-2d6e1036fb1eea7e95cafc281141ead9ef77796e43711b17edccaab67c5e791a.yml openapi_spec_hash: 12501774d0127be4ec1812d613a58e97 -config_hash: 830747463ff4d018b5633ce511e88558 +config_hash: 5b61cc8c6c31c071a08578ad825b421d diff --git a/README.md b/README.md index 4d9653e9..19ef3fd4 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; -// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables +// Configures using the `hanzo.apiKey` and `hanzo.baseUrl` system properties +// Or configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClient client = HanzoOkHttpClient.fromEnv(); ClientGetHomeResponse response = client.getHome(); @@ -61,13 +62,14 @@ ClientGetHomeResponse response = client.getHome(); ## Client configuration -Configure the client using environment variables: +Configure the client using system properties or environment variables: ```java import ai.hanzo.api.client.HanzoClient; import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; -// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables +// Configures using the `hanzo.apiKey` and `hanzo.baseUrl` system properties +// Or configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClient client = HanzoOkHttpClient.fromEnv(); ``` @@ -89,7 +91,8 @@ import ai.hanzo.api.client.HanzoClient; import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; HanzoClient client = HanzoOkHttpClient.builder() - // Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables + // Configures using the `hanzo.apiKey` and `hanzo.baseUrl` system properties + // Or configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables .fromEnv() .apiKey("My API Key") .build(); @@ -97,10 +100,12 @@ HanzoClient client = HanzoOkHttpClient.builder() See this table for the available options: -| Setter | Environment variable | Required | Default value | -| --------- | -------------------- | -------- | ------------------------ | -| `apiKey` | `HANZO_API_KEY` | true | - | -| `baseUrl` | `HANZO_BASE_URL` | true | `"https://api.hanzo.ai"` | +| Setter | System property | Environment variable | Required | Default value | +| --------- | --------------- | -------------------- | -------- | ------------------------ | +| `apiKey` | `hanzo.apiKey` | `HANZO_API_KEY` | true | - | +| `baseUrl` | `hanzo.baseUrl` | `HANZO_BASE_URL` | true | `"https://api.hanzo.ai"` | + +System properties take precedence over environment variables. > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -146,7 +151,8 @@ import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; import java.util.concurrent.CompletableFuture; -// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables +// Configures using the `hanzo.apiKey` and `hanzo.baseUrl` system properties +// Or configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClient client = HanzoOkHttpClient.fromEnv(); CompletableFuture response = client.async().getHome(); @@ -161,7 +167,8 @@ import ai.hanzo.api.models.ClientGetHomeParams; import ai.hanzo.api.models.ClientGetHomeResponse; import java.util.concurrent.CompletableFuture; -// Configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables +// Configures using the `hanzo.apiKey` and `hanzo.baseUrl` system properties +// Or configures using the `HANZO_API_KEY` and `HANZO_BASE_URL` environment variables HanzoClientAsync client = HanzoOkHttpClientAsync.fromEnv(); CompletableFuture response = client.getHome(); @@ -274,6 +281,8 @@ The SDK throws custom unchecked exception types: - [`HanzoIoException`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoIoException.kt): I/O networking errors. +- [`HanzoRetryableException`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoRetryableException.kt): Generic error indicating a failure that could be retried by the client. + - [`HanzoInvalidDataException`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. - [`HanzoException`](hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. @@ -294,6 +303,12 @@ Or to `debug` for more verbose logging: $ export HANZO_LOG=debug ``` +## ProGuard and R8 + +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `hanzo-java-core` is published with a [configuration file](hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + ## Jackson The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. @@ -309,7 +324,7 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t ### Retries -The SDK automatically retries 2 times by default, with a short exponential backoff. +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. Only the following error types are retried: @@ -319,7 +334,7 @@ Only the following error types are retried: - 429 Rate Limit - 5xx Internal -The API may also explicitly instruct the SDK to retry or not retry a response. +The API may also explicitly instruct the SDK to retry or not retry a request. To set a custom number of retries, configure the client using the `maxRetries` method: @@ -378,6 +393,27 @@ HanzoClient client = HanzoOkHttpClient.builder() .build(); ``` +### HTTPS + +> [!NOTE] +> Most applications should not call these methods, and instead use the system defaults. The defaults include +> special optimizations that can be lost if the implementations are modified. + +To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: + +```java +import ai.hanzo.api.client.HanzoClient; +import ai.hanzo.api.client.okhttp.HanzoOkHttpClient; + +HanzoClient client = HanzoOkHttpClient.builder() + .fromEnv() + // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa. + .sslSocketFactory(yourSSLSocketFactory) + .trustManager(yourTrustManager) + .hostnameVerifier(yourHostnameVerifier) + .build(); +``` + ### Environments The SDK sends requests to the production by default. To send requests to a different environment, configure the client like so: diff --git a/build.gradle.kts b/build.gradle.kts index 65121943..80284fad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,19 @@ allprojects { version = "0.1.0-alpha.2" // x-release-please-version } +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } + apply(plugin = "org.jetbrains.dokka") +} + subprojects { apply(plugin = "org.jetbrains.dokka") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 778c89de..c6dc92ec 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,7 +10,6 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/hanzo.java.gradle.kts b/buildSrc/src/main/kotlin/hanzo.java.gradle.kts index dfbacb86..70fc33f4 100644 --- a/buildSrc/src/main/kotlin/hanzo.java.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.java.gradle.kts @@ -1,24 +1,13 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat plugins { `java-library` - id("com.diffplug.spotless") } repositories { mavenCentral() } -configure { - java { - importOrder() - removeUnusedImports() - palantirJavaFormat() - toggleOffOn() - } -} - java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -53,3 +42,86 @@ tasks.withType().configureEach { exceptionFormat = TestExceptionFormat.FULL } } + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts index 7408acaa..c86cd9f0 100644 --- a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -7,6 +6,10 @@ plugins { kotlin("jvm") } +repositories { + mavenCentral() +} + kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -27,14 +30,77 @@ kotlin { } } -configure { - kotlin { - ktfmt().kotlinlangStyle() - toggleOffOn() - } -} - tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") diff --git a/gradle.properties b/gradle.properties index ff76593f..6680f9ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,13 @@ org.gradle.parallel=true org.gradle.daemon=false # These options improve our compilation and test performance. They are inherited by the Kotlin daemon. org.gradle.jvmargs=\ - -Xms1g \ - -Xmx4g \ + -Xms2g \ + -Xmx8g \ -XX:+UseParallelGC \ -XX:InitialCodeCacheSize=256m \ -XX:ReservedCodeCacheSize=1G \ - -XX:MetaspaceSize=256m \ + -XX:MetaspaceSize=512m \ + -XX:MaxMetaspaceSize=2G \ -XX:TieredStopAtLevel=1 \ -XX:GCTimeRatio=4 \ -XX:CICompilerCount=4 \ diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt index c3534112..055cf4ab 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt @@ -7,19 +7,35 @@ import ai.hanzo.api.client.HanzoClientImpl import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.Timeout import ai.hanzo.api.core.http.Headers +import ai.hanzo.api.core.http.HttpClient import ai.hanzo.api.core.http.QueryParams +import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration - +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [HanzoClient] with [OkHttpClient] as the underlying + * [HttpClient]. + */ class HanzoOkHttpClient private constructor() { companion object { - /** Returns a mutable builder for constructing an instance of [HanzoOkHttpClient]. */ + /** Returns a mutable builder for constructing an instance of [HanzoClient]. */ @JvmStatic fun builder() = Builder() + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ @JvmStatic fun fromEnv(): HanzoClient = builder().fromEnv().build() } @@ -27,12 +43,63 @@ class HanzoOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) - fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) } + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } - fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -45,10 +112,86 @@ class HanzoOkHttpClient private constructor() { clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [ai.hanzo.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.hanzo.ai`. + * + * The following other environments, with dedicated builder methods, are available: + * - sandbox: `https://api.sandbox.hanzo.ai` + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** Sets [baseUrl] to `https://api.sandbox.hanzo.ai`. */ + fun sandbox() = apply { clientOptions.sandbox() } + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + /** The default name of the subscription key header of Azure */ + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } fun headers(headers: Map>) = apply { @@ -129,30 +272,11 @@ class HanzoOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } - /** - * Sets the maximum time allowed for a complete HTTP call, not including retries. + * Updates configuration using system properties and environment variables. * - * See [Timeout.request] for more details. - * - * For fine-grained control, pass a [Timeout] object. + * @see ClientOptions.Builder.fromEnv */ - fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } - - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } - - fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } - fun fromEnv() = apply { clientOptions.fromEnv() } /** @@ -163,7 +287,15 @@ class HanzoOkHttpClient private constructor() { fun build(): HanzoClient = HanzoClientImpl( clientOptions - .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) .build() ) } diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt index 26d03728..f97cf2b3 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt @@ -7,19 +7,35 @@ import ai.hanzo.api.client.HanzoClientAsyncImpl import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.Timeout import ai.hanzo.api.core.http.Headers +import ai.hanzo.api.core.http.HttpClient import ai.hanzo.api.core.http.QueryParams +import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration - +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [HanzoClientAsync] with [OkHttpClient] as the + * underlying [HttpClient]. + */ class HanzoOkHttpClientAsync private constructor() { companion object { - /** Returns a mutable builder for constructing an instance of [HanzoOkHttpClientAsync]. */ + /** Returns a mutable builder for constructing an instance of [HanzoClientAsync]. */ @JvmStatic fun builder() = Builder() + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ @JvmStatic fun fromEnv(): HanzoClientAsync = builder().fromEnv().build() } @@ -27,12 +43,63 @@ class HanzoOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) - fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) } + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } - fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -45,10 +112,86 @@ class HanzoOkHttpClientAsync private constructor() { clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [ai.hanzo.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.hanzo.ai`. + * + * The following other environments, with dedicated builder methods, are available: + * - sandbox: `https://api.sandbox.hanzo.ai` + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** Sets [baseUrl] to `https://api.sandbox.hanzo.ai`. */ + fun sandbox() = apply { clientOptions.sandbox() } + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + /** The default name of the subscription key header of Azure */ + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } fun headers(headers: Map>) = apply { @@ -129,30 +272,11 @@ class HanzoOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } - /** - * Sets the maximum time allowed for a complete HTTP call, not including retries. + * Updates configuration using system properties and environment variables. * - * See [Timeout.request] for more details. - * - * For fine-grained control, pass a [Timeout] object. + * @see ClientOptions.Builder.fromEnv */ - fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } - - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } - - fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } - fun fromEnv() = apply { clientOptions.fromEnv() } /** @@ -163,7 +287,15 @@ class HanzoOkHttpClientAsync private constructor() { fun build(): HanzoClientAsync = HanzoClientAsyncImpl( clientOptions - .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) .build() ) } diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt index fd37b7fa..53370f56 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt @@ -14,6 +14,9 @@ import java.io.InputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CompletableFuture +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback import okhttp3.HttpUrl.Companion.toHttpUrl @@ -191,6 +194,9 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null fun timeout(timeout: Timeout) = apply { this.timeout = timeout } @@ -198,6 +204,18 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() @@ -206,6 +224,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) + .apply { + val sslSocketFactory = sslSocketFactory + val trustManager = trustManager + if (sslSocketFactory != null && trustManager != null) { + sslSocketFactory(sslSocketFactory, trustManager) + } else { + check((sslSocketFactory != null) == (trustManager != null)) { + "Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set" + } + } + + hostnameVerifier?.let(::hostnameVerifier) + } .build() .apply { // We usually make all our requests to the same host so it makes sense to diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt index f5bc1079..8400c4d5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClient.kt @@ -192,17 +192,17 @@ interface HanzoClient { /** Home */ fun getHome(): ClientGetHomeResponse = getHome(ClientGetHomeParams.none()) - /** @see [getHome] */ + /** @see getHome */ fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ClientGetHomeResponse - /** @see [getHome] */ + /** @see getHome */ fun getHome(params: ClientGetHomeParams = ClientGetHomeParams.none()): ClientGetHomeResponse = getHome(params, RequestOptions.none()) - /** @see [getHome] */ + /** @see getHome */ fun getHome(requestOptions: RequestOptions): ClientGetHomeResponse = getHome(ClientGetHomeParams.none(), requestOptions) @@ -332,20 +332,20 @@ interface HanzoClient { @MustBeClosed fun getHome(): HttpResponseFor = getHome(ClientGetHomeParams.none()) - /** @see [getHome] */ + /** @see getHome */ @MustBeClosed fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [getHome] */ + /** @see getHome */ @MustBeClosed fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none() ): HttpResponseFor = getHome(params, RequestOptions.none()) - /** @see [getHome] */ + /** @see getHome */ @MustBeClosed fun getHome(requestOptions: RequestOptions): HttpResponseFor = getHome(ClientGetHomeParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt index 7677078f..7b73152f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsync.kt @@ -192,18 +192,18 @@ interface HanzoClientAsync { /** Home */ fun getHome(): CompletableFuture = getHome(ClientGetHomeParams.none()) - /** @see [getHome] */ + /** @see getHome */ fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [getHome] */ + /** @see getHome */ fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none() ): CompletableFuture = getHome(params, RequestOptions.none()) - /** @see [getHome] */ + /** @see getHome */ fun getHome(requestOptions: RequestOptions): CompletableFuture = getHome(ClientGetHomeParams.none(), requestOptions) @@ -333,19 +333,19 @@ interface HanzoClientAsync { fun getHome(): CompletableFuture> = getHome(ClientGetHomeParams.none()) - /** @see [getHome] */ + /** @see getHome */ fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [getHome] */ + /** @see getHome */ fun getHome( params: ClientGetHomeParams = ClientGetHomeParams.none() ): CompletableFuture> = getHome(params, RequestOptions.none()) - /** @see [getHome] */ + /** @see getHome */ fun getHome( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt index 3e323ad8..1441a129 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.client import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.getPackageVersion +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -417,12 +417,13 @@ class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClie // get / withRawResponse().getHome(params, requestOptions).thenApply { it.parse() } - override fun close() = clientOptions.httpClient.close() + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : HanzoClientAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val models: ModelServiceAsync.WithRawResponse by lazy { ModelServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -721,7 +722,6 @@ class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClie private val getHomeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun getHome( params: ClientGetHomeParams, @@ -738,7 +738,7 @@ class HanzoClientAsyncImpl(private val clientOptions: ClientOptions) : HanzoClie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { getHomeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt index b2890a0c..43e98b9f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/client/HanzoClientImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.client import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.getPackageVersion +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -370,12 +370,13 @@ class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { // get / withRawResponse().getHome(params, requestOptions).parse() - override fun close() = clientOptions.httpClient.close() + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : HanzoClient.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val models: ModelService.WithRawResponse by lazy { ModelServiceImpl.WithRawResponseImpl(clientOptions) @@ -674,7 +675,6 @@ class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { private val getHomeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun getHome( params: ClientGetHomeParams, @@ -689,7 +689,7 @@ class HanzoClientImpl(private val clientOptions: ClientOptions) : HanzoClient { .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { getHomeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt index b27c08f7..666c1e66 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt @@ -9,22 +9,81 @@ import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper import java.time.Clock +import java.time.Duration import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** A class representing the SDK client configuration. */ class ClientOptions private constructor( private val originalHttpClient: HttpClient, + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `hanzo-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee that + * the SDK will work correctly when using an incompatible Jackson version. + */ @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [ai.hanzo.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ @get:JvmName("clock") val clock: Clock, private val baseUrl: String?, + /** Headers to send with the request. */ @get:JvmName("headers") val headers: Headers, + /** Query params to send with the request. */ @get:JvmName("queryParams") val queryParams: QueryParams, + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ @get:JvmName("responseValidation") val responseValidation: Boolean, + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ @get:JvmName("timeout") val timeout: Timeout, + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ @get:JvmName("maxRetries") val maxRetries: Int, + /** The default name of the subscription key header of Azure */ @get:JvmName("apiKey") val apiKey: String, ) { @@ -34,6 +93,14 @@ private constructor( } } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.hanzo.ai`. + * + * The following other environments, with dedicated builder methods, are available: + * - sandbox: `https://api.sandbox.hanzo.ai` + */ fun baseUrl(): String = baseUrl ?: PRODUCTION_URL fun toBuilder() = Builder().from(this) @@ -55,6 +122,11 @@ private constructor( */ @JvmStatic fun builder() = Builder() + /** + * Returns options configured using system properties and environment variables. + * + * @see Builder.fromEnv + */ @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } @@ -88,31 +160,106 @@ private constructor( apiKey = clientOptions.apiKey } + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `hanzo-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ fun httpClient(httpClient: HttpClient) = apply { this.httpClient = PhantomReachableClosingHttpClient(httpClient) } + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility } + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [ai.hanzo.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ fun clock(clock: Clock) = apply { this.clock = clock } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.hanzo.ai`. + * + * The following other environments, with dedicated builder methods, are available: + * - sandbox: `https://api.sandbox.hanzo.ai` + */ fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** Sets [baseUrl] to `https://api.sandbox.hanzo.ai`. */ + fun sandbox() = baseUrl(SANDBOX_URL) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + /** The default name of the subscription key header of Azure */ fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } fun headers(headers: Headers) = apply { @@ -195,9 +342,27 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + fun timeout(): Timeout = timeout + + /** + * Updates configuration using system properties and environment variables. + * + * See this table for the available options: + * + * | Setter | System property | Environment variable | Required | Default value | + * |-----------|-----------------|----------------------|----------|--------------------------| + * | `apiKey` | `hanzo.apiKey` | `HANZO_API_KEY` | true | - | + * | `baseUrl` | `hanzo.baseUrl` | `HANZO_BASE_URL` | true | `"https://api.hanzo.ai"` | + * + * System properties take precedence over environment variables. + */ fun fromEnv() = apply { - System.getenv("HANZO_BASE_URL")?.let { baseUrl(it) } - System.getenv("HANZO_API_KEY")?.let { apiKey(it) } + (System.getProperty("hanzo.baseUrl") ?: System.getenv("HANZO_BASE_URL"))?.let { + baseUrl(it) + } + (System.getProperty("hanzo.apiKey") ?: System.getenv("HANZO_API_KEY"))?.let { + apiKey(it) + } } /** @@ -254,4 +419,18 @@ private constructor( ) } } + + /** + * Closes these client options, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client options are + * long-lived and usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default client automatically + * releases threads and connections if they remain idle, but if you are writing an application + * that needs to aggressively release unused resources, then you may call this method. + */ + fun close() { + httpClient.close() + } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableExecutorService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableExecutorService.kt new file mode 100644 index 00000000..a95108d7 --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableExecutorService.kt @@ -0,0 +1,58 @@ +package ai.hanzo.api.core + +import java.util.concurrent.Callable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +/** + * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom + * reachable. + * + * This class ensures the [ExecutorService] is shut down even if the user forgets to do it. + */ +internal class PhantomReachableExecutorService(private val executorService: ExecutorService) : + ExecutorService { + init { + closeWhenPhantomReachable(this) { executorService.shutdown() } + } + + override fun execute(command: Runnable) = executorService.execute(command) + + override fun shutdown() = executorService.shutdown() + + override fun shutdownNow(): MutableList = executorService.shutdownNow() + + override fun isShutdown(): Boolean = executorService.isShutdown + + override fun isTerminated(): Boolean = executorService.isTerminated + + override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean = + executorService.awaitTermination(timeout, unit) + + override fun submit(task: Callable): Future = executorService.submit(task) + + override fun submit(task: Runnable, result: T): Future = + executorService.submit(task, result) + + override fun submit(task: Runnable): Future<*> = executorService.submit(task) + + override fun invokeAll( + tasks: MutableCollection> + ): MutableList> = executorService.invokeAll(tasks) + + override fun invokeAll( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): MutableList> = executorService.invokeAll(tasks, timeout, unit) + + override fun invokeAny(tasks: MutableCollection>): T = + executorService.invokeAny(tasks) + + override fun invokeAny( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): T = executorService.invokeAny(tasks, timeout, unit) +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Timeout.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Timeout.kt index 844fb638..ba32882f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Timeout.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Timeout.kt @@ -157,10 +157,14 @@ private constructor( return true } - return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + return other is Timeout && + connect == other.connect && + read == other.read && + write == other.write && + request == other.request } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(connect, read, write, request) override fun toString() = "Timeout{connect=$connect, read=$read, write=$write, request=$request}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt index 57ae1e24..75457e0c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Utils.kt @@ -5,6 +5,8 @@ package ai.hanzo.api.core import ai.hanzo.api.errors.HanzoInvalidDataException import java.util.Collections import java.util.SortedMap +import java.util.concurrent.CompletableFuture +import java.util.concurrent.locks.Lock @JvmSynthetic internal fun T?.getOrThrow(name: String): T = @@ -90,3 +92,24 @@ internal fun Any?.contentToString(): String { } internal interface Enum + +/** + * Executes the given [action] while holding the lock, returning a [CompletableFuture] with the + * result. + * + * @param action The asynchronous action to execute while holding the lock + * @return A [CompletableFuture] that completes with the result of the action + */ +@JvmSynthetic +internal fun Lock.withLockAsync(action: () -> CompletableFuture): CompletableFuture { + lock() + val future = + try { + action() + } catch (e: Throwable) { + unlock() + throw e + } + future.whenComplete { _, _ -> unlock() } + return future +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/handlers/ErrorHandler.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/handlers/ErrorHandler.kt index d9b86af9..f3d71314 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/handlers/ErrorHandler.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/handlers/ErrorHandler.kt @@ -19,7 +19,7 @@ import ai.hanzo.api.errors.UnprocessableEntityException import com.fasterxml.jackson.databind.json.JsonMapper @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { val handler = jsonHandler(jsonMapper) return object : Handler { @@ -33,52 +33,52 @@ internal fun errorHandler(jsonMapper: JsonMapper): Handler { } @JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = - object : Handler { - override fun handle(response: HttpResponse): T = +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = when (val statusCode = response.statusCode()) { - in 200..299 -> this@withErrorHandler.handle(response) + in 200..299 -> response 400 -> throw BadRequestException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 401 -> throw UnauthorizedException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 403 -> throw PermissionDeniedException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 404 -> throw NotFoundException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 422 -> throw UnprocessableEntityException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 429 -> throw RateLimitException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() in 500..599 -> throw InternalServerException.builder() .statusCode(statusCode) .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() else -> throw UnexpectedStatusCodeException.builder() .statusCode(statusCode) .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/Headers.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/Headers.kt index 3958ec95..a05f1289 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/Headers.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/Headers.kt @@ -1,5 +1,15 @@ +// File generated from our OpenAPI spec by Stainless. + package ai.hanzo.api.core.http +import ai.hanzo.api.core.JsonArray +import ai.hanzo.api.core.JsonBoolean +import ai.hanzo.api.core.JsonMissing +import ai.hanzo.api.core.JsonNull +import ai.hanzo.api.core.JsonNumber +import ai.hanzo.api.core.JsonObject +import ai.hanzo.api.core.JsonString +import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.toImmutable import java.util.TreeMap @@ -28,6 +38,19 @@ private constructor( TreeMap(String.CASE_INSENSITIVE_ORDER) private var size: Int = 0 + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + fun put(name: String, value: String) = apply { map.getOrPut(name) { mutableListOf() }.add(value) size++ @@ -41,15 +64,6 @@ private constructor( headers.names().forEach { put(it, headers.values(it)) } } - fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } - - fun removeAll(names: Set) = apply { names.forEach(::remove) } - - fun clear() = apply { - map.clear() - size = 0 - } - fun replace(name: String, value: String) = apply { remove(name) put(name, value) @@ -68,6 +82,15 @@ private constructor( headers.names().forEach { replace(it, headers.values(it)) } } + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + fun build() = Headers( map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/QueryParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/QueryParams.kt index e788ffd5..a7b8d832 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/QueryParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/QueryParams.kt @@ -2,6 +2,14 @@ package ai.hanzo.api.core.http +import ai.hanzo.api.core.JsonArray +import ai.hanzo.api.core.JsonBoolean +import ai.hanzo.api.core.JsonMissing +import ai.hanzo.api.core.JsonNull +import ai.hanzo.api.core.JsonNumber +import ai.hanzo.api.core.JsonObject +import ai.hanzo.api.core.JsonString +import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.toImmutable class QueryParams @@ -28,6 +36,39 @@ private constructor( private val map: MutableMap> = mutableMapOf() private var size: Int = 0 + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> + put( + key, + value.values + .asSequence() + .mapNotNull { + when (it) { + is JsonMissing, + is JsonNull -> null + is JsonBoolean -> it.value.toString() + is JsonNumber -> it.value.toString() + is JsonString -> it.value + is JsonArray, + is JsonObject -> + throw IllegalArgumentException( + "Cannot comma separate non-primitives in query params" + ) + } + } + .joinToString(","), + ) + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + fun put(key: String, value: String) = apply { map.getOrPut(key) { mutableListOf() }.add(value) size++ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt index 6bc34a62..94e25251 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt @@ -3,6 +3,7 @@ package ai.hanzo.api.core.http import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired import ai.hanzo.api.errors.HanzoIoException +import ai.hanzo.api.errors.HanzoRetryableException import java.io.IOException import java.time.Clock import java.time.Duration @@ -176,9 +177,10 @@ private constructor( } private fun shouldRetry(throwable: Throwable): Boolean = - // Only retry IOException and HanzoIoException, other exceptions are not intended to be - // retried. - throwable is IOException || throwable is HanzoIoException + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is HanzoIoException || + throwable is HanzoRetryableException private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoRetryableException.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoRetryableException.kt new file mode 100644 index 00000000..2b70e060 --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/errors/HanzoRetryableException.kt @@ -0,0 +1,14 @@ +package ai.hanzo.api.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class HanzoRetryableException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : HanzoException(message, cause) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeParams.kt index 5e07583f..29954e1b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeParams.kt @@ -14,8 +14,10 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -156,10 +158,12 @@ private constructor( return true } - return /* spotless:off */ other is ClientGetHomeParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ClientGetHomeParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) override fun toString() = "ClientGetHomeParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt index 6816f8bc..6277927d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = ipAddress._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -185,10 +187,13 @@ private constructor( return true } - return /* spotless:off */ other is AddAddAllowedIpParams && ipAddress == other.ipAddress && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AddAddAllowedIpParams && + ipAddress == other.ipAddress && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ipAddress, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(ipAddress, additionalHeaders, additionalQueryParams) override fun toString() = "AddAddAllowedIpParams{ipAddress=$ipAddress, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt index 0ef48c7a..1af19043 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AnthropicCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AnthropicCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt index 8798b507..87982a4b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AnthropicDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AnthropicDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt index 48f6676e..cf32cc9e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicModifyParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AnthropicModifyParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AnthropicModifyParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt index 859ce1ca..8698a80a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -178,10 +180,13 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AnthropicRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "AnthropicRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt index 1d42fad7..68965318 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AnthropicUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AnthropicUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt index 437e0a8f..313fd3ac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is AssemblyaiCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AssemblyaiCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AssemblyaiCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt index 4675b00d..b9b025bd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is AssemblyaiDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AssemblyaiDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AssemblyaiDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt index 11cea0c1..6ce87bb3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is AssemblyaiPatchParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AssemblyaiPatchParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AssemblyaiPatchParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt index 5554e686..af025b96 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -178,10 +180,13 @@ private constructor( return true } - return /* spotless:off */ other is AssemblyaiRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AssemblyaiRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "AssemblyaiRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt index 1986819f..b91a66c2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is AssemblyaiUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AssemblyaiUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AssemblyaiUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt index d4c0fd9d..6a9dcce0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap, ) : Params { + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -197,10 +200,14 @@ private constructor( return true } - return /* spotless:off */ other is AssistantCreateParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AssistantCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AssistantCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt index d9944ba0..81a48b36 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(assistantId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,20 @@ private constructor( return true } - return /* spotless:off */ other is AssistantDeleteParams && assistantId == other.assistantId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AssistantDeleteParams && + assistantId == other.assistantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(assistantId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + assistantId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "AssistantDeleteParams{assistantId=$assistantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt index 74bae117..dec47c6d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap, ) : Params { + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -197,10 +200,14 @@ private constructor( return true } - return /* spotless:off */ other is SpeechCreateParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is SpeechCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "SpeechCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt index ba453f26..dec5703f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = body._file() + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -97,7 +105,26 @@ private constructor( fun file(file: ByteArray) = apply { body.file(file) } - fun file(file: Path) = apply { body.file(file) } + fun file(path: Path) = apply { body.file(path) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -217,13 +244,20 @@ private constructor( ) } - fun _body(): Map> = mapOf("file" to _file()).toImmutable() + fun _body(): Map> = + (mapOf("file" to _file()) + + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - class Body private constructor(private val file: MultipartField) { + class Body + private constructor( + private val file: MultipartField, + private val additionalProperties: MutableMap, + ) { /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is @@ -238,6 +272,16 @@ private constructor( */ @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) companion object { @@ -257,8 +301,13 @@ private constructor( class Builder internal constructor() { private var file: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmSynthetic internal fun from(body: Body) = apply { file = body.file } + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + additionalProperties = body.additionalProperties.toMutableMap() + } fun file(file: InputStream) = file(MultipartField.of(file)) @@ -273,14 +322,33 @@ private constructor( fun file(file: ByteArray) = file(file.inputStream()) - fun file(file: Path) = + fun file(path: Path) = file( MultipartField.builder() - .value(file.inputStream()) - .filename(file.name) + .value(path.inputStream()) + .filename(path.name) .build() ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** * Returns an immutable instance of [Body]. * @@ -293,7 +361,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Body = Body(checkRequired("file", file)) + fun build(): Body = + Body(checkRequired("file", file), additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -320,16 +389,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && file == other.file /* spotless:on */ + return other is Body && + file == other.file && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(file) } - /* spotless:on */ + private val hashCode: Int by lazy { Objects.hash(file, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "Body{file=$file}" + override fun toString() = "Body{file=$file, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -337,10 +406,13 @@ private constructor( return true } - return /* spotless:off */ other is TranscriptionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TranscriptionCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "TranscriptionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt index cb56315e..28ec798e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -178,10 +180,13 @@ private constructor( return true } - return /* spotless:off */ other is AzureCallParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is AzureCallParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "AzureCallParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt index 9d8152f3..83306012 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is AzureCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AzureCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AzureCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt index 616f7d7b..95e22457 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is AzureDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AzureDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AzureDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt index 850962d1..46fd0416 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is AzurePatchParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AzurePatchParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AzurePatchParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt index 167b58bc..95df70ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is AzureUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is AzureUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "AzureUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt index 9c096670..67d94884 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(batchId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -247,10 +250,22 @@ private constructor( return true } - return /* spotless:off */ other is BatchCancelWithProviderParams && provider == other.provider && batchId == other.batchId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BatchCancelWithProviderParams && + provider == other.provider && + batchId == other.batchId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, batchId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + provider, + batchId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "BatchCancelWithProviderParams{provider=$provider, batchId=$batchId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt index eabb34ce..fb013579 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt @@ -107,12 +107,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(provider) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -225,10 +228,15 @@ private constructor( return true } - return /* spotless:off */ other is BatchCreateParams && provider == other.provider && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BatchCreateParams && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "BatchCreateParams{provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt index 3665dba6..1022f081 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(provider) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -229,10 +232,15 @@ private constructor( return true } - return /* spotless:off */ other is BatchCreateWithProviderParams && provider == other.provider && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BatchCreateWithProviderParams && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "BatchCreateWithProviderParams{provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt index f033757d..7fd0faa0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt @@ -107,12 +107,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(provider) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -218,10 +220,16 @@ private constructor( return true } - return /* spotless:off */ other is BatchListParams && after == other.after && limit == other.limit && provider == other.provider && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BatchListParams && + after == other.after && + limit == other.limit && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(after, limit, provider, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(after, limit, provider, additionalHeaders, additionalQueryParams) override fun toString() = "BatchListParams{after=$after, limit=$limit, provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt index fe58179d..7efca222 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(limit) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -225,10 +227,16 @@ private constructor( return true } - return /* spotless:off */ other is BatchListWithProviderParams && provider == other.provider && after == other.after && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BatchListWithProviderParams && + provider == other.provider && + after == other.after && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, after, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, after, limit, additionalHeaders, additionalQueryParams) override fun toString() = "BatchListWithProviderParams{provider=$provider, after=$after, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt index bf947806..0a898998 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt @@ -105,12 +105,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(provider) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -206,10 +208,15 @@ private constructor( return true } - return /* spotless:off */ other is BatchRetrieveParams && batchId == other.batchId && provider == other.provider && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BatchRetrieveParams && + batchId == other.batchId && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(batchId, provider, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(batchId, provider, additionalHeaders, additionalQueryParams) override fun toString() = "BatchRetrieveParams{batchId=$batchId, provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt index a4bb9bc5..4957afcf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(batchId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -214,10 +216,15 @@ private constructor( return true } - return /* spotless:off */ other is BatchRetrieveWithProviderParams && provider == other.provider && batchId == other.batchId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BatchRetrieveWithProviderParams && + provider == other.provider && + batchId == other.batchId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, batchId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, batchId, additionalHeaders, additionalQueryParams) override fun toString() = "BatchRetrieveWithProviderParams{provider=$provider, batchId=$batchId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt index 7a2ae6cd..6f66fd13 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt @@ -107,12 +107,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(provider) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -240,10 +243,22 @@ private constructor( return true } - return /* spotless:off */ other is CancelCancelParams && batchId == other.batchId && provider == other.provider && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CancelCancelParams && + batchId == other.batchId && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(batchId, provider, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + batchId, + provider, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "CancelCancelParams{batchId=$batchId, provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt index 488ce404..62e780a0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is BedrockCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BedrockCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "BedrockCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt index d35b2616..34ccbe81 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is BedrockDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BedrockDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "BedrockDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt index 68c35336..3d37e3e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is BedrockPatchParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BedrockPatchParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "BedrockPatchParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt index 2648f983..3e7dd8b6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -178,10 +180,13 @@ private constructor( return true } - return /* spotless:off */ other is BedrockRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BedrockRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "BedrockRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt index 3026c45b..cd0f70c5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is BedrockUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is BedrockUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "BedrockUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt index c13ea381..91389aba 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = budgetNew._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -199,10 +201,13 @@ private constructor( return true } - return /* spotless:off */ other is BudgetCreateParams && budgetNew == other.budgetNew && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BudgetCreateParams && + budgetNew == other.budgetNew && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(budgetNew, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(budgetNew, additionalHeaders, additionalQueryParams) override fun toString() = "BudgetCreateParams{budgetNew=$budgetNew, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt index c9d5fd4d..8b15401a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -379,12 +381,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + id == other.id && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -396,10 +398,13 @@ private constructor( return true } - return /* spotless:off */ other is BudgetDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BudgetDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "BudgetDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt index b75f2fa5..52fe4c11 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -406,12 +408,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && budgets == other.budgets && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + budgets == other.budgets && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(budgets, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -424,10 +426,13 @@ private constructor( return true } - return /* spotless:off */ other is BudgetInfoParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BudgetInfoParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "BudgetInfoParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt index 2abbd940..2db389d7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = budgetNew._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -199,10 +201,13 @@ private constructor( return true } - return /* spotless:off */ other is BudgetUpdateParams && budgetNew == other.budgetNew && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is BudgetUpdateParams && + budgetNew == other.budgetNew && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(budgetNew, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(budgetNew, additionalHeaders, additionalQueryParams) override fun toString() = "BudgetUpdateParams{budgetNew=$budgetNew, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt index 11709b4a..e384628f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap, ) : Params { + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -204,10 +207,14 @@ private constructor( return true } - return /* spotless:off */ other is CacheDeleteParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CacheDeleteParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CacheDeleteParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt index 456396a7..d261d171 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap, ) : Params { + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -202,10 +205,14 @@ private constructor( return true } - return /* spotless:off */ other is CacheFlushAllParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CacheFlushAllParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CacheFlushAllParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt index 56d9449a..27ef8e73 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -230,10 +233,15 @@ private constructor( return true } - return /* spotless:off */ other is CompletionCreateParams && model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CompletionCreateParams && + model == other.model && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CompletionCreateParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt index cb649346..e906230c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CohereCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CohereCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CohereCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt index 3bf2f225..03828d25 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CohereDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CohereDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CohereDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt index 140205a3..3be17d7b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CohereModifyParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CohereModifyParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CohereModifyParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt index f7b9d628..4fa7a92d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -174,10 +176,13 @@ private constructor( return true } - return /* spotless:off */ other is CohereRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CohereRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "CohereRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt index 24dc77c2..8be1c2c9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is CohereUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CohereUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CohereUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt index 5baaab7e..2fced519 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -227,10 +230,15 @@ private constructor( return true } - return /* spotless:off */ other is CompletionCreateParams && model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CompletionCreateParams && + model == other.model && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "CompletionCreateParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt index 187459b8..fa0ebb4e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = passThroughGenericEndpoint._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -193,10 +195,14 @@ private constructor( return true } - return /* spotless:off */ other is PassThroughEndpointCreateParams && passThroughGenericEndpoint == other.passThroughGenericEndpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PassThroughEndpointCreateParams && + passThroughGenericEndpoint == other.passThroughGenericEndpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(passThroughGenericEndpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(passThroughGenericEndpoint, additionalHeaders, additionalQueryParams) override fun toString() = "PassThroughEndpointCreateParams{passThroughGenericEndpoint=$passThroughGenericEndpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt index c32701ee..939646a8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt @@ -107,12 +107,11 @@ private constructor(private val additionalProperties: MutableMap = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -228,10 +231,15 @@ private constructor( return true } - return /* spotless:off */ other is PassThroughEndpointDeleteParams && endpointId == other.endpointId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is PassThroughEndpointDeleteParams && + endpointId == other.endpointId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpointId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpointId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "PassThroughEndpointDeleteParams{endpointId=$endpointId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt index 470e8768..f1b556f7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt @@ -23,8 +23,10 @@ private constructor( fun endpointId(): Optional = Optional.ofNullable(endpointId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -185,10 +187,14 @@ private constructor( return true } - return /* spotless:off */ other is PassThroughEndpointListParams && endpointId == other.endpointId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is PassThroughEndpointListParams && + endpointId == other.endpointId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpointId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpointId, additionalHeaders, additionalQueryParams) override fun toString() = "PassThroughEndpointListParams{endpointId=$endpointId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt index 29ef5296..166367b3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt @@ -180,12 +180,12 @@ private constructor( return true } - return /* spotless:off */ other is PassThroughEndpointResponse && endpoints == other.endpoints && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PassThroughEndpointResponse && + endpoints == other.endpoints && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(endpoints, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt index e220c644..aab89b1f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt @@ -22,10 +22,13 @@ private constructor( fun endpointId(): Optional = Optional.ofNullable(endpointId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -217,10 +220,15 @@ private constructor( return true } - return /* spotless:off */ other is PassThroughEndpointUpdateParams && endpointId == other.endpointId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is PassThroughEndpointUpdateParams && + endpointId == other.endpointId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpointId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpointId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "PassThroughEndpointUpdateParams{endpointId=$endpointId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt index 09b22392..a45f0251 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt @@ -107,12 +107,11 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -505,13 +507,24 @@ private constructor( return true } - return /* spotless:off */ other is Body && credentialInfo == other.credentialInfo && credentialName == other.credentialName && credentialValues == other.credentialValues && modelId == other.modelId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + credentialInfo == other.credentialInfo && + credentialName == other.credentialName && + credentialValues == other.credentialValues && + modelId == other.modelId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + credentialInfo, + credentialName, + credentialValues, + modelId, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(credentialInfo, credentialName, credentialValues, modelId, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -523,10 +536,13 @@ private constructor( return true } - return /* spotless:off */ other is CredentialCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CredentialCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CredentialCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt index 4de2ce8a..35904cd5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(credentialName) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -213,10 +216,20 @@ private constructor( return true } - return /* spotless:off */ other is CredentialDeleteParams && credentialName == other.credentialName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CredentialDeleteParams && + credentialName == other.credentialName && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(credentialName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + credentialName, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "CredentialDeleteParams{credentialName=$credentialName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt index 6861b51d..158ce984 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = blockUsers._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -195,10 +197,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBlockParams && blockUsers == other.blockUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerBlockParams && + blockUsers == other.blockUsers && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(blockUsers, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(blockUsers, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerBlockParams{blockUsers=$blockUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt index 0c9b5747..d1ecd5ab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -1383,12 +1385,41 @@ private constructor( return true } - return /* spotless:off */ other is Body && userId == other.userId && alias == other.alias && allowedModelRegion == other.allowedModelRegion && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetId == other.budgetId && defaultModel == other.defaultModel && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && modelMaxBudget == other.modelMaxBudget && rpmLimit == other.rpmLimit && softBudget == other.softBudget && tpmLimit == other.tpmLimit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + userId == other.userId && + alias == other.alias && + allowedModelRegion == other.allowedModelRegion && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + budgetId == other.budgetId && + defaultModel == other.defaultModel && + maxBudget == other.maxBudget && + maxParallelRequests == other.maxParallelRequests && + modelMaxBudget == other.modelMaxBudget && + rpmLimit == other.rpmLimit && + softBudget == other.softBudget && + tpmLimit == other.tpmLimit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(userId, alias, allowedModelRegion, blocked, budgetDuration, budgetId, defaultModel, maxBudget, maxParallelRequests, modelMaxBudget, rpmLimit, softBudget, tpmLimit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + userId, + alias, + allowedModelRegion, + blocked, + budgetDuration, + budgetId, + defaultModel, + maxBudget, + maxParallelRequests, + modelMaxBudget, + rpmLimit, + softBudget, + tpmLimit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1517,7 +1548,7 @@ private constructor( return true } - return /* spotless:off */ other is AllowedModelRegion && value == other.value /* spotless:on */ + return other is AllowedModelRegion && value == other.value } override fun hashCode() = value.hashCode() @@ -1618,12 +1649,10 @@ private constructor( return true } - return /* spotless:off */ other is ModelMaxBudget && additionalProperties == other.additionalProperties /* spotless:on */ + return other is ModelMaxBudget && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -1635,10 +1664,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt index 5d50d7fd..ba38f348 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -420,12 +422,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && userIds == other.userIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + userIds == other.userIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(userIds, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -438,10 +440,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt index 83a4efa1..5fa87808 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = blockUsers._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -197,10 +199,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerUnblockParams && blockUsers == other.blockUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerUnblockParams && + blockUsers == other.blockUsers && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(blockUsers, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(blockUsers, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerUnblockParams{blockUsers=$blockUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt index da1d884d..d3cb4676 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -828,13 +830,30 @@ private constructor( return true } - return /* spotless:off */ other is Body && userId == other.userId && alias == other.alias && allowedModelRegion == other.allowedModelRegion && blocked == other.blocked && budgetId == other.budgetId && defaultModel == other.defaultModel && maxBudget == other.maxBudget && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + userId == other.userId && + alias == other.alias && + allowedModelRegion == other.allowedModelRegion && + blocked == other.blocked && + budgetId == other.budgetId && + defaultModel == other.defaultModel && + maxBudget == other.maxBudget && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + userId, + alias, + allowedModelRegion, + blocked, + budgetId, + defaultModel, + maxBudget, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(userId, alias, allowedModelRegion, blocked, budgetId, defaultModel, maxBudget, additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = @@ -962,7 +981,7 @@ private constructor( return true } - return /* spotless:off */ other is AllowedModelRegion && value == other.value /* spotless:on */ + return other is AllowedModelRegion && value == other.value } override fun hashCode() = value.hashCode() @@ -975,10 +994,13 @@ private constructor( return true } - return /* spotless:off */ other is CustomerUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CustomerUpdateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "CustomerUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt index 4f5da83b..dd29bfdb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = ipAddress._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -186,10 +188,13 @@ private constructor( return true } - return /* spotless:off */ other is DeleteCreateAllowedIpParams && ipAddress == other.ipAddress && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is DeleteCreateAllowedIpParams && + ipAddress == other.ipAddress && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ipAddress, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(ipAddress, additionalHeaders, additionalQueryParams) override fun toString() = "DeleteCreateAllowedIpParams{ipAddress=$ipAddress, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt index b412bc8e..5319d639 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt @@ -105,12 +105,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -224,10 +227,15 @@ private constructor( return true } - return /* spotless:off */ other is EmbeddingCreateParams && model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EmbeddingCreateParams && + model == other.model && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EmbeddingCreateParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt index ed4c3cec..44f6322a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -226,10 +229,15 @@ private constructor( return true } - return /* spotless:off */ other is EngineCompleteParams && model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EngineCompleteParams && + model == other.model && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EngineCompleteParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt index 19dedc96..6deec33c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -224,10 +227,15 @@ private constructor( return true } - return /* spotless:off */ other is EngineEmbedParams && model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EngineEmbedParams && + model == other.model && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EngineEmbedParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt index 0a058601..b36e5362 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -229,10 +232,15 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompleteParams && model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is ChatCompleteParams && + model == other.model && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "ChatCompleteParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt index 85f4265f..f792e9e5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is EuAssemblyaiCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EuAssemblyaiCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EuAssemblyaiCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt index 099b4f34..b640a32c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is EuAssemblyaiDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EuAssemblyaiDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EuAssemblyaiDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt index 9a2ba763..06392ead 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is EuAssemblyaiPatchParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EuAssemblyaiPatchParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EuAssemblyaiPatchParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt index f24ec4ed..cd83fcf3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -180,10 +182,13 @@ private constructor( return true } - return /* spotless:off */ other is EuAssemblyaiRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is EuAssemblyaiRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "EuAssemblyaiRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt index 8e7cebe4..ac3c6450 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is EuAssemblyaiUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is EuAssemblyaiUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "EuAssemblyaiUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt index b66f1351..889599e6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt @@ -104,12 +104,11 @@ private constructor(private val additionalProperties: MutableMap = body._customLlmProvider() + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -147,7 +155,7 @@ private constructor( fun file(file: ByteArray) = apply { body.file(file) } - fun file(file: Path) = apply { body.file(file) } + fun file(path: Path) = apply { body.file(path) } fun purpose(purpose: String) = apply { body.purpose(purpose) } @@ -174,6 +182,25 @@ private constructor( body.customLlmProvider(customLlmProvider) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -295,11 +322,11 @@ private constructor( } fun _body(): Map> = - mapOf( + (mapOf( "file" to _file(), "purpose" to _purpose(), "custom_llm_provider" to _customLlmProvider(), - ) + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() fun _pathParam(index: Int): String = @@ -317,6 +344,7 @@ private constructor( private val file: MultipartField, private val purpose: MultipartField, private val customLlmProvider: MultipartField, + private val additionalProperties: MutableMap, ) { /** @@ -363,6 +391,16 @@ private constructor( @ExcludeMissing fun _customLlmProvider(): MultipartField = customLlmProvider + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) companion object { @@ -385,12 +423,14 @@ private constructor( private var file: MultipartField? = null private var purpose: MultipartField? = null private var customLlmProvider: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { file = body.file purpose = body.purpose customLlmProvider = body.customLlmProvider + additionalProperties = body.additionalProperties.toMutableMap() } fun file(file: InputStream) = file(MultipartField.of(file)) @@ -406,11 +446,11 @@ private constructor( fun file(file: ByteArray) = file(file.inputStream()) - fun file(file: Path) = + fun file(path: Path) = file( MultipartField.builder() - .value(file.inputStream()) - .filename(file.name) + .value(path.inputStream()) + .filename(path.name) .build() ) @@ -439,6 +479,25 @@ private constructor( this.customLlmProvider = customLlmProvider } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** * Returns an immutable instance of [Body]. * @@ -457,6 +516,7 @@ private constructor( checkRequired("file", file), checkRequired("purpose", purpose), customLlmProvider, + additionalProperties.toMutableMap(), ) } @@ -486,17 +546,21 @@ private constructor( return true } - return /* spotless:off */ other is Body && file == other.file && purpose == other.purpose && customLlmProvider == other.customLlmProvider /* spotless:on */ + return other is Body && + file == other.file && + purpose == other.purpose && + customLlmProvider == other.customLlmProvider && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(file, purpose, customLlmProvider) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(file, purpose, customLlmProvider, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{file=$file, purpose=$purpose, customLlmProvider=$customLlmProvider}" + "Body{file=$file, purpose=$purpose, customLlmProvider=$customLlmProvider, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -504,10 +568,15 @@ private constructor( return true } - return /* spotless:off */ other is FileCreateParams && provider == other.provider && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is FileCreateParams && + provider == other.provider && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, body, additionalHeaders, additionalQueryParams) override fun toString() = "FileCreateParams{provider=$provider, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt index 7aa92277..34515f3d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(fileId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -245,10 +248,22 @@ private constructor( return true } - return /* spotless:off */ other is FileDeleteParams && provider == other.provider && fileId == other.fileId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is FileDeleteParams && + provider == other.provider && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, fileId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + provider, + fileId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "FileDeleteParams{provider=$provider, fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt index 727cc853..d80f8800 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(purpose) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -207,10 +209,15 @@ private constructor( return true } - return /* spotless:off */ other is FileListParams && provider == other.provider && purpose == other.purpose && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is FileListParams && + provider == other.provider && + purpose == other.purpose && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, purpose, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, purpose, additionalHeaders, additionalQueryParams) override fun toString() = "FileListParams{provider=$provider, purpose=$purpose, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt index 36bc41ea..a50a3255 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(fileId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -212,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is FileRetrieveParams && provider == other.provider && fileId == other.fileId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is FileRetrieveParams && + provider == other.provider && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, fileId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, fileId, additionalHeaders, additionalQueryParams) override fun toString() = "FileRetrieveParams{provider=$provider, fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt index 51b6fded..ea252d34 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(fileId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -213,10 +215,15 @@ private constructor( return true } - return /* spotless:off */ other is ContentRetrieveParams && provider == other.provider && fileId == other.fileId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ContentRetrieveParams && + provider == other.provider && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(provider, fileId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(provider, fileId, additionalHeaders, additionalQueryParams) override fun toString() = "ContentRetrieveParams{provider=$provider, fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt index 9efa1241..0a6cc944 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -939,12 +941,31 @@ private constructor( return true } - return /* spotless:off */ other is Body && customLlmProvider == other.customLlmProvider && model == other.model && trainingFile == other.trainingFile && hyperparameters == other.hyperparameters && integrations == other.integrations && seed == other.seed && suffix == other.suffix && validationFile == other.validationFile && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + customLlmProvider == other.customLlmProvider && + model == other.model && + trainingFile == other.trainingFile && + hyperparameters == other.hyperparameters && + integrations == other.integrations && + seed == other.seed && + suffix == other.suffix && + validationFile == other.validationFile && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(customLlmProvider, model, trainingFile, hyperparameters, integrations, seed, suffix, validationFile, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + customLlmProvider, + model, + trainingFile, + hyperparameters, + integrations, + seed, + suffix, + validationFile, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1078,7 +1099,7 @@ private constructor( return true } - return /* spotless:off */ other is CustomLlmProvider && value == other.value /* spotless:on */ + return other is CustomLlmProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -1404,10 +1425,10 @@ private constructor( return true } - return /* spotless:off */ other is BatchSize && string == other.string && integer == other.integer /* spotless:on */ + return other is BatchSize && string == other.string && integer == other.integer } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, integer) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, integer) override fun toString(): String = when { @@ -1574,10 +1595,12 @@ private constructor( return true } - return /* spotless:off */ other is LearningRateMultiplier && string == other.string && number == other.number /* spotless:on */ + return other is LearningRateMultiplier && + string == other.string && + number == other.number } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, number) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, number) override fun toString(): String = when { @@ -1746,10 +1769,10 @@ private constructor( return true } - return /* spotless:off */ other is NEpochs && string == other.string && integer == other.integer /* spotless:on */ + return other is NEpochs && string == other.string && integer == other.integer } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, integer) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, integer) override fun toString(): String = when { @@ -1843,12 +1866,16 @@ private constructor( return true } - return /* spotless:off */ other is Hyperparameters && batchSize == other.batchSize && learningRateMultiplier == other.learningRateMultiplier && nEpochs == other.nEpochs && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Hyperparameters && + batchSize == other.batchSize && + learningRateMultiplier == other.learningRateMultiplier && + nEpochs == other.nEpochs && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(batchSize, learningRateMultiplier, nEpochs, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(batchSize, learningRateMultiplier, nEpochs, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -1861,10 +1888,13 @@ private constructor( return true } - return /* spotless:off */ other is JobCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is JobCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "JobCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt index 0231974a..0d29be44 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(limit) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -348,7 +350,7 @@ private constructor( return true } - return /* spotless:off */ other is CustomLlmProvider && value == other.value /* spotless:on */ + return other is CustomLlmProvider && value == other.value } override fun hashCode() = value.hashCode() @@ -361,10 +363,16 @@ private constructor( return true } - return /* spotless:off */ other is JobListParams && customLlmProvider == other.customLlmProvider && after == other.after && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is JobListParams && + customLlmProvider == other.customLlmProvider && + after == other.after && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customLlmProvider, after, limit, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(customLlmProvider, after, limit, additionalHeaders, additionalQueryParams) override fun toString() = "JobListParams{customLlmProvider=$customLlmProvider, after=$after, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt index 45b5f498..21d303e8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(fineTuningJobId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -223,10 +226,20 @@ private constructor( return true } - return /* spotless:off */ other is CancelCreateParams && fineTuningJobId == other.fineTuningJobId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is CancelCreateParams && + fineTuningJobId == other.fineTuningJobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(fineTuningJobId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash( + fineTuningJobId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = "CancelCreateParams{fineTuningJobId=$fineTuningJobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt index e52e9ffc..d48f9c1f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is GeminiCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is GeminiCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "GeminiCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt index 5abbe8fa..00eda08f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is GeminiDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is GeminiDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "GeminiDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt index 6e6d0d4a..d6ffe9f2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is GeminiPatchParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is GeminiPatchParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "GeminiPatchParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt index 3bc27e34..9755e577 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -174,10 +176,13 @@ private constructor( return true } - return /* spotless:off */ other is GeminiRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is GeminiRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "GeminiRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt index 3a7b7059..9101df4d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -211,10 +214,15 @@ private constructor( return true } - return /* spotless:off */ other is GeminiUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is GeminiUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "GeminiUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt index a0a89409..7e570314 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(tags) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -221,10 +223,16 @@ private constructor( return true } - return /* spotless:off */ other is SpendListTagsParams && endDate == other.endDate && startDate == other.startDate && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is SpendListTagsParams && + endDate == other.endDate && + startDate == other.startDate && + tags == other.tags && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endDate, startDate, tags, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endDate, startDate, tags, additionalHeaders, additionalQueryParams) override fun toString() = "SpendListTagsParams{endDate=$endDate, startDate=$startDate, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt index 0f10c99e..30816906 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt @@ -11,6 +11,7 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow +import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -914,10 +915,10 @@ private constructor( return true } - return /* spotless:off */ other is EndTime && string == other.string && offsetDate == other.offsetDate /* spotless:on */ + return other is EndTime && string == other.string && offsetDate == other.offsetDate } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, offsetDate) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, offsetDate) override fun toString(): String = when { @@ -1096,10 +1097,13 @@ private constructor( return true } - return /* spotless:off */ other is Messages && string == other.string && jsonValues == other.jsonValues && jsonValue == other.jsonValue /* spotless:on */ + return other is Messages && + string == other.string && + jsonValues == other.jsonValues && + jsonValue == other.jsonValue } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, jsonValue) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, jsonValues, jsonValue) override fun toString(): String = when { @@ -1115,7 +1119,8 @@ private constructor( @JvmStatic fun ofString(string: String) = Messages(string = string) @JvmStatic - fun ofJsonValues(jsonValues: List) = Messages(jsonValues = jsonValues) + fun ofJsonValues(jsonValues: List) = + Messages(jsonValues = jsonValues.toImmutable()) @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Messages(jsonValue = jsonValue) } @@ -1287,10 +1292,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && string == other.string && jsonValues == other.jsonValues && jsonValue == other.jsonValue /* spotless:on */ + return other is Response && + string == other.string && + jsonValues == other.jsonValues && + jsonValue == other.jsonValue } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, jsonValue) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, jsonValues, jsonValue) override fun toString(): String = when { @@ -1306,7 +1314,8 @@ private constructor( @JvmStatic fun ofString(string: String) = Response(string = string) @JvmStatic - fun ofJsonValues(jsonValues: List) = Response(jsonValues = jsonValues) + fun ofJsonValues(jsonValues: List) = + Response(jsonValues = jsonValues.toImmutable()) @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Response(jsonValue = jsonValue) } @@ -1466,10 +1475,10 @@ private constructor( return true } - return /* spotless:off */ other is StartTime && string == other.string && offsetDate == other.offsetDate /* spotless:on */ + return other is StartTime && string == other.string && offsetDate == other.offsetDate } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, offsetDate) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, offsetDate) override fun toString(): String = when { @@ -1563,12 +1572,53 @@ private constructor( return true } - return /* spotless:off */ other is SpendListTagsResponse && apiKey == other.apiKey && callType == other.callType && endTime == other.endTime && messages == other.messages && requestId == other.requestId && response == other.response && startTime == other.startTime && apiBase == other.apiBase && cacheHit == other.cacheHit && cacheKey == other.cacheKey && completionTokens == other.completionTokens && metadata == other.metadata && model == other.model && promptTokens == other.promptTokens && requestTags == other.requestTags && requesterIpAddress == other.requesterIpAddress && spend == other.spend && totalTokens == other.totalTokens && user == other.user && additionalProperties == other.additionalProperties /* spotless:on */ + return other is SpendListTagsResponse && + apiKey == other.apiKey && + callType == other.callType && + endTime == other.endTime && + messages == other.messages && + requestId == other.requestId && + response == other.response && + startTime == other.startTime && + apiBase == other.apiBase && + cacheHit == other.cacheHit && + cacheKey == other.cacheKey && + completionTokens == other.completionTokens && + metadata == other.metadata && + model == other.model && + promptTokens == other.promptTokens && + requestTags == other.requestTags && + requesterIpAddress == other.requesterIpAddress && + spend == other.spend && + totalTokens == other.totalTokens && + user == other.user && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(apiKey, callType, endTime, messages, requestId, response, startTime, apiBase, cacheHit, cacheKey, completionTokens, metadata, model, promptTokens, requestTags, requesterIpAddress, spend, totalTokens, user, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + apiKey, + callType, + endTime, + messages, + requestId, + response, + startTime, + apiBase, + cacheHit, + cacheKey, + completionTokens, + metadata, + model, + promptTokens, + requestTags, + requesterIpAddress, + spend, + totalTokens, + user, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt index 8f8fbb4b..68a3920a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt @@ -25,10 +25,13 @@ private constructor( private val additionalBodyProperties: Map, ) : Params { + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -200,10 +203,14 @@ private constructor( return true } - return /* spotless:off */ other is SpendResetParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is SpendResetParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "SpendResetParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt index ae399cac..7ebe12b8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(userId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -202,10 +204,15 @@ private constructor( return true } - return /* spotless:off */ other is TeamListParams && organizationId == other.organizationId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TeamListParams && + organizationId == other.organizationId && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, userId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(organizationId, userId, additionalHeaders, additionalQueryParams) override fun toString() = "TeamListParams{organizationId=$organizationId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt index 5d3069ba..de4aca74 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -523,12 +525,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && teamId == other.teamId && userEmail == other.userEmail && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + teamId == other.teamId && + userEmail == other.userEmail && + userId == other.userId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(teamId, userEmail, userId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(teamId, userEmail, userId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -541,10 +547,13 @@ private constructor( return true } - return /* spotless:off */ other is TeamRemoveMemberParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TeamRemoveMemberParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "TeamRemoveMemberParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt index 508fdea7..8322bfea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(teamId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -185,10 +187,13 @@ private constructor( return true } - return /* spotless:off */ other is TeamRetrieveInfoParams && teamId == other.teamId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TeamRetrieveInfoParams && + teamId == other.teamId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(teamId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(teamId, additionalHeaders, additionalQueryParams) override fun toString() = "TeamRetrieveInfoParams{teamId=$teamId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt index 393e4982..417a6003 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = blockTeamRequest._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -200,10 +202,14 @@ private constructor( return true } - return /* spotless:off */ other is TeamUnblockParams && blockTeamRequest == other.blockTeamRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TeamUnblockParams && + blockTeamRequest == other.blockTeamRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(blockTeamRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(blockTeamRequest, additionalHeaders, additionalQueryParams) override fun toString() = "TeamUnblockParams{blockTeamRequest=$blockTeamRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt index 97020f4a..5ac3ccef 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -665,12 +667,18 @@ private constructor( return true } - return /* spotless:off */ other is Body && teamId == other.teamId && maxBudgetInTeam == other.maxBudgetInTeam && role == other.role && userEmail == other.userEmail && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + teamId == other.teamId && + maxBudgetInTeam == other.maxBudgetInTeam && + role == other.role && + userEmail == other.userEmail && + userId == other.userId && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(teamId, maxBudgetInTeam, role, userEmail, userId, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(teamId, maxBudgetInTeam, role, userEmail, userId, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -794,7 +802,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return other is Role && value == other.value } override fun hashCode() = value.hashCode() @@ -807,10 +815,13 @@ private constructor( return true } - return /* spotless:off */ other is TeamUpdateMemberParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TeamUpdateMemberParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "TeamUpdateMemberParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt index cbb239de..e826a737 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt @@ -274,12 +274,17 @@ private constructor( return true } - return /* spotless:off */ other is TeamUpdateMemberResponse && teamId == other.teamId && userId == other.userId && maxBudgetInTeam == other.maxBudgetInTeam && userEmail == other.userEmail && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TeamUpdateMemberResponse && + teamId == other.teamId && + userId == other.userId && + maxBudgetInTeam == other.maxBudgetInTeam && + userEmail == other.userEmail && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(teamId, userId, maxBudgetInTeam, userEmail, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(teamId, userId, maxBudgetInTeam, userEmail, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt index 74d8d82c..a8809648 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt @@ -233,8 +233,10 @@ private constructor( fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -1272,12 +1274,41 @@ private constructor( return true } - return /* spotless:off */ other is Body && teamId == other.teamId && blocked == other.blocked && budgetDuration == other.budgetDuration && guardrails == other.guardrails && maxBudget == other.maxBudget && metadata == other.metadata && modelAliases == other.modelAliases && models == other.models && organizationId == other.organizationId && rpmLimit == other.rpmLimit && tags == other.tags && teamAlias == other.teamAlias && tpmLimit == other.tpmLimit && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + teamId == other.teamId && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + guardrails == other.guardrails && + maxBudget == other.maxBudget && + metadata == other.metadata && + modelAliases == other.modelAliases && + models == other.models && + organizationId == other.organizationId && + rpmLimit == other.rpmLimit && + tags == other.tags && + teamAlias == other.teamAlias && + tpmLimit == other.tpmLimit && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(teamId, blocked, budgetDuration, guardrails, maxBudget, metadata, modelAliases, models, organizationId, rpmLimit, tags, teamAlias, tpmLimit, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + teamId, + blocked, + budgetDuration, + guardrails, + maxBudget, + metadata, + modelAliases, + models, + organizationId, + rpmLimit, + tags, + teamAlias, + tpmLimit, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1290,10 +1321,15 @@ private constructor( return true } - return /* spotless:off */ other is TeamUpdateParams && llmChangedBy == other.llmChangedBy && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is TeamUpdateParams && + llmChangedBy == other.llmChangedBy && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) override fun toString() = "TeamUpdateParams{llmChangedBy=$llmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt index 3d06453c..07ec4724 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -616,12 +618,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && callbackName == other.callbackName && callbackVars == other.callbackVars && callbackType == other.callbackType && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + callbackName == other.callbackName && + callbackVars == other.callbackVars && + callbackType == other.callbackType && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(callbackName, callbackVars, callbackType, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(callbackName, callbackVars, callbackType, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -718,12 +724,10 @@ private constructor( return true } - return /* spotless:off */ other is CallbackVars && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CallbackVars && additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -855,7 +859,7 @@ private constructor( return true } - return /* spotless:off */ other is CallbackType && value == other.value /* spotless:on */ + return other is CallbackType && value == other.value } override fun hashCode() = value.hashCode() @@ -868,10 +872,16 @@ private constructor( return true } - return /* spotless:off */ other is CallbackAddParams && teamId == other.teamId && llmChangedBy == other.llmChangedBy && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CallbackAddParams && + teamId == other.teamId && + llmChangedBy == other.llmChangedBy && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(teamId, llmChangedBy, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(teamId, llmChangedBy, body, additionalHeaders, additionalQueryParams) override fun toString() = "CallbackAddParams{teamId=$teamId, llmChangedBy=$llmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt index f0c045ff..cc755bc1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(teamId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -191,10 +193,13 @@ private constructor( return true } - return /* spotless:off */ other is CallbackRetrieveParams && teamId == other.teamId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is CallbackRetrieveParams && + teamId == other.teamId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(teamId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(teamId, additionalHeaders, additionalQueryParams) override fun toString() = "CallbackRetrieveParams{teamId=$teamId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt index d635806b..0d172325 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -476,12 +478,13 @@ private constructor( return true } - return /* spotless:off */ other is Body && models == other.models && teamId == other.teamId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + models == other.models && + teamId == other.teamId && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(models, teamId, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -494,10 +497,13 @@ private constructor( return true } - return /* spotless:off */ other is ModelAddParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ModelAddParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "ModelAddParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt index 16a1ab62..706e38b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -480,12 +482,13 @@ private constructor( return true } - return /* spotless:off */ other is Body && models == other.models && teamId == other.teamId && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + models == other.models && + teamId == other.teamId && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(models, teamId, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -498,10 +501,13 @@ private constructor( return true } - return /* spotless:off */ other is ModelRemoveParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ModelRemoveParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "ModelRemoveParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt index 7bb531ef..672aff99 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap, ) : Params { + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -197,10 +200,14 @@ private constructor( return true } - return /* spotless:off */ other is ThreadCreateParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is ThreadCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "ThreadCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt index 7e51be10..109f589e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(threadId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -178,10 +180,13 @@ private constructor( return true } - return /* spotless:off */ other is ThreadRetrieveParams && threadId == other.threadId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is ThreadRetrieveParams && + threadId == other.threadId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(threadId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(threadId, additionalHeaders, additionalQueryParams) override fun toString() = "ThreadRetrieveParams{threadId=$threadId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt index 60beb21e..1385ce9f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(threadId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is MessageCreateParams && threadId == other.threadId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is MessageCreateParams && + threadId == other.threadId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(threadId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(threadId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "MessageCreateParams{threadId=$threadId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt index 5a8fdc0b..1daecb2c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(threadId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -178,10 +180,13 @@ private constructor( return true } - return /* spotless:off */ other is MessageListParams && threadId == other.threadId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is MessageListParams && + threadId == other.threadId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(threadId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(threadId, additionalHeaders, additionalQueryParams) override fun toString() = "MessageListParams{threadId=$threadId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt index 83586c5e..66804f66 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(threadId) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is RunCreateParams && threadId == other.threadId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is RunCreateParams && + threadId == other.threadId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(threadId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(threadId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "RunCreateParams{threadId=$threadId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt index 8ed6e365..131b26a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -2004,12 +2006,69 @@ private constructor( return true } - return /* spotless:off */ other is Body && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && autoCreateKey == other.autoCreateKey && blocked == other.blocked && budgetDuration == other.budgetDuration && config == other.config && duration == other.duration && guardrails == other.guardrails && keyAlias == other.keyAlias && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && modelMaxBudget == other.modelMaxBudget && modelRpmLimit == other.modelRpmLimit && modelTpmLimit == other.modelTpmLimit && models == other.models && permissions == other.permissions && rpmLimit == other.rpmLimit && sendInviteEmail == other.sendInviteEmail && spend == other.spend && teamId == other.teamId && teams == other.teams && tpmLimit == other.tpmLimit && userAlias == other.userAlias && userEmail == other.userEmail && userId == other.userId && userRole == other.userRole && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + aliases == other.aliases && + allowedCacheControls == other.allowedCacheControls && + autoCreateKey == other.autoCreateKey && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + config == other.config && + duration == other.duration && + guardrails == other.guardrails && + keyAlias == other.keyAlias && + maxBudget == other.maxBudget && + maxParallelRequests == other.maxParallelRequests && + metadata == other.metadata && + modelMaxBudget == other.modelMaxBudget && + modelRpmLimit == other.modelRpmLimit && + modelTpmLimit == other.modelTpmLimit && + models == other.models && + permissions == other.permissions && + rpmLimit == other.rpmLimit && + sendInviteEmail == other.sendInviteEmail && + spend == other.spend && + teamId == other.teamId && + teams == other.teams && + tpmLimit == other.tpmLimit && + userAlias == other.userAlias && + userEmail == other.userEmail && + userId == other.userId && + userRole == other.userRole && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(aliases, allowedCacheControls, autoCreateKey, blocked, budgetDuration, config, duration, guardrails, keyAlias, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelRpmLimit, modelTpmLimit, models, permissions, rpmLimit, sendInviteEmail, spend, teamId, teams, tpmLimit, userAlias, userEmail, userId, userRole, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + aliases, + allowedCacheControls, + autoCreateKey, + blocked, + budgetDuration, + config, + duration, + guardrails, + keyAlias, + maxBudget, + maxParallelRequests, + metadata, + modelMaxBudget, + modelRpmLimit, + modelTpmLimit, + models, + permissions, + rpmLimit, + sendInviteEmail, + spend, + teamId, + teams, + tpmLimit, + userAlias, + userEmail, + userId, + userRole, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2145,7 +2204,7 @@ private constructor( return true } - return /* spotless:off */ other is UserRole && value == other.value /* spotless:on */ + return other is UserRole && value == other.value } override fun hashCode() = value.hashCode() @@ -2158,10 +2217,13 @@ private constructor( return true } - return /* spotless:off */ other is UserCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UserCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "UserCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt index 0e7a4485..aaaa8b49 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt @@ -1488,7 +1488,7 @@ private constructor( return true } - return /* spotless:off */ other is UserRole && value == other.value /* spotless:on */ + return other is UserRole && value == other.value } override fun hashCode() = value.hashCode() @@ -1501,12 +1501,87 @@ private constructor( return true } - return /* spotless:off */ other is UserCreateResponse && expires == other.expires && key == other.key && token == other.token && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetId == other.budgetId && config == other.config && createdBy == other.createdBy && duration == other.duration && enforcedParams == other.enforcedParams && guardrails == other.guardrails && keyAlias == other.keyAlias && keyName == other.keyName && llmBudgetTable == other.llmBudgetTable && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && modelMaxBudget == other.modelMaxBudget && modelRpmLimit == other.modelRpmLimit && modelTpmLimit == other.modelTpmLimit && models == other.models && permissions == other.permissions && rpmLimit == other.rpmLimit && spend == other.spend && tags == other.tags && teamId == other.teamId && teams == other.teams && tokenId == other.tokenId && tpmLimit == other.tpmLimit && updatedBy == other.updatedBy && userAlias == other.userAlias && userEmail == other.userEmail && userId == other.userId && userRole == other.userRole && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UserCreateResponse && + expires == other.expires && + key == other.key && + token == other.token && + aliases == other.aliases && + allowedCacheControls == other.allowedCacheControls && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + budgetId == other.budgetId && + config == other.config && + createdBy == other.createdBy && + duration == other.duration && + enforcedParams == other.enforcedParams && + guardrails == other.guardrails && + keyAlias == other.keyAlias && + keyName == other.keyName && + llmBudgetTable == other.llmBudgetTable && + maxBudget == other.maxBudget && + maxParallelRequests == other.maxParallelRequests && + metadata == other.metadata && + modelMaxBudget == other.modelMaxBudget && + modelRpmLimit == other.modelRpmLimit && + modelTpmLimit == other.modelTpmLimit && + models == other.models && + permissions == other.permissions && + rpmLimit == other.rpmLimit && + spend == other.spend && + tags == other.tags && + teamId == other.teamId && + teams == other.teams && + tokenId == other.tokenId && + tpmLimit == other.tpmLimit && + updatedBy == other.updatedBy && + userAlias == other.userAlias && + userEmail == other.userEmail && + userId == other.userId && + userRole == other.userRole && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(expires, key, token, aliases, allowedCacheControls, blocked, budgetDuration, budgetId, config, createdBy, duration, enforcedParams, guardrails, keyAlias, keyName, llmBudgetTable, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelRpmLimit, modelTpmLimit, models, permissions, rpmLimit, spend, tags, teamId, teams, tokenId, tpmLimit, updatedBy, userAlias, userEmail, userId, userRole, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + expires, + key, + token, + aliases, + allowedCacheControls, + blocked, + budgetDuration, + budgetId, + config, + createdBy, + duration, + enforcedParams, + guardrails, + keyAlias, + keyName, + llmBudgetTable, + maxBudget, + maxParallelRequests, + metadata, + modelMaxBudget, + modelRpmLimit, + modelTpmLimit, + models, + permissions, + rpmLimit, + spend, + tags, + teamId, + teams, + tokenId, + tpmLimit, + updatedBy, + userAlias, + userEmail, + userId, + userRole, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt index a89ae388..a2ed8ca6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt @@ -66,8 +66,10 @@ private constructor( fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -445,12 +447,12 @@ private constructor( return true } - return /* spotless:off */ other is Body && userIds == other.userIds && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + userIds == other.userIds && + additionalProperties == other.additionalProperties } - /* spotless:off */ private val hashCode: Int by lazy { Objects.hash(userIds, additionalProperties) } - /* spotless:on */ override fun hashCode(): Int = hashCode @@ -463,10 +465,15 @@ private constructor( return true } - return /* spotless:off */ other is UserDeleteParams && llmChangedBy == other.llmChangedBy && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UserDeleteParams && + llmChangedBy == other.llmChangedBy && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) override fun toString() = "UserDeleteParams{llmChangedBy=$llmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt index 1225b9b3..21520ce7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(userIds) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -252,10 +254,17 @@ private constructor( return true } - return /* spotless:off */ other is UserListParams && page == other.page && pageSize == other.pageSize && role == other.role && userIds == other.userIds && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UserListParams && + page == other.page && + pageSize == other.pageSize && + role == other.role && + userIds == other.userIds && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(page, pageSize, role, userIds, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(page, pageSize, role, userIds, additionalHeaders, additionalQueryParams) override fun toString() = "UserListParams{page=$page, pageSize=$pageSize, role=$role, userIds=$userIds, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt index b837d24a..6a31c0f8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(userId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -186,10 +188,13 @@ private constructor( return true } - return /* spotless:off */ other is UserRetrieveInfoParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UserRetrieveInfoParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(userId, additionalHeaders, additionalQueryParams) override fun toString() = "UserRetrieveInfoParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt index a8c9f157..65f09955 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -1740,12 +1742,63 @@ private constructor( return true } - return /* spotless:off */ other is Body && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && blocked == other.blocked && budgetDuration == other.budgetDuration && config == other.config && duration == other.duration && guardrails == other.guardrails && keyAlias == other.keyAlias && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && modelMaxBudget == other.modelMaxBudget && modelRpmLimit == other.modelRpmLimit && modelTpmLimit == other.modelTpmLimit && models == other.models && password == other.password && permissions == other.permissions && rpmLimit == other.rpmLimit && spend == other.spend && teamId == other.teamId && tpmLimit == other.tpmLimit && userEmail == other.userEmail && userId == other.userId && userRole == other.userRole && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + aliases == other.aliases && + allowedCacheControls == other.allowedCacheControls && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + config == other.config && + duration == other.duration && + guardrails == other.guardrails && + keyAlias == other.keyAlias && + maxBudget == other.maxBudget && + maxParallelRequests == other.maxParallelRequests && + metadata == other.metadata && + modelMaxBudget == other.modelMaxBudget && + modelRpmLimit == other.modelRpmLimit && + modelTpmLimit == other.modelTpmLimit && + models == other.models && + password == other.password && + permissions == other.permissions && + rpmLimit == other.rpmLimit && + spend == other.spend && + teamId == other.teamId && + tpmLimit == other.tpmLimit && + userEmail == other.userEmail && + userId == other.userId && + userRole == other.userRole && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(aliases, allowedCacheControls, blocked, budgetDuration, config, duration, guardrails, keyAlias, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelRpmLimit, modelTpmLimit, models, password, permissions, rpmLimit, spend, teamId, tpmLimit, userEmail, userId, userRole, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + aliases, + allowedCacheControls, + blocked, + budgetDuration, + config, + duration, + guardrails, + keyAlias, + maxBudget, + maxParallelRequests, + metadata, + modelMaxBudget, + modelRpmLimit, + modelTpmLimit, + models, + password, + permissions, + rpmLimit, + spend, + teamId, + tpmLimit, + userEmail, + userId, + userRole, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1881,7 +1934,7 @@ private constructor( return true } - return /* spotless:off */ other is UserRole && value == other.value /* spotless:on */ + return other is UserRole && value == other.value } override fun hashCode() = value.hashCode() @@ -1894,10 +1947,13 @@ private constructor( return true } - return /* spotless:off */ other is UserUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UserUpdateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "UserUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt index 7d45181a..1a7c0198 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt @@ -101,12 +101,10 @@ private constructor(private val additionalProperties: MutableMap = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -532,12 +534,16 @@ private constructor( return true } - return /* spotless:off */ other is Body && model == other.model && messages == other.messages && prompt == other.prompt && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + model == other.model && + messages == other.messages && + prompt == other.prompt && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(model, messages, prompt, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(model, messages, prompt, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -550,10 +556,13 @@ private constructor( return true } - return /* spotless:off */ other is UtilTokenCounterParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UtilTokenCounterParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "UtilTokenCounterParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt index 330a687a..9cd27828 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt @@ -271,12 +271,17 @@ private constructor( return true } - return /* spotless:off */ other is UtilTokenCounterResponse && modelUsed == other.modelUsed && requestModel == other.requestModel && tokenizerType == other.tokenizerType && totalTokens == other.totalTokens && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UtilTokenCounterResponse && + modelUsed == other.modelUsed && + requestModel == other.requestModel && + tokenizerType == other.tokenizerType && + totalTokens == other.totalTokens && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(modelUsed, requestModel, tokenizerType, totalTokens, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(modelUsed, requestModel, tokenizerType, totalTokens, additionalProperties) + } override fun hashCode(): Int = hashCode diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt index 85a2233d..8d96a926 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt @@ -45,8 +45,10 @@ private constructor( fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -402,12 +404,15 @@ private constructor( return true } - return /* spotless:off */ other is Body && callType == other.callType && requestBody == other.requestBody && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + callType == other.callType && + requestBody == other.requestBody && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(callType, requestBody, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(callType, requestBody, additionalProperties) + } override fun hashCode(): Int = hashCode @@ -885,7 +890,7 @@ private constructor( return true } - return /* spotless:off */ other is CallType && value == other.value /* spotless:on */ + return other is CallType && value == other.value } override fun hashCode() = value.hashCode() @@ -898,10 +903,13 @@ private constructor( return true } - return /* spotless:off */ other is UtilTransformRequestParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is UtilTransformRequestParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = "UtilTransformRequestParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt index 2c103b1f..55ec014f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt @@ -223,12 +223,23 @@ private constructor( return true } - return /* spotless:off */ other is UtilTransformRequestResponse && error == other.error && rawRequestApiBase == other.rawRequestApiBase && rawRequestBody == other.rawRequestBody && rawRequestHeaders == other.rawRequestHeaders && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UtilTransformRequestResponse && + error == other.error && + rawRequestApiBase == other.rawRequestApiBase && + rawRequestBody == other.rawRequestBody && + rawRequestHeaders == other.rawRequestHeaders && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(error, rawRequestApiBase, rawRequestBody, rawRequestHeaders, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + error, + rawRequestApiBase, + rawRequestBody, + rawRequestHeaders, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt index 977f7d57..4769c488 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParams.kt @@ -26,10 +26,13 @@ private constructor( fun endpoint(): Optional = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is VertexAiCreateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is VertexAiCreateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "VertexAiCreateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt index 94b3b334..90bb2389 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is VertexAiDeleteParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is VertexAiDeleteParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "VertexAiDeleteParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt index c7816ece..dd5b4008 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is VertexAiPatchParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is VertexAiPatchParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "VertexAiPatchParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt index 0cf096ba..5fc17274 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -182,10 +184,13 @@ private constructor( return true } - return /* spotless:off */ other is VertexAiRetrieveParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return other is VertexAiRetrieveParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(endpoint, additionalHeaders, additionalQueryParams) override fun toString() = "VertexAiRetrieveParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt index a80a097a..91c25f08 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt @@ -102,12 +102,11 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(endpoint) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -215,10 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is VertexAiUpdateParams && endpoint == other.endpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is VertexAiUpdateParams && + endpoint == other.endpoint && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = + Objects.hash(endpoint, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = "VertexAiUpdateParams{endpoint=$endpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt index 0c94d207..eafc33d2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt @@ -102,12 +102,10 @@ private constructor(private val additionalProperties: MutableMap = listCallbacks(ActiveListCallbacksParams.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none() ): CompletableFuture = listCallbacks(params, RequestOptions.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( requestOptions: RequestOptions ): CompletableFuture = @@ -88,19 +88,19 @@ interface ActiveServiceAsync { fun listCallbacks(): CompletableFuture> = listCallbacks(ActiveListCallbacksParams.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none() ): CompletableFuture> = listCallbacks(params, RequestOptions.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt index 27af8261..9845cbf2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class ActiveServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ActiveServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class ActiveServiceAsyncImpl internal constructor(private val clientOptions: Cli private val listCallbacksHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listCallbacks( params: ActiveListCallbacksParams, @@ -69,7 +69,7 @@ class ActiveServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listCallbacksHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt index ca8425d6..e959c52d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt @@ -28,7 +28,7 @@ interface AddServiceAsync { fun addAllowedIp(params: AddAddAllowedIpParams): CompletableFuture = addAllowedIp(params, RequestOptions.none()) - /** @see [addAllowedIp] */ + /** @see addAllowedIp */ fun addAllowedIp( params: AddAddAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -53,7 +53,7 @@ interface AddServiceAsync { ): CompletableFuture> = addAllowedIp(params, RequestOptions.none()) - /** @see [addAllowedIp] */ + /** @see addAllowedIp */ fun addAllowedIp( params: AddAddAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt index f538519a..9164defa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class AddServiceAsyncImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AddServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class AddServiceAsyncImpl internal constructor(private val clientOptions: Client private val addAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun addAllowedIp( params: AddAddAllowedIpParams, @@ -71,7 +71,7 @@ class AddServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { addAllowedIpHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt index 809df39b..b982d3fc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsync.kt @@ -36,7 +36,7 @@ interface AnthropicServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, AnthropicCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), @@ -44,23 +44,23 @@ interface AnthropicServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AnthropicCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: AnthropicCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -71,7 +71,7 @@ interface AnthropicServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, AnthropicRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), @@ -79,24 +79,24 @@ interface AnthropicServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AnthropicRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: AnthropicRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -107,7 +107,7 @@ interface AnthropicServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, AnthropicUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), @@ -115,23 +115,23 @@ interface AnthropicServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AnthropicUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: AnthropicUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -142,7 +142,7 @@ interface AnthropicServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, AnthropicDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), @@ -150,23 +150,23 @@ interface AnthropicServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AnthropicDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: AnthropicDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -177,7 +177,7 @@ interface AnthropicServiceAsync { fun modify(endpoint: String): CompletableFuture = modify(endpoint, AnthropicModifyParams.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), @@ -185,23 +185,23 @@ interface AnthropicServiceAsync { ): CompletableFuture = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), ): CompletableFuture = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [modify] */ + /** @see modify */ fun modify(params: AnthropicModifyParams): CompletableFuture = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, requestOptions: RequestOptions, @@ -229,7 +229,7 @@ interface AnthropicServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, AnthropicCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), @@ -237,26 +237,26 @@ interface AnthropicServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AnthropicCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: AnthropicCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -272,7 +272,7 @@ interface AnthropicServiceAsync { ): CompletableFuture> = retrieve(endpoint, AnthropicRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), @@ -280,26 +280,26 @@ interface AnthropicServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AnthropicRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AnthropicRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -313,7 +313,7 @@ interface AnthropicServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, AnthropicUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), @@ -321,26 +321,26 @@ interface AnthropicServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AnthropicUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: AnthropicUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -354,7 +354,7 @@ interface AnthropicServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, AnthropicDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), @@ -362,26 +362,26 @@ interface AnthropicServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AnthropicDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: AnthropicDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -395,7 +395,7 @@ interface AnthropicServiceAsync { fun modify(endpoint: String): CompletableFuture> = modify(endpoint, AnthropicModifyParams.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), @@ -403,26 +403,26 @@ interface AnthropicServiceAsync { ): CompletableFuture> = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), ): CompletableFuture> = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [modify] */ + /** @see modify */ fun modify( params: AnthropicModifyParams ): CompletableFuture> = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt index 9e915c48..498a8a26 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AnthropicServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AnthropicCreateParams, @@ -112,7 +112,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: AnthropicRetrieveParams, @@ -146,7 +145,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AnthropicUpdateParams, @@ -181,7 +179,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AnthropicDeleteParams, @@ -216,7 +213,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: private val modifyHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun modify( params: AnthropicModifyParams, @@ -251,7 +247,7 @@ class AnthropicServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { modifyHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt index 7fc34dea..9fc9d104 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsync.kt @@ -36,7 +36,7 @@ interface AssemblyaiServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, AssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), @@ -44,23 +44,23 @@ interface AssemblyaiServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: AssemblyaiCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -71,7 +71,7 @@ interface AssemblyaiServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, AssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), @@ -79,24 +79,24 @@ interface AssemblyaiServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: AssemblyaiRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -107,7 +107,7 @@ interface AssemblyaiServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, AssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), @@ -115,23 +115,23 @@ interface AssemblyaiServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: AssemblyaiUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -142,7 +142,7 @@ interface AssemblyaiServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, AssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), @@ -150,23 +150,23 @@ interface AssemblyaiServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: AssemblyaiDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -177,7 +177,7 @@ interface AssemblyaiServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, AssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), @@ -185,23 +185,23 @@ interface AssemblyaiServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: AssemblyaiPatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -230,7 +230,7 @@ interface AssemblyaiServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, AssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), @@ -238,26 +238,26 @@ interface AssemblyaiServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: AssemblyaiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -273,7 +273,7 @@ interface AssemblyaiServiceAsync { ): CompletableFuture> = retrieve(endpoint, AssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), @@ -281,26 +281,26 @@ interface AssemblyaiServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AssemblyaiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -314,7 +314,7 @@ interface AssemblyaiServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, AssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), @@ -322,26 +322,26 @@ interface AssemblyaiServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: AssemblyaiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -355,7 +355,7 @@ interface AssemblyaiServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, AssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), @@ -363,26 +363,26 @@ interface AssemblyaiServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: AssemblyaiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -396,7 +396,7 @@ interface AssemblyaiServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, AssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), @@ -404,26 +404,26 @@ interface AssemblyaiServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: AssemblyaiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt index fd209e06..d6cc70d8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AssemblyaiServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AssemblyaiCreateParams, @@ -112,7 +112,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: AssemblyaiRetrieveParams, @@ -146,7 +145,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AssemblyaiUpdateParams, @@ -181,7 +179,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AssemblyaiDeleteParams, @@ -216,7 +213,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: AssemblyaiPatchParams, @@ -251,7 +247,7 @@ class AssemblyaiServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt index 8734e4fc..49df5897 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsync.kt @@ -36,18 +36,18 @@ interface AssistantServiceAsync { */ fun create(): CompletableFuture = create(AssistantCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: AssistantCreateParams = AssistantCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: AssistantCreateParams = AssistantCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(AssistantCreateParams.none(), requestOptions) @@ -58,18 +58,18 @@ interface AssistantServiceAsync { */ fun list(): CompletableFuture = list(AssistantListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: AssistantListParams = AssistantListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: AssistantListParams = AssistantListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(AssistantListParams.none(), requestOptions) @@ -82,7 +82,7 @@ interface AssistantServiceAsync { fun delete(assistantId: String): CompletableFuture = delete(assistantId, AssistantDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), @@ -90,24 +90,24 @@ interface AssistantServiceAsync { ): CompletableFuture = delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), ): CompletableFuture = delete(assistantId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: AssistantDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, requestOptions: RequestOptions, @@ -135,19 +135,19 @@ interface AssistantServiceAsync { fun create(): CompletableFuture> = create(AssistantCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: AssistantCreateParams = AssistantCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: AssistantCreateParams = AssistantCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -160,19 +160,19 @@ interface AssistantServiceAsync { fun list(): CompletableFuture> = list(AssistantListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: AssistantListParams = AssistantListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: AssistantListParams = AssistantListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -187,7 +187,7 @@ interface AssistantServiceAsync { ): CompletableFuture> = delete(assistantId, AssistantDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), @@ -195,26 +195,26 @@ interface AssistantServiceAsync { ): CompletableFuture> = delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), ): CompletableFuture> = delete(assistantId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: AssistantDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt index ef5767e2..534a1932 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -62,7 +62,8 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AssistantServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -73,7 +74,6 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AssistantCreateParams, @@ -91,7 +91,7 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -105,7 +105,6 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AssistantListParams, @@ -122,7 +121,7 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -136,7 +135,6 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AssistantDeleteParams, @@ -157,7 +155,7 @@ class AssistantServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt index 3927a1a9..fa42e61e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsync.kt @@ -40,7 +40,7 @@ interface AzureServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, AzureCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), @@ -48,23 +48,23 @@ interface AzureServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AzureCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: AzureCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -79,7 +79,7 @@ interface AzureServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, AzureUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), @@ -87,23 +87,23 @@ interface AzureServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AzureUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: AzureUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -118,7 +118,7 @@ interface AzureServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, AzureDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), @@ -126,23 +126,23 @@ interface AzureServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AzureDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: AzureDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -157,7 +157,7 @@ interface AzureServiceAsync { fun call(endpoint: String): CompletableFuture = call(endpoint, AzureCallParams.none()) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), @@ -165,23 +165,23 @@ interface AzureServiceAsync { ): CompletableFuture = call(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), ): CompletableFuture = call(endpoint, params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ fun call( params: AzureCallParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [call] */ + /** @see call */ fun call(params: AzureCallParams): CompletableFuture = call(params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, requestOptions: RequestOptions, @@ -195,7 +195,7 @@ interface AzureServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, AzurePatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), @@ -203,23 +203,23 @@ interface AzureServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: AzurePatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -245,7 +245,7 @@ interface AzureServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, AzureCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), @@ -253,26 +253,26 @@ interface AzureServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AzureCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: AzureCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -286,7 +286,7 @@ interface AzureServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, AzureUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), @@ -294,26 +294,26 @@ interface AzureServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AzureUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: AzureUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -327,7 +327,7 @@ interface AzureServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, AzureDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), @@ -335,26 +335,26 @@ interface AzureServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AzureDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: AzureDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -368,7 +368,7 @@ interface AzureServiceAsync { fun call(endpoint: String): CompletableFuture> = call(endpoint, AzureCallParams.none()) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), @@ -376,24 +376,24 @@ interface AzureServiceAsync { ): CompletableFuture> = call(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), ): CompletableFuture> = call(endpoint, params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ fun call( params: AzureCallParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [call] */ + /** @see call */ fun call(params: AzureCallParams): CompletableFuture> = call(params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, requestOptions: RequestOptions, @@ -407,7 +407,7 @@ interface AzureServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, AzurePatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), @@ -415,26 +415,26 @@ interface AzureServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: AzurePatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt index a21af70a..7335a5eb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AzureServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AzureCreateParams, @@ -112,7 +112,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AzureUpdateParams, @@ -147,7 +146,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -161,7 +160,6 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AzureDeleteParams, @@ -182,7 +180,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -195,7 +193,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie } private val callHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun call( params: AzureCallParams, @@ -215,7 +213,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { callHandler.handle(it) } .also { @@ -228,7 +226,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie } private val patchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun patch( params: AzurePatchParams, @@ -249,7 +247,7 @@ class AzureServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt index be570111..87ad3bac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsync.kt @@ -56,18 +56,18 @@ interface BatchServiceAsync { */ fun create(): CompletableFuture = create(BatchCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: BatchCreateParams = BatchCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: BatchCreateParams = BatchCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(BatchCreateParams.none(), requestOptions) @@ -84,7 +84,7 @@ interface BatchServiceAsync { fun retrieve(batchId: String): CompletableFuture = retrieve(batchId, BatchRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), @@ -92,23 +92,23 @@ interface BatchServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), ): CompletableFuture = retrieve(batchId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BatchRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: BatchRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, requestOptions: RequestOptions, @@ -127,18 +127,18 @@ interface BatchServiceAsync { */ fun list(): CompletableFuture = list(BatchListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: BatchListParams = BatchListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: BatchListParams = BatchListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(BatchListParams.none(), requestOptions) @@ -161,7 +161,7 @@ interface BatchServiceAsync { ): CompletableFuture = cancelWithProvider(batchId, params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( batchId: String, params: BatchCancelWithProviderParams, @@ -169,13 +169,13 @@ interface BatchServiceAsync { ): CompletableFuture = cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( params: BatchCancelWithProviderParams ): CompletableFuture = cancelWithProvider(params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( params: BatchCancelWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -199,7 +199,7 @@ interface BatchServiceAsync { fun createWithProvider(provider: String): CompletableFuture = createWithProvider(provider, BatchCreateWithProviderParams.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), @@ -207,26 +207,26 @@ interface BatchServiceAsync { ): CompletableFuture = createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), ): CompletableFuture = createWithProvider(provider, params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( params: BatchCreateWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( params: BatchCreateWithProviderParams ): CompletableFuture = createWithProvider(params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, requestOptions: RequestOptions, @@ -246,7 +246,7 @@ interface BatchServiceAsync { fun listWithProvider(provider: String): CompletableFuture = listWithProvider(provider, BatchListWithProviderParams.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), @@ -254,26 +254,26 @@ interface BatchServiceAsync { ): CompletableFuture = listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), ): CompletableFuture = listWithProvider(provider, params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( params: BatchListWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( params: BatchListWithProviderParams ): CompletableFuture = listWithProvider(params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, requestOptions: RequestOptions, @@ -296,7 +296,7 @@ interface BatchServiceAsync { ): CompletableFuture = retrieveWithProvider(batchId, params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( batchId: String, params: BatchRetrieveWithProviderParams, @@ -304,13 +304,13 @@ interface BatchServiceAsync { ): CompletableFuture = retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): CompletableFuture = retrieveWithProvider(params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -337,19 +337,19 @@ interface BatchServiceAsync { fun create(): CompletableFuture> = create(BatchCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: BatchCreateParams = BatchCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: BatchCreateParams = BatchCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -362,7 +362,7 @@ interface BatchServiceAsync { fun retrieve(batchId: String): CompletableFuture> = retrieve(batchId, BatchRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), @@ -370,26 +370,26 @@ interface BatchServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), ): CompletableFuture> = retrieve(batchId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BatchRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BatchRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, requestOptions: RequestOptions, @@ -403,19 +403,19 @@ interface BatchServiceAsync { fun list(): CompletableFuture> = list(BatchListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: BatchListParams = BatchListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: BatchListParams = BatchListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -431,7 +431,7 @@ interface BatchServiceAsync { ): CompletableFuture> = cancelWithProvider(batchId, params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( batchId: String, params: BatchCancelWithProviderParams, @@ -439,13 +439,13 @@ interface BatchServiceAsync { ): CompletableFuture> = cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( params: BatchCancelWithProviderParams ): CompletableFuture> = cancelWithProvider(params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( params: BatchCancelWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -460,7 +460,7 @@ interface BatchServiceAsync { ): CompletableFuture> = createWithProvider(provider, BatchCreateWithProviderParams.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), @@ -468,26 +468,26 @@ interface BatchServiceAsync { ): CompletableFuture> = createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), ): CompletableFuture> = createWithProvider(provider, params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( params: BatchCreateWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( params: BatchCreateWithProviderParams ): CompletableFuture> = createWithProvider(params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, requestOptions: RequestOptions, @@ -503,7 +503,7 @@ interface BatchServiceAsync { ): CompletableFuture> = listWithProvider(provider, BatchListWithProviderParams.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), @@ -511,26 +511,26 @@ interface BatchServiceAsync { ): CompletableFuture> = listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), ): CompletableFuture> = listWithProvider(provider, params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( params: BatchListWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( params: BatchListWithProviderParams ): CompletableFuture> = listWithProvider(params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, requestOptions: RequestOptions, @@ -547,7 +547,7 @@ interface BatchServiceAsync { ): CompletableFuture> = retrieveWithProvider(batchId, params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( batchId: String, params: BatchRetrieveWithProviderParams, @@ -555,13 +555,13 @@ interface BatchServiceAsync { ): CompletableFuture> = retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): CompletableFuture> = retrieveWithProvider(params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt index c62ba85a..91e8a278 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -104,7 +104,8 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BatchServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val cancel: CancelServiceAsync.WithRawResponse by lazy { CancelServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -121,7 +122,6 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BatchCreateParams, @@ -139,7 +139,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -153,7 +153,6 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BatchRetrieveParams, @@ -173,7 +172,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -186,7 +185,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: BatchListParams, @@ -203,7 +202,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -217,7 +216,6 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val cancelWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun cancelWithProvider( params: BatchCancelWithProviderParams, @@ -244,7 +242,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { cancelWithProviderHandler.handle(it) } .also { @@ -258,7 +256,6 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val createWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createWithProvider( params: BatchCreateWithProviderParams, @@ -279,7 +276,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createWithProviderHandler.handle(it) } .also { @@ -293,7 +290,6 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val listWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listWithProvider( params: BatchListWithProviderParams, @@ -313,7 +309,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listWithProviderHandler.handle(it) } .also { @@ -327,7 +323,6 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, @@ -347,7 +342,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveWithProviderHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt index ad605d1a..ee3e7e34 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsync.kt @@ -36,7 +36,7 @@ interface BedrockServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, BedrockCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), @@ -44,23 +44,23 @@ interface BedrockServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: BedrockCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: BedrockCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -71,7 +71,7 @@ interface BedrockServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, BedrockRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), @@ -79,24 +79,24 @@ interface BedrockServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BedrockRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: BedrockRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -107,7 +107,7 @@ interface BedrockServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, BedrockUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), @@ -115,23 +115,23 @@ interface BedrockServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: BedrockUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: BedrockUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -142,7 +142,7 @@ interface BedrockServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, BedrockDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), @@ -150,23 +150,23 @@ interface BedrockServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: BedrockDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: BedrockDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -177,7 +177,7 @@ interface BedrockServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, BedrockPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), @@ -185,23 +185,23 @@ interface BedrockServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: BedrockPatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -229,7 +229,7 @@ interface BedrockServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, BedrockCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), @@ -237,26 +237,26 @@ interface BedrockServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: BedrockCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: BedrockCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -272,7 +272,7 @@ interface BedrockServiceAsync { ): CompletableFuture> = retrieve(endpoint, BedrockRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), @@ -280,26 +280,26 @@ interface BedrockServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BedrockRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BedrockRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -313,7 +313,7 @@ interface BedrockServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, BedrockUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), @@ -321,26 +321,26 @@ interface BedrockServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: BedrockUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: BedrockUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -354,7 +354,7 @@ interface BedrockServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, BedrockDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), @@ -362,26 +362,26 @@ interface BedrockServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: BedrockDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: BedrockDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -395,7 +395,7 @@ interface BedrockServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, BedrockPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), @@ -403,26 +403,26 @@ interface BedrockServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: BedrockPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt index d4e83d74..8ea63111 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BedrockServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BedrockCreateParams, @@ -112,7 +112,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BedrockRetrieveParams, @@ -146,7 +145,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: BedrockUpdateParams, @@ -181,7 +179,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: BedrockDeleteParams, @@ -216,7 +213,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: BedrockPatchParams, @@ -251,7 +247,7 @@ class BedrockServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt index 75b4030e..7a0fca76 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt @@ -53,7 +53,7 @@ interface BudgetServiceAsync { fun create(params: BudgetCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: BudgetCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -78,7 +78,7 @@ interface BudgetServiceAsync { fun update(params: BudgetUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: BudgetUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -87,18 +87,18 @@ interface BudgetServiceAsync { /** List all the created budgets in proxy db. Used on Admin UI. */ fun list(): CompletableFuture = list(BudgetListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: BudgetListParams = BudgetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: BudgetListParams = BudgetListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(BudgetListParams.none(), requestOptions) @@ -111,7 +111,7 @@ interface BudgetServiceAsync { fun delete(params: BudgetDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: BudgetDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -126,7 +126,7 @@ interface BudgetServiceAsync { fun info(params: BudgetInfoParams): CompletableFuture = info(params, RequestOptions.none()) - /** @see [info] */ + /** @see info */ fun info( params: BudgetInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -143,7 +143,7 @@ interface BudgetServiceAsync { fun settings(params: BudgetSettingsParams): CompletableFuture = settings(params, RequestOptions.none()) - /** @see [settings] */ + /** @see settings */ fun settings( params: BudgetSettingsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -172,7 +172,7 @@ interface BudgetServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: BudgetCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -187,7 +187,7 @@ interface BudgetServiceAsync { ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: BudgetUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -200,19 +200,19 @@ interface BudgetServiceAsync { fun list(): CompletableFuture> = list(BudgetListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: BudgetListParams = BudgetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: BudgetListParams = BudgetListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -227,7 +227,7 @@ interface BudgetServiceAsync { ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: BudgetDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -240,7 +240,7 @@ interface BudgetServiceAsync { fun info(params: BudgetInfoParams): CompletableFuture> = info(params, RequestOptions.none()) - /** @see [info] */ + /** @see info */ fun info( params: BudgetInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -255,7 +255,7 @@ interface BudgetServiceAsync { ): CompletableFuture> = settings(params, RequestOptions.none()) - /** @see [settings] */ + /** @see settings */ fun settings( params: BudgetSettingsParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt index 3f6341a9..b798c583 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -87,7 +87,8 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BudgetServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -98,7 +99,6 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BudgetCreateParams, @@ -116,7 +116,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -130,7 +130,6 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: BudgetUpdateParams, @@ -148,7 +147,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -161,7 +160,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: BudgetListParams, @@ -178,7 +177,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -192,7 +191,6 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: BudgetDeleteParams, @@ -210,7 +208,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -223,7 +221,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli } private val infoHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun info( params: BudgetInfoParams, @@ -241,7 +239,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { infoHandler.handle(it) } .also { @@ -255,7 +253,6 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli private val settingsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun settings( params: BudgetSettingsParams, @@ -272,7 +269,7 @@ class BudgetServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { settingsHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt index 4733aacd..5b943fc1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt @@ -45,18 +45,18 @@ interface CacheServiceAsync { */ fun delete(): CompletableFuture = delete(CacheDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CacheDeleteParams = CacheDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete( params: CacheDeleteParams = CacheDeleteParams.none() ): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(requestOptions: RequestOptions): CompletableFuture = delete(CacheDeleteParams.none(), requestOptions) @@ -72,36 +72,36 @@ interface CacheServiceAsync { */ fun flushAll(): CompletableFuture = flushAll(CacheFlushAllParams.none()) - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none() ): CompletableFuture = flushAll(params, RequestOptions.none()) - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll(requestOptions: RequestOptions): CompletableFuture = flushAll(CacheFlushAllParams.none(), requestOptions) /** Endpoint for checking if cache can be pinged */ fun ping(): CompletableFuture = ping(CachePingParams.none()) - /** @see [ping] */ + /** @see ping */ fun ping( params: CachePingParams = CachePingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [ping] */ + /** @see ping */ fun ping( params: CachePingParams = CachePingParams.none() ): CompletableFuture = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ fun ping(requestOptions: RequestOptions): CompletableFuture = ping(CachePingParams.none(), requestOptions) @@ -126,19 +126,19 @@ interface CacheServiceAsync { fun delete(): CompletableFuture> = delete(CacheDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CacheDeleteParams = CacheDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: CacheDeleteParams = CacheDeleteParams.none() ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( requestOptions: RequestOptions ): CompletableFuture> = @@ -151,19 +151,19 @@ interface CacheServiceAsync { fun flushAll(): CompletableFuture> = flushAll(CacheFlushAllParams.none()) - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none() ): CompletableFuture> = flushAll(params, RequestOptions.none()) - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll( requestOptions: RequestOptions ): CompletableFuture> = @@ -176,19 +176,19 @@ interface CacheServiceAsync { fun ping(): CompletableFuture> = ping(CachePingParams.none()) - /** @see [ping] */ + /** @see ping */ fun ping( params: CachePingParams = CachePingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [ping] */ + /** @see ping */ fun ping( params: CachePingParams = CachePingParams.none() ): CompletableFuture> = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ fun ping( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt index c18ea321..70e92be0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -66,7 +66,8 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CacheServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val redis: RediServiceAsync.WithRawResponse by lazy { RediServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -83,7 +84,6 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CacheDeleteParams, @@ -101,7 +101,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -115,7 +115,6 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie private val flushAllHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun flushAll( params: CacheFlushAllParams, @@ -133,7 +132,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { flushAllHandler.handle(it) } .also { @@ -146,7 +145,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie } private val pingHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun ping( params: CachePingParams, @@ -163,7 +162,7 @@ class CacheServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { pingHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt index 7bfdca85..a0168400 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsync.kt @@ -36,7 +36,7 @@ interface CohereServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, CohereCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), @@ -44,23 +44,23 @@ interface CohereServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CohereCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: CohereCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -71,7 +71,7 @@ interface CohereServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, CohereRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), @@ -79,23 +79,23 @@ interface CohereServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CohereRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: CohereRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -106,7 +106,7 @@ interface CohereServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, CohereUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), @@ -114,23 +114,23 @@ interface CohereServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: CohereUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: CohereUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -141,7 +141,7 @@ interface CohereServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, CohereDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), @@ -149,23 +149,23 @@ interface CohereServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CohereDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: CohereDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -176,7 +176,7 @@ interface CohereServiceAsync { fun modify(endpoint: String): CompletableFuture = modify(endpoint, CohereModifyParams.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), @@ -184,23 +184,23 @@ interface CohereServiceAsync { ): CompletableFuture = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), ): CompletableFuture = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [modify] */ + /** @see modify */ fun modify(params: CohereModifyParams): CompletableFuture = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, requestOptions: RequestOptions, @@ -228,7 +228,7 @@ interface CohereServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, CohereCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), @@ -236,26 +236,26 @@ interface CohereServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CohereCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: CohereCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -269,7 +269,7 @@ interface CohereServiceAsync { fun retrieve(endpoint: String): CompletableFuture> = retrieve(endpoint, CohereRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), @@ -277,26 +277,26 @@ interface CohereServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CohereRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CohereRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -310,7 +310,7 @@ interface CohereServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, CohereUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), @@ -318,26 +318,26 @@ interface CohereServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: CohereUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: CohereUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -351,7 +351,7 @@ interface CohereServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, CohereDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), @@ -359,26 +359,26 @@ interface CohereServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CohereDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: CohereDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -392,7 +392,7 @@ interface CohereServiceAsync { fun modify(endpoint: String): CompletableFuture> = modify(endpoint, CohereModifyParams.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), @@ -400,26 +400,26 @@ interface CohereServiceAsync { ): CompletableFuture> = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), ): CompletableFuture> = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [modify] */ + /** @see modify */ fun modify( params: CohereModifyParams ): CompletableFuture> = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt index b02af234..f95252f6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CohereServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CohereCreateParams, @@ -112,7 +112,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CohereRetrieveParams, @@ -146,7 +145,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: CohereUpdateParams, @@ -181,7 +179,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CohereDeleteParams, @@ -216,7 +213,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli private val modifyHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun modify( params: CohereModifyParams, @@ -251,7 +247,7 @@ class CohereServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { modifyHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt index 7433283a..e752ba8f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsync.kt @@ -43,18 +43,18 @@ interface CompletionServiceAsync { fun create(): CompletableFuture = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(CompletionCreateParams.none(), requestOptions) @@ -80,19 +80,19 @@ interface CompletionServiceAsync { fun create(): CompletableFuture> = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt index 025f70cf..96bb6928 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CompletionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CompletionCreateParams, @@ -71,7 +71,7 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt index 23de8d05..de46840a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsync.kt @@ -35,7 +35,7 @@ interface CredentialServiceAsync { fun create(params: CredentialCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CredentialCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -44,18 +44,18 @@ interface CredentialServiceAsync { /** [BETA] endpoint. This might change unexpectedly. */ fun list(): CompletableFuture = list(CredentialListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: CredentialListParams = CredentialListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: CredentialListParams = CredentialListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(CredentialListParams.none(), requestOptions) @@ -63,7 +63,7 @@ interface CredentialServiceAsync { fun delete(credentialName: String): CompletableFuture = delete(credentialName, CredentialDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), @@ -71,24 +71,24 @@ interface CredentialServiceAsync { ): CompletableFuture = delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), ): CompletableFuture = delete(credentialName, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: CredentialDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, requestOptions: RequestOptions, @@ -119,7 +119,7 @@ interface CredentialServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CredentialCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -132,19 +132,19 @@ interface CredentialServiceAsync { fun list(): CompletableFuture> = list(CredentialListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: CredentialListParams = CredentialListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: CredentialListParams = CredentialListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -159,7 +159,7 @@ interface CredentialServiceAsync { ): CompletableFuture> = delete(credentialName, CredentialDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), @@ -167,26 +167,26 @@ interface CredentialServiceAsync { ): CompletableFuture> = delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), ): CompletableFuture> = delete(credentialName, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: CredentialDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt index d194c7e6..c8482881 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -62,7 +62,8 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CredentialServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -73,7 +74,6 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CredentialCreateParams, @@ -91,7 +91,7 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -105,7 +105,6 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CredentialListParams, @@ -122,7 +121,7 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -136,7 +135,6 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CredentialDeleteParams, @@ -157,7 +155,7 @@ class CredentialServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt index 03af1db4..0957d328 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt @@ -87,7 +87,7 @@ interface CustomerServiceAsync { fun create(params: CustomerCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CustomerCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -120,7 +120,7 @@ interface CustomerServiceAsync { fun update(params: CustomerUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: CustomerUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -136,18 +136,18 @@ interface CustomerServiceAsync { */ fun list(): CompletableFuture> = list(CustomerListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: CustomerListParams = CustomerListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: CustomerListParams = CustomerListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture> = list(CustomerListParams.none(), requestOptions) @@ -169,7 +169,7 @@ interface CustomerServiceAsync { fun delete(params: CustomerDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CustomerDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -189,7 +189,7 @@ interface CustomerServiceAsync { fun block(params: CustomerBlockParams): CompletableFuture = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: CustomerBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -210,7 +210,7 @@ interface CustomerServiceAsync { params: CustomerRetrieveInfoParams ): CompletableFuture = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: CustomerRetrieveInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -232,7 +232,7 @@ interface CustomerServiceAsync { fun unblock(params: CustomerUnblockParams): CompletableFuture = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: CustomerUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -261,7 +261,7 @@ interface CustomerServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CustomerCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -276,7 +276,7 @@ interface CustomerServiceAsync { ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: CustomerUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -289,19 +289,19 @@ interface CustomerServiceAsync { fun list(): CompletableFuture>> = list(CustomerListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: CustomerListParams = CustomerListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [list] */ + /** @see list */ fun list( params: CustomerListParams = CustomerListParams.none() ): CompletableFuture>> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture>> = @@ -316,7 +316,7 @@ interface CustomerServiceAsync { ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CustomerDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -331,7 +331,7 @@ interface CustomerServiceAsync { ): CompletableFuture> = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: CustomerBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -346,7 +346,7 @@ interface CustomerServiceAsync { ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: CustomerRetrieveInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -361,7 +361,7 @@ interface CustomerServiceAsync { ): CompletableFuture> = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: CustomerUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt index d547c37d..a1e86d23 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -96,7 +96,8 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -107,7 +108,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CustomerCreateParams, @@ -125,7 +125,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -139,7 +139,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: CustomerUpdateParams, @@ -157,7 +156,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -171,7 +170,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CustomerListParams, @@ -188,7 +186,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -202,7 +200,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CustomerDeleteParams, @@ -220,7 +217,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -234,7 +231,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val blockHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun block( params: CustomerBlockParams, @@ -252,7 +248,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { blockHandler.handle(it) } .also { @@ -266,7 +262,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: CustomerRetrieveInfoParams, @@ -283,7 +278,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { @@ -297,7 +292,6 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C private val unblockHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun unblock( params: CustomerUnblockParams, @@ -315,7 +309,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { unblockHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt index 15117005..9c997f12 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt @@ -30,7 +30,7 @@ interface DeleteServiceAsync { ): CompletableFuture = createAllowedIp(params, RequestOptions.none()) - /** @see [createAllowedIp] */ + /** @see createAllowedIp */ fun createAllowedIp( params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -59,7 +59,7 @@ interface DeleteServiceAsync { ): CompletableFuture> = createAllowedIp(params, RequestOptions.none()) - /** @see [createAllowedIp] */ + /** @see createAllowedIp */ fun createAllowedIp( params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt index e9e7722c..10de7ed6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class DeleteServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DeleteServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class DeleteServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createAllowedIp( params: DeleteCreateAllowedIpParams, @@ -71,7 +71,7 @@ class DeleteServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createAllowedIpHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt index 62c26bf0..91d1ce0f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsync.kt @@ -40,18 +40,18 @@ interface EmbeddingServiceAsync { */ fun create(): CompletableFuture = create(EmbeddingCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(EmbeddingCreateParams.none(), requestOptions) @@ -76,19 +76,19 @@ interface EmbeddingServiceAsync { fun create(): CompletableFuture> = create(EmbeddingCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt index bce5315c..7f18d673 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EmbeddingServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: EmbeddingCreateParams, @@ -71,7 +71,7 @@ class EmbeddingServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt index 831d397a..f5f2a00e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsync.kt @@ -48,7 +48,7 @@ interface EngineServiceAsync { fun complete(model: String): CompletableFuture = complete(model, EngineCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), @@ -56,23 +56,23 @@ interface EngineServiceAsync { ): CompletableFuture = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), ): CompletableFuture = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: EngineCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [complete] */ + /** @see complete */ fun complete(params: EngineCompleteParams): CompletableFuture = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, @@ -96,7 +96,7 @@ interface EngineServiceAsync { fun embed(model: String): CompletableFuture = embed(model, EngineEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), @@ -104,23 +104,23 @@ interface EngineServiceAsync { ): CompletableFuture = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), ): CompletableFuture = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [embed] */ + /** @see embed */ fun embed(params: EngineEmbedParams): CompletableFuture = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, requestOptions: RequestOptions, @@ -150,7 +150,7 @@ interface EngineServiceAsync { fun complete(model: String): CompletableFuture> = complete(model, EngineCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), @@ -158,26 +158,26 @@ interface EngineServiceAsync { ): CompletableFuture> = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), ): CompletableFuture> = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: EngineCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [complete] */ + /** @see complete */ fun complete( params: EngineCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, @@ -191,7 +191,7 @@ interface EngineServiceAsync { fun embed(model: String): CompletableFuture> = embed(model, EngineEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), @@ -199,26 +199,26 @@ interface EngineServiceAsync { ): CompletableFuture> = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), ): CompletableFuture> = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [embed] */ + /** @see embed */ fun embed( params: EngineEmbedParams ): CompletableFuture> = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt index 04f02a43..0584d2d7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -59,7 +59,8 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EngineServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val chat: ChatServiceAsync.WithRawResponse by lazy { ChatServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -76,7 +77,6 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: EngineCompleteParams, @@ -97,7 +97,7 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { @@ -111,7 +111,6 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli private val embedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun embed( params: EngineEmbedParams, @@ -132,7 +131,7 @@ class EngineServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { embedHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt index b3299a82..78b2ec1d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsync.kt @@ -36,7 +36,7 @@ interface EuAssemblyaiServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, EuAssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), @@ -44,24 +44,24 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: EuAssemblyaiCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -72,7 +72,7 @@ interface EuAssemblyaiServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), @@ -80,25 +80,25 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: EuAssemblyaiRetrieveParams ): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -109,7 +109,7 @@ interface EuAssemblyaiServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, EuAssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), @@ -117,24 +117,24 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: EuAssemblyaiUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -145,7 +145,7 @@ interface EuAssemblyaiServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, EuAssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), @@ -153,24 +153,24 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: EuAssemblyaiDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -181,7 +181,7 @@ interface EuAssemblyaiServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, EuAssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), @@ -189,23 +189,23 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: EuAssemblyaiPatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -236,7 +236,7 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = create(endpoint, EuAssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), @@ -244,26 +244,26 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: EuAssemblyaiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -279,7 +279,7 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), @@ -287,26 +287,26 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: EuAssemblyaiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -322,7 +322,7 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = update(endpoint, EuAssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), @@ -330,26 +330,26 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: EuAssemblyaiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -365,7 +365,7 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = delete(endpoint, EuAssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), @@ -373,26 +373,26 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: EuAssemblyaiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -406,7 +406,7 @@ interface EuAssemblyaiServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, EuAssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), @@ -414,26 +414,26 @@ interface EuAssemblyaiServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: EuAssemblyaiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt index a9d27995..6b4789e7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EuAssemblyaiServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: EuAssemblyaiCreateParams, @@ -112,7 +112,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: EuAssemblyaiRetrieveParams, @@ -146,7 +145,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: EuAssemblyaiUpdateParams, @@ -181,7 +179,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: EuAssemblyaiDeleteParams, @@ -216,7 +213,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: EuAssemblyaiPatchParams, @@ -251,7 +247,7 @@ class EuAssemblyaiServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt index 5c7904da..a042921a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsync.kt @@ -49,7 +49,7 @@ interface FileServiceAsync { fun create(provider: String, params: FileCreateParams): CompletableFuture = create(provider, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( provider: String, params: FileCreateParams, @@ -57,11 +57,11 @@ interface FileServiceAsync { ): CompletableFuture = create(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create(params: FileCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: FileCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -85,7 +85,7 @@ interface FileServiceAsync { params: FileRetrieveParams, ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fileId: String, params: FileRetrieveParams, @@ -93,11 +93,11 @@ interface FileServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: FileRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: FileRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -119,7 +119,7 @@ interface FileServiceAsync { fun list(provider: String): CompletableFuture = list(provider, FileListParams.none()) - /** @see [list] */ + /** @see list */ fun list( provider: String, params: FileListParams = FileListParams.none(), @@ -127,23 +127,23 @@ interface FileServiceAsync { ): CompletableFuture = list(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( provider: String, params: FileListParams = FileListParams.none(), ): CompletableFuture = list(provider, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: FileListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: FileListParams): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( provider: String, requestOptions: RequestOptions, @@ -165,7 +165,7 @@ interface FileServiceAsync { fun delete(fileId: String, params: FileDeleteParams): CompletableFuture = delete(fileId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( fileId: String, params: FileDeleteParams, @@ -173,11 +173,11 @@ interface FileServiceAsync { ): CompletableFuture = delete(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete(params: FileDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: FileDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -205,7 +205,7 @@ interface FileServiceAsync { ): CompletableFuture> = create(provider, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( provider: String, params: FileCreateParams, @@ -213,13 +213,13 @@ interface FileServiceAsync { ): CompletableFuture> = create(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( params: FileCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: FileCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -235,7 +235,7 @@ interface FileServiceAsync { ): CompletableFuture> = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fileId: String, params: FileRetrieveParams, @@ -243,13 +243,13 @@ interface FileServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: FileRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: FileRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -262,7 +262,7 @@ interface FileServiceAsync { fun list(provider: String): CompletableFuture> = list(provider, FileListParams.none()) - /** @see [list] */ + /** @see list */ fun list( provider: String, params: FileListParams = FileListParams.none(), @@ -270,24 +270,24 @@ interface FileServiceAsync { ): CompletableFuture> = list(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( provider: String, params: FileListParams = FileListParams.none(), ): CompletableFuture> = list(provider, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: FileListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list(params: FileListParams): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( provider: String, requestOptions: RequestOptions, @@ -304,7 +304,7 @@ interface FileServiceAsync { ): CompletableFuture> = delete(fileId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( fileId: String, params: FileDeleteParams, @@ -312,13 +312,13 @@ interface FileServiceAsync { ): CompletableFuture> = delete(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( params: FileDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: FileDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt index 5f0c9178..c4944aec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/FileServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -78,7 +78,8 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FileServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val content: ContentServiceAsync.WithRawResponse by lazy { ContentServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -94,7 +95,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun content(): ContentServiceAsync.WithRawResponse = content private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: FileCreateParams, @@ -115,7 +116,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -129,7 +130,6 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FileRetrieveParams, @@ -149,7 +149,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -162,7 +162,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: FileListParams, @@ -182,7 +182,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -195,7 +195,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: FileDeleteParams, @@ -216,7 +216,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt index eaa0221f..62b7af95 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsync.kt @@ -36,7 +36,7 @@ interface GeminiServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, GeminiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), @@ -44,23 +44,23 @@ interface GeminiServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: GeminiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: GeminiCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -71,7 +71,7 @@ interface GeminiServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, GeminiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), @@ -79,23 +79,23 @@ interface GeminiServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: GeminiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: GeminiRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -106,7 +106,7 @@ interface GeminiServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, GeminiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), @@ -114,23 +114,23 @@ interface GeminiServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: GeminiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: GeminiUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -141,7 +141,7 @@ interface GeminiServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, GeminiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), @@ -149,23 +149,23 @@ interface GeminiServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: GeminiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: GeminiDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -176,7 +176,7 @@ interface GeminiServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, GeminiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), @@ -184,23 +184,23 @@ interface GeminiServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: GeminiPatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -228,7 +228,7 @@ interface GeminiServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, GeminiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), @@ -236,26 +236,26 @@ interface GeminiServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: GeminiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: GeminiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -269,7 +269,7 @@ interface GeminiServiceAsync { fun retrieve(endpoint: String): CompletableFuture> = retrieve(endpoint, GeminiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), @@ -277,26 +277,26 @@ interface GeminiServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: GeminiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: GeminiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -310,7 +310,7 @@ interface GeminiServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, GeminiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), @@ -318,26 +318,26 @@ interface GeminiServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: GeminiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: GeminiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -351,7 +351,7 @@ interface GeminiServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, GeminiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), @@ -359,26 +359,26 @@ interface GeminiServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: GeminiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: GeminiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -392,7 +392,7 @@ interface GeminiServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, GeminiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), @@ -400,26 +400,26 @@ interface GeminiServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: GeminiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt index a05530bd..705a4e1f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : GeminiServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: GeminiCreateParams, @@ -112,7 +112,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: GeminiRetrieveParams, @@ -146,7 +145,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: GeminiUpdateParams, @@ -181,7 +179,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: GeminiDeleteParams, @@ -216,7 +213,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: GeminiPatchParams, @@ -251,7 +247,7 @@ class GeminiServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt index 1a4a3f20..f6a81ae0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt @@ -60,18 +60,18 @@ interface GuardrailServiceAsync { */ fun list(): CompletableFuture = list(GuardrailListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: GuardrailListParams = GuardrailListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: GuardrailListParams = GuardrailListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(GuardrailListParams.none(), requestOptions) @@ -96,19 +96,19 @@ interface GuardrailServiceAsync { fun list(): CompletableFuture> = list(GuardrailListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: GuardrailListParams = GuardrailListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: GuardrailListParams = GuardrailListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt index 29b8e831..b867ad90 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : GuardrailServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: GuardrailListParams, @@ -69,7 +69,7 @@ class GuardrailServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt index 638f524f..3196a3db 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsync.kt @@ -51,18 +51,18 @@ interface HealthServiceAsync { fun checkAll(): CompletableFuture = checkAll(HealthCheckAllParams.none()) - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none() ): CompletableFuture = checkAll(params, RequestOptions.none()) - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll(requestOptions: RequestOptions): CompletableFuture = checkAll(HealthCheckAllParams.none(), requestOptions) @@ -70,19 +70,19 @@ interface HealthServiceAsync { fun checkLiveliness(): CompletableFuture = checkLiveliness(HealthCheckLivelinessParams.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none() ): CompletableFuture = checkLiveliness(params, RequestOptions.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( requestOptions: RequestOptions ): CompletableFuture = @@ -92,18 +92,18 @@ interface HealthServiceAsync { fun checkLiveness(): CompletableFuture = checkLiveness(HealthCheckLivenessParams.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none() ): CompletableFuture = checkLiveness(params, RequestOptions.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( requestOptions: RequestOptions ): CompletableFuture = @@ -113,19 +113,19 @@ interface HealthServiceAsync { fun checkReadiness(): CompletableFuture = checkReadiness(HealthCheckReadinessParams.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none() ): CompletableFuture = checkReadiness(params, RequestOptions.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( requestOptions: RequestOptions ): CompletableFuture = @@ -143,7 +143,7 @@ interface HealthServiceAsync { params: HealthCheckServicesParams ): CompletableFuture = checkServices(params, RequestOptions.none()) - /** @see [checkServices] */ + /** @see checkServices */ fun checkServices( params: HealthCheckServicesParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -170,19 +170,19 @@ interface HealthServiceAsync { fun checkAll(): CompletableFuture> = checkAll(HealthCheckAllParams.none()) - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none() ): CompletableFuture> = checkAll(params, RequestOptions.none()) - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( requestOptions: RequestOptions ): CompletableFuture> = @@ -195,19 +195,19 @@ interface HealthServiceAsync { fun checkLiveliness(): CompletableFuture> = checkLiveliness(HealthCheckLivelinessParams.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none() ): CompletableFuture> = checkLiveliness(params, RequestOptions.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( requestOptions: RequestOptions ): CompletableFuture> = @@ -220,19 +220,19 @@ interface HealthServiceAsync { fun checkLiveness(): CompletableFuture> = checkLiveness(HealthCheckLivenessParams.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none() ): CompletableFuture> = checkLiveness(params, RequestOptions.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( requestOptions: RequestOptions ): CompletableFuture> = @@ -245,19 +245,19 @@ interface HealthServiceAsync { fun checkReadiness(): CompletableFuture> = checkReadiness(HealthCheckReadinessParams.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none() ): CompletableFuture> = checkReadiness(params, RequestOptions.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( requestOptions: RequestOptions ): CompletableFuture> = @@ -272,7 +272,7 @@ interface HealthServiceAsync { ): CompletableFuture> = checkServices(params, RequestOptions.none()) - /** @see [checkServices] */ + /** @see checkServices */ fun checkServices( params: HealthCheckServicesParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt index 9110864f..3055b6e1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -77,7 +77,8 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : HealthServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -88,7 +89,6 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli private val checkAllHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkAll( params: HealthCheckAllParams, @@ -105,7 +105,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkAllHandler.handle(it) } .also { @@ -119,7 +119,6 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli private val checkLivelinessHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkLiveliness( params: HealthCheckLivelinessParams, @@ -136,7 +135,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkLivelinessHandler.handle(it) } .also { @@ -150,7 +149,6 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli private val checkLivenessHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkLiveness( params: HealthCheckLivenessParams, @@ -167,7 +165,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkLivenessHandler.handle(it) } .also { @@ -181,7 +179,6 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli private val checkReadinessHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkReadiness( params: HealthCheckReadinessParams, @@ -198,7 +195,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkReadinessHandler.handle(it) } .also { @@ -212,7 +209,6 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli private val checkServicesHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkServices( params: HealthCheckServicesParams, @@ -229,7 +225,7 @@ class HealthServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkServicesHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt index e343e6d4..9f032875 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt @@ -102,7 +102,7 @@ interface KeyServiceAsync { fun update(params: KeyUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: KeyUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -116,17 +116,17 @@ interface KeyServiceAsync { */ fun list(): CompletableFuture = list(KeyListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: KeyListParams = KeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: KeyListParams = KeyListParams.none()): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(KeyListParams.none(), requestOptions) @@ -154,18 +154,18 @@ interface KeyServiceAsync { */ fun delete(): CompletableFuture = delete(KeyDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: KeyDeleteParams = KeyDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete( params: KeyDeleteParams = KeyDeleteParams.none() ): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(requestOptions: RequestOptions): CompletableFuture = delete(KeyDeleteParams.none(), requestOptions) @@ -188,7 +188,7 @@ interface KeyServiceAsync { fun block(params: KeyBlockParams): CompletableFuture> = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: KeyBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -235,18 +235,18 @@ interface KeyServiceAsync { fun checkHealth(): CompletableFuture = checkHealth(KeyCheckHealthParams.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none() ): CompletableFuture = checkHealth(params, RequestOptions.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth(requestOptions: RequestOptions): CompletableFuture = checkHealth(KeyCheckHealthParams.none(), requestOptions) @@ -327,18 +327,18 @@ interface KeyServiceAsync { */ fun generate(): CompletableFuture = generate(KeyGenerateParams.none()) - /** @see [generate] */ + /** @see generate */ fun generate( params: KeyGenerateParams = KeyGenerateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [generate] */ + /** @see generate */ fun generate( params: KeyGenerateParams = KeyGenerateParams.none() ): CompletableFuture = generate(params, RequestOptions.none()) - /** @see [generate] */ + /** @see generate */ fun generate(requestOptions: RequestOptions): CompletableFuture = generate(KeyGenerateParams.none(), requestOptions) @@ -393,7 +393,7 @@ interface KeyServiceAsync { fun regenerateByKey(pathKey: String): CompletableFuture> = regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), @@ -401,26 +401,26 @@ interface KeyServiceAsync { ): CompletableFuture> = regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), ): CompletableFuture> = regenerateByKey(pathKey, params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( params: KeyRegenerateByKeyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( params: KeyRegenerateByKeyParams ): CompletableFuture> = regenerateByKey(params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, requestOptions: RequestOptions, @@ -447,18 +447,18 @@ interface KeyServiceAsync { fun retrieveInfo(): CompletableFuture = retrieveInfo(KeyRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none() ): CompletableFuture = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): CompletableFuture = retrieveInfo(KeyRetrieveInfoParams.none(), requestOptions) @@ -481,7 +481,7 @@ interface KeyServiceAsync { fun unblock(params: KeyUnblockParams): CompletableFuture = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: KeyUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -506,7 +506,7 @@ interface KeyServiceAsync { fun update(params: KeyUpdateParams): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: KeyUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -518,18 +518,18 @@ interface KeyServiceAsync { */ fun list(): CompletableFuture> = list(KeyListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: KeyListParams = KeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: KeyListParams = KeyListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -542,19 +542,19 @@ interface KeyServiceAsync { fun delete(): CompletableFuture> = delete(KeyDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: KeyDeleteParams = KeyDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: KeyDeleteParams = KeyDeleteParams.none() ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( requestOptions: RequestOptions ): CompletableFuture> = @@ -569,7 +569,7 @@ interface KeyServiceAsync { ): CompletableFuture>> = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: KeyBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -582,19 +582,19 @@ interface KeyServiceAsync { fun checkHealth(): CompletableFuture> = checkHealth(KeyCheckHealthParams.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none() ): CompletableFuture> = checkHealth(params, RequestOptions.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( requestOptions: RequestOptions ): CompletableFuture> = @@ -607,19 +607,19 @@ interface KeyServiceAsync { fun generate(): CompletableFuture> = generate(KeyGenerateParams.none()) - /** @see [generate] */ + /** @see generate */ fun generate( params: KeyGenerateParams = KeyGenerateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [generate] */ + /** @see generate */ fun generate( params: KeyGenerateParams = KeyGenerateParams.none() ): CompletableFuture> = generate(params, RequestOptions.none()) - /** @see [generate] */ + /** @see generate */ fun generate( requestOptions: RequestOptions ): CompletableFuture> = @@ -634,7 +634,7 @@ interface KeyServiceAsync { ): CompletableFuture>> = regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), @@ -642,26 +642,26 @@ interface KeyServiceAsync { ): CompletableFuture>> = regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), ): CompletableFuture>> = regenerateByKey(pathKey, params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( params: KeyRegenerateByKeyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( params: KeyRegenerateByKeyParams ): CompletableFuture>> = regenerateByKey(params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, requestOptions: RequestOptions, @@ -675,19 +675,19 @@ interface KeyServiceAsync { fun retrieveInfo(): CompletableFuture> = retrieveInfo(KeyRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = @@ -702,7 +702,7 @@ interface KeyServiceAsync { ): CompletableFuture> = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: KeyUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt index 1b37ed2a..6e08ebae 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -124,7 +124,8 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : KeyServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val regenerate: RegenerateServiceAsync.WithRawResponse by lazy { RegenerateServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -140,7 +141,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client override fun regenerate(): RegenerateServiceAsync.WithRawResponse = regenerate private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: KeyUpdateParams, @@ -158,7 +159,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -171,7 +172,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: KeyListParams, @@ -188,7 +189,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -201,7 +202,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: KeyDeleteParams, @@ -219,7 +220,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -233,7 +234,6 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client private val blockHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun block( params: KeyBlockParams, @@ -251,7 +251,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { blockHandler.handle(it) } .also { @@ -265,7 +265,6 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client private val checkHealthHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkHealth( params: KeyCheckHealthParams, @@ -283,7 +282,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { checkHealthHandler.handle(it) } .also { @@ -297,7 +296,6 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client private val generateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun generate( params: KeyGenerateParams, @@ -315,7 +313,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { generateHandler.handle(it) } .also { @@ -329,7 +327,6 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client private val regenerateByKeyHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun regenerateByKey( params: KeyRegenerateByKeyParams, @@ -350,7 +347,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { regenerateByKeyHandler.handle(it) } .also { @@ -364,7 +361,6 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: KeyRetrieveInfoParams, @@ -381,7 +377,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { @@ -394,7 +390,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client } private val unblockHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun unblock( params: KeyUnblockParams, @@ -412,7 +408,7 @@ class KeyServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { unblockHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt index 140a1b47..e8b51aea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsync.kt @@ -40,7 +40,7 @@ interface LangfuseServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, LangfuseCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), @@ -48,23 +48,23 @@ interface LangfuseServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: LangfuseCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: LangfuseCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -79,7 +79,7 @@ interface LangfuseServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, LangfuseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), @@ -87,24 +87,24 @@ interface LangfuseServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: LangfuseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: LangfuseRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -119,7 +119,7 @@ interface LangfuseServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, LangfuseUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), @@ -127,23 +127,23 @@ interface LangfuseServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: LangfuseUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: LangfuseUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -158,7 +158,7 @@ interface LangfuseServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, LangfuseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), @@ -166,23 +166,23 @@ interface LangfuseServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: LangfuseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: LangfuseDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -197,7 +197,7 @@ interface LangfuseServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, LangfusePatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), @@ -205,23 +205,23 @@ interface LangfuseServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: LangfusePatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -249,7 +249,7 @@ interface LangfuseServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, LangfuseCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), @@ -257,26 +257,26 @@ interface LangfuseServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: LangfuseCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: LangfuseCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -292,7 +292,7 @@ interface LangfuseServiceAsync { ): CompletableFuture> = retrieve(endpoint, LangfuseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), @@ -300,26 +300,26 @@ interface LangfuseServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: LangfuseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: LangfuseRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -333,7 +333,7 @@ interface LangfuseServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, LangfuseUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), @@ -341,26 +341,26 @@ interface LangfuseServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: LangfuseUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: LangfuseUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -374,7 +374,7 @@ interface LangfuseServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, LangfuseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), @@ -382,26 +382,26 @@ interface LangfuseServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: LangfuseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: LangfuseDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -415,7 +415,7 @@ interface LangfuseServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, LangfusePatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), @@ -423,26 +423,26 @@ interface LangfuseServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: LangfusePatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt index 2c56dadf..0ac816bb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LangfuseServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: LangfuseCreateParams, @@ -112,7 +112,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: LangfuseRetrieveParams, @@ -146,7 +145,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: LangfuseUpdateParams, @@ -181,7 +179,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: LangfuseDeleteParams, @@ -216,7 +213,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: LangfusePatchParams, @@ -251,7 +247,7 @@ class LangfuseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt index f8e76dff..14cd230a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt @@ -165,19 +165,19 @@ interface ModelGroupServiceAsync { fun retrieveInfo(): CompletableFuture = retrieveInfo(ModelGroupRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none() ): CompletableFuture = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture = @@ -205,19 +205,19 @@ interface ModelGroupServiceAsync { fun retrieveInfo(): CompletableFuture> = retrieveInfo(ModelGroupRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt index 7d8d2e03..34a945b2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModelGroupServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: ModelGroupRetrieveInfoParams, @@ -69,7 +69,7 @@ class ModelGroupServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt index 458d6e2a..6398fdc4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsync.kt @@ -36,7 +36,7 @@ interface ModelServiceAsync { fun create(params: ModelCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: ModelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +46,7 @@ interface ModelServiceAsync { fun delete(params: ModelDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: ModelDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -77,7 +77,7 @@ interface ModelServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: ModelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +92,7 @@ interface ModelServiceAsync { ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: ModelDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt index 541d24b9..2a77a7b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -63,7 +63,8 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModelServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val info: InfoServiceAsync.WithRawResponse by lazy { InfoServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -86,7 +87,6 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ModelCreateParams, @@ -104,7 +104,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -118,7 +118,6 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: ModelDeleteParams, @@ -136,7 +135,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt index 6a2ded33..7e91a8c0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsync.kt @@ -37,18 +37,18 @@ interface ModerationServiceAsync { fun create(): CompletableFuture = create(ModerationCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ModerationCreateParams = ModerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: ModerationCreateParams = ModerationCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(ModerationCreateParams.none(), requestOptions) @@ -74,19 +74,19 @@ interface ModerationServiceAsync { fun create(): CompletableFuture> = create(ModerationCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ModerationCreateParams = ModerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: ModerationCreateParams = ModerationCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt index 8f66c934..a60ff0fa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModerationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ModerationCreateParams, @@ -71,7 +71,7 @@ class ModerationServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt index 8bca4194..d4047866 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsync.kt @@ -41,7 +41,7 @@ interface OpenAIServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, OpenAICreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), @@ -49,23 +49,23 @@ interface OpenAIServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: OpenAICreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: OpenAICreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -78,7 +78,7 @@ interface OpenAIServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, OpenAIRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), @@ -86,23 +86,23 @@ interface OpenAIServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: OpenAIRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: OpenAIRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -115,7 +115,7 @@ interface OpenAIServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, OpenAIUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), @@ -123,23 +123,23 @@ interface OpenAIServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: OpenAIUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: OpenAIUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -152,7 +152,7 @@ interface OpenAIServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, OpenAIDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), @@ -160,23 +160,23 @@ interface OpenAIServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: OpenAIDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: OpenAIDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -189,7 +189,7 @@ interface OpenAIServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, OpenAIPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), @@ -197,23 +197,23 @@ interface OpenAIServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: OpenAIPatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -243,7 +243,7 @@ interface OpenAIServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, OpenAICreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), @@ -251,26 +251,26 @@ interface OpenAIServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: OpenAICreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: OpenAICreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -284,7 +284,7 @@ interface OpenAIServiceAsync { fun retrieve(endpoint: String): CompletableFuture> = retrieve(endpoint, OpenAIRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), @@ -292,26 +292,26 @@ interface OpenAIServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: OpenAIRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: OpenAIRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -325,7 +325,7 @@ interface OpenAIServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, OpenAIUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), @@ -333,26 +333,26 @@ interface OpenAIServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: OpenAIUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: OpenAIUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -366,7 +366,7 @@ interface OpenAIServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, OpenAIDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), @@ -374,26 +374,26 @@ interface OpenAIServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: OpenAIDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: OpenAIDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -407,7 +407,7 @@ interface OpenAIServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, OpenAIPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), @@ -415,26 +415,26 @@ interface OpenAIServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: OpenAIPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt index 0138ae7e..8f1fa456 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -88,7 +88,8 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OpenAIServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val deployments: DeploymentServiceAsync.WithRawResponse by lazy { DeploymentServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -105,7 +106,6 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: OpenAICreateParams, @@ -126,7 +126,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -140,7 +140,6 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: OpenAIRetrieveParams, @@ -160,7 +159,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -174,7 +173,6 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: OpenAIUpdateParams, @@ -195,7 +193,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -209,7 +207,6 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: OpenAIDeleteParams, @@ -230,7 +227,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -244,7 +241,6 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: OpenAIPatchParams, @@ -265,7 +261,7 @@ class OpenAIServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt index b05b23a9..35df5069 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt @@ -104,7 +104,7 @@ interface OrganizationServiceAsync { fun create(params: OrganizationCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: OrganizationCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -114,18 +114,18 @@ interface OrganizationServiceAsync { fun update(): CompletableFuture = update(OrganizationUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none() ): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(requestOptions: RequestOptions): CompletableFuture = update(OrganizationUpdateParams.none(), requestOptions) @@ -137,18 +137,18 @@ interface OrganizationServiceAsync { fun list(): CompletableFuture> = list(OrganizationListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: OrganizationListParams = OrganizationListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture> = list(OrganizationListParams.none(), requestOptions) @@ -162,7 +162,7 @@ interface OrganizationServiceAsync { params: OrganizationDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -207,7 +207,7 @@ interface OrganizationServiceAsync { params: OrganizationAddMemberParams ): CompletableFuture = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ fun addMember( params: OrganizationAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -219,7 +219,7 @@ interface OrganizationServiceAsync { ): CompletableFuture = deleteMember(params, RequestOptions.none()) - /** @see [deleteMember] */ + /** @see deleteMember */ fun deleteMember( params: OrganizationDeleteMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -231,7 +231,7 @@ interface OrganizationServiceAsync { ): CompletableFuture = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ fun updateMember( params: OrganizationUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -263,7 +263,7 @@ interface OrganizationServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: OrganizationCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -276,19 +276,19 @@ interface OrganizationServiceAsync { fun update(): CompletableFuture> = update(OrganizationUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none() ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( requestOptions: RequestOptions ): CompletableFuture> = @@ -301,19 +301,19 @@ interface OrganizationServiceAsync { fun list(): CompletableFuture>> = list(OrganizationListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [list] */ + /** @see list */ fun list( params: OrganizationListParams = OrganizationListParams.none() ): CompletableFuture>> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture>> = @@ -328,7 +328,7 @@ interface OrganizationServiceAsync { ): CompletableFuture>> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -343,7 +343,7 @@ interface OrganizationServiceAsync { ): CompletableFuture> = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ fun addMember( params: OrganizationAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -358,7 +358,7 @@ interface OrganizationServiceAsync { ): CompletableFuture> = deleteMember(params, RequestOptions.none()) - /** @see [deleteMember] */ + /** @see deleteMember */ fun deleteMember( params: OrganizationDeleteMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -373,7 +373,7 @@ interface OrganizationServiceAsync { ): CompletableFuture> = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ fun updateMember( params: OrganizationUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt index 48f4107f..3e3a95a8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -102,7 +102,8 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val info: InfoServiceAsync.WithRawResponse by lazy { InfoServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -119,7 +120,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: OrganizationCreateParams, @@ -137,7 +137,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -151,7 +151,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: OrganizationUpdateParams, @@ -169,7 +168,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -183,7 +182,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: OrganizationListParams, @@ -200,7 +198,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -214,7 +212,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val deleteHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: OrganizationDeleteParams, @@ -232,7 +229,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -246,7 +243,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val addMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun addMember( params: OrganizationAddMemberParams, @@ -264,7 +260,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { addMemberHandler.handle(it) } .also { @@ -278,7 +274,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val deleteMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun deleteMember( params: OrganizationDeleteMemberParams, @@ -296,7 +291,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteMemberHandler.handle(it) } .also { @@ -310,7 +305,6 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val updateMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun updateMember( params: OrganizationUpdateMemberParams, @@ -328,7 +322,7 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateMemberHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt index 9b86613a..bb364c0e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt @@ -72,18 +72,18 @@ interface ProviderServiceAsync { fun listBudgets(): CompletableFuture = listBudgets(ProviderListBudgetsParams.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none() ): CompletableFuture = listBudgets(params, RequestOptions.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( requestOptions: RequestOptions ): CompletableFuture = @@ -110,19 +110,19 @@ interface ProviderServiceAsync { fun listBudgets(): CompletableFuture> = listBudgets(ProviderListBudgetsParams.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none() ): CompletableFuture> = listBudgets(params, RequestOptions.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt index b7d5b739..cf0e52b9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ProviderServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C private val listBudgetsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listBudgets( params: ProviderListBudgetsParams, @@ -69,7 +69,7 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listBudgetsHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt index d43e5d80..a5380824 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsync.kt @@ -31,18 +31,18 @@ interface RerankServiceAsync { /** Rerank */ fun create(): CompletableFuture = create(RerankCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: RerankCreateParams = RerankCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: RerankCreateParams = RerankCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(RerankCreateParams.none(), requestOptions) @@ -50,18 +50,18 @@ interface RerankServiceAsync { fun createV1(): CompletableFuture = createV1(RerankCreateV1Params.none()) - /** @see [createV1] */ + /** @see createV1 */ fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [createV1] */ + /** @see createV1 */ fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none() ): CompletableFuture = createV1(params, RequestOptions.none()) - /** @see [createV1] */ + /** @see createV1 */ fun createV1(requestOptions: RequestOptions): CompletableFuture = createV1(RerankCreateV1Params.none(), requestOptions) @@ -69,18 +69,18 @@ interface RerankServiceAsync { fun createV2(): CompletableFuture = createV2(RerankCreateV2Params.none()) - /** @see [createV2] */ + /** @see createV2 */ fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [createV2] */ + /** @see createV2 */ fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none() ): CompletableFuture = createV2(params, RequestOptions.none()) - /** @see [createV2] */ + /** @see createV2 */ fun createV2(requestOptions: RequestOptions): CompletableFuture = createV2(RerankCreateV2Params.none(), requestOptions) @@ -105,19 +105,19 @@ interface RerankServiceAsync { fun create(): CompletableFuture> = create(RerankCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: RerankCreateParams = RerankCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: RerankCreateParams = RerankCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -130,19 +130,19 @@ interface RerankServiceAsync { fun createV1(): CompletableFuture> = createV1(RerankCreateV1Params.none()) - /** @see [createV1] */ + /** @see createV1 */ fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [createV1] */ + /** @see createV1 */ fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none() ): CompletableFuture> = createV1(params, RequestOptions.none()) - /** @see [createV1] */ + /** @see createV1 */ fun createV1( requestOptions: RequestOptions ): CompletableFuture> = @@ -155,19 +155,19 @@ interface RerankServiceAsync { fun createV2(): CompletableFuture> = createV2(RerankCreateV2Params.none()) - /** @see [createV2] */ + /** @see createV2 */ fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [createV2] */ + /** @see createV2 */ fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none() ): CompletableFuture> = createV2(params, RequestOptions.none()) - /** @see [createV2] */ + /** @see createV2 */ fun createV2( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt index 965dde90..cfd3765d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -60,7 +60,8 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RerankServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -71,7 +72,6 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: RerankCreateParams, @@ -89,7 +89,7 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -103,7 +103,6 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createV1Handler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createV1( params: RerankCreateV1Params, @@ -121,7 +120,7 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createV1Handler.handle(it) } .also { @@ -135,7 +134,6 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createV2Handler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createV2( params: RerankCreateV2Params, @@ -153,7 +151,7 @@ class RerankServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createV2Handler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt index bd734cf9..7e1458e5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsync.kt @@ -44,18 +44,18 @@ interface ResponseServiceAsync { */ fun create(): CompletableFuture = create(ResponseCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ResponseCreateParams = ResponseCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: ResponseCreateParams = ResponseCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(ResponseCreateParams.none(), requestOptions) @@ -72,7 +72,7 @@ interface ResponseServiceAsync { fun retrieve(responseId: String): CompletableFuture = retrieve(responseId, ResponseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), @@ -80,24 +80,24 @@ interface ResponseServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), ): CompletableFuture = retrieve(responseId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ResponseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: ResponseRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, requestOptions: RequestOptions, @@ -117,7 +117,7 @@ interface ResponseServiceAsync { fun delete(responseId: String): CompletableFuture = delete(responseId, ResponseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), @@ -125,23 +125,23 @@ interface ResponseServiceAsync { ): CompletableFuture = delete(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), ): CompletableFuture = delete(responseId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: ResponseDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, requestOptions: RequestOptions, @@ -171,19 +171,19 @@ interface ResponseServiceAsync { fun create(): CompletableFuture> = create(ResponseCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ResponseCreateParams = ResponseCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: ResponseCreateParams = ResponseCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -198,7 +198,7 @@ interface ResponseServiceAsync { ): CompletableFuture> = retrieve(responseId, ResponseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), @@ -206,26 +206,26 @@ interface ResponseServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), ): CompletableFuture> = retrieve(responseId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ResponseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ResponseRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, requestOptions: RequestOptions, @@ -239,7 +239,7 @@ interface ResponseServiceAsync { fun delete(responseId: String): CompletableFuture> = delete(responseId, ResponseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), @@ -247,26 +247,26 @@ interface ResponseServiceAsync { ): CompletableFuture> = delete(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), ): CompletableFuture> = delete(responseId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: ResponseDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt index aaa53f42..c715184a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -70,7 +70,8 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ResponseServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val inputItems: InputItemServiceAsync.WithRawResponse by lazy { InputItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -87,7 +88,6 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ResponseCreateParams, @@ -105,7 +105,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -119,7 +119,6 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ResponseRetrieveParams, @@ -139,7 +138,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: ResponseDeleteParams, @@ -174,7 +172,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt index eb3265fb..887672c9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsync.kt @@ -27,18 +27,18 @@ interface RouteServiceAsync { /** Get a list of available routes in the FastAPI application. */ fun list(): CompletableFuture = list(RouteListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: RouteListParams = RouteListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: RouteListParams = RouteListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(RouteListParams.none(), requestOptions) @@ -61,19 +61,19 @@ interface RouteServiceAsync { fun list(): CompletableFuture> = list(RouteListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: RouteListParams = RouteListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: RouteListParams = RouteListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt index c20fc0b2..cd0c5bd9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RouteServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,7 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie ) private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: RouteListParams, @@ -68,7 +69,7 @@ class RouteServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt index 90bca4ce..c972089a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsync.kt @@ -50,18 +50,18 @@ interface SettingServiceAsync { fun retrieve(): CompletableFuture = retrieve(SettingRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none() ): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(requestOptions: RequestOptions): CompletableFuture = retrieve(SettingRetrieveParams.none(), requestOptions) @@ -86,19 +86,19 @@ interface SettingServiceAsync { fun retrieve(): CompletableFuture> = retrieve(SettingRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none() ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt index a34e4efc..5b274187 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class SettingServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SettingServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class SettingServiceAsyncImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: SettingRetrieveParams, @@ -69,7 +69,7 @@ class SettingServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt index 9b110fb3..6d704bac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsync.kt @@ -79,19 +79,19 @@ interface SpendServiceAsync { fun calculateSpend(): CompletableFuture = calculateSpend(SpendCalculateSpendParams.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none() ): CompletableFuture = calculateSpend(params, RequestOptions.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( requestOptions: RequestOptions ): CompletableFuture = @@ -128,18 +128,18 @@ interface SpendServiceAsync { fun listLogs(): CompletableFuture> = listLogs(SpendListLogsParams.none()) - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none() ): CompletableFuture> = listLogs(params, RequestOptions.none()) - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs(requestOptions: RequestOptions): CompletableFuture> = listLogs(SpendListLogsParams.none(), requestOptions) @@ -160,18 +160,18 @@ interface SpendServiceAsync { fun listTags(): CompletableFuture> = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): CompletableFuture> = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags(requestOptions: RequestOptions): CompletableFuture> = listTags(SpendListTagsParams.none(), requestOptions) @@ -194,19 +194,19 @@ interface SpendServiceAsync { fun calculateSpend(): CompletableFuture> = calculateSpend(SpendCalculateSpendParams.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none() ): CompletableFuture> = calculateSpend(params, RequestOptions.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( requestOptions: RequestOptions ): CompletableFuture> = @@ -219,19 +219,19 @@ interface SpendServiceAsync { fun listLogs(): CompletableFuture>> = listLogs(SpendListLogsParams.none()) - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none() ): CompletableFuture>> = listLogs(params, RequestOptions.none()) - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( requestOptions: RequestOptions ): CompletableFuture>> = @@ -244,19 +244,19 @@ interface SpendServiceAsync { fun listTags(): CompletableFuture>> = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): CompletableFuture>> = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( requestOptions: RequestOptions ): CompletableFuture>> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt index 8cc55d70..92f3d4a5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -60,7 +60,8 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SpendServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -71,7 +72,6 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val calculateSpendHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun calculateSpend( params: SpendCalculateSpendParams, @@ -89,7 +89,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { calculateSpendHandler.handle(it) } .also { @@ -103,7 +103,6 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val listLogsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listLogs( params: SpendListLogsParams, @@ -120,7 +119,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listLogsHandler.handle(it) } .also { @@ -134,7 +133,6 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val listTagsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listTags( params: SpendListTagsParams, @@ -151,7 +149,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listTagsHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt index e395dd04..0285e2c2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt @@ -113,18 +113,18 @@ interface TeamServiceAsync { */ fun create(): CompletableFuture = create(TeamCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: TeamCreateParams = TeamCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: TeamCreateParams = TeamCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(TeamCreateParams.none(), requestOptions) @@ -179,7 +179,7 @@ interface TeamServiceAsync { fun update(params: TeamUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: TeamUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -197,17 +197,17 @@ interface TeamServiceAsync { */ fun list(): CompletableFuture = list(TeamListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: TeamListParams = TeamListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: TeamListParams = TeamListParams.none()): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(TeamListParams.none(), requestOptions) @@ -227,7 +227,7 @@ interface TeamServiceAsync { fun delete(params: TeamDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: TeamDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -251,7 +251,7 @@ interface TeamServiceAsync { fun addMember(params: TeamAddMemberParams): CompletableFuture = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ fun addMember( params: TeamAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -276,7 +276,7 @@ interface TeamServiceAsync { fun block(params: TeamBlockParams): CompletableFuture = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: TeamBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -296,7 +296,7 @@ interface TeamServiceAsync { fun disableLogging(teamId: String): CompletableFuture = disableLogging(teamId, TeamDisableLoggingParams.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), @@ -304,25 +304,25 @@ interface TeamServiceAsync { ): CompletableFuture = disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), ): CompletableFuture = disableLogging(teamId, params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( params: TeamDisableLoggingParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( params: TeamDisableLoggingParams ): CompletableFuture = disableLogging(params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, requestOptions: RequestOptions, @@ -333,18 +333,18 @@ interface TeamServiceAsync { fun listAvailable(): CompletableFuture = listAvailable(TeamListAvailableParams.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none() ): CompletableFuture = listAvailable(params, RequestOptions.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( requestOptions: RequestOptions ): CompletableFuture = @@ -370,7 +370,7 @@ interface TeamServiceAsync { fun removeMember(params: TeamRemoveMemberParams): CompletableFuture = removeMember(params, RequestOptions.none()) - /** @see [removeMember] */ + /** @see removeMember */ fun removeMember( params: TeamRemoveMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -389,18 +389,18 @@ interface TeamServiceAsync { fun retrieveInfo(): CompletableFuture = retrieveInfo(TeamRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none() ): CompletableFuture = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): CompletableFuture = retrieveInfo(TeamRetrieveInfoParams.none(), requestOptions) @@ -420,7 +420,7 @@ interface TeamServiceAsync { fun unblock(params: TeamUnblockParams): CompletableFuture = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: TeamUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -434,7 +434,7 @@ interface TeamServiceAsync { fun updateMember(params: TeamUpdateMemberParams): CompletableFuture = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ fun updateMember( params: TeamUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -461,19 +461,19 @@ interface TeamServiceAsync { fun create(): CompletableFuture> = create(TeamCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: TeamCreateParams = TeamCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: TeamCreateParams = TeamCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -488,7 +488,7 @@ interface TeamServiceAsync { ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: TeamUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -501,19 +501,19 @@ interface TeamServiceAsync { fun list(): CompletableFuture> = list(TeamListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: TeamListParams = TeamListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: TeamListParams = TeamListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -528,7 +528,7 @@ interface TeamServiceAsync { ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: TeamDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -543,7 +543,7 @@ interface TeamServiceAsync { ): CompletableFuture> = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ fun addMember( params: TeamAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -556,7 +556,7 @@ interface TeamServiceAsync { fun block(params: TeamBlockParams): CompletableFuture> = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: TeamBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -571,7 +571,7 @@ interface TeamServiceAsync { ): CompletableFuture> = disableLogging(teamId, TeamDisableLoggingParams.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), @@ -579,26 +579,26 @@ interface TeamServiceAsync { ): CompletableFuture> = disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), ): CompletableFuture> = disableLogging(teamId, params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( params: TeamDisableLoggingParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( params: TeamDisableLoggingParams ): CompletableFuture> = disableLogging(params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, requestOptions: RequestOptions, @@ -612,19 +612,19 @@ interface TeamServiceAsync { fun listAvailable(): CompletableFuture> = listAvailable(TeamListAvailableParams.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none() ): CompletableFuture> = listAvailable(params, RequestOptions.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( requestOptions: RequestOptions ): CompletableFuture> = @@ -639,7 +639,7 @@ interface TeamServiceAsync { ): CompletableFuture> = removeMember(params, RequestOptions.none()) - /** @see [removeMember] */ + /** @see removeMember */ fun removeMember( params: TeamRemoveMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -652,19 +652,19 @@ interface TeamServiceAsync { fun retrieveInfo(): CompletableFuture> = retrieveInfo(TeamRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = @@ -679,7 +679,7 @@ interface TeamServiceAsync { ): CompletableFuture> = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: TeamUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -694,7 +694,7 @@ interface TeamServiceAsync { ): CompletableFuture> = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ fun updateMember( params: TeamUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt index ecb9aeeb..678995ca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -155,7 +155,8 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TeamServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val model: ModelServiceAsync.WithRawResponse by lazy { ModelServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -177,7 +178,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun callback(): CallbackServiceAsync.WithRawResponse = callback private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: TeamCreateParams, @@ -195,7 +196,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -208,7 +209,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: TeamUpdateParams, @@ -226,7 +227,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -239,7 +240,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: TeamListParams, @@ -256,7 +257,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -269,7 +270,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: TeamDeleteParams, @@ -287,7 +288,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -301,7 +302,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val addMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun addMember( params: TeamAddMemberParams, @@ -319,7 +319,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { addMemberHandler.handle(it) } .also { @@ -332,7 +332,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val blockHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun block( params: TeamBlockParams, @@ -350,7 +350,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { blockHandler.handle(it) } .also { @@ -364,7 +364,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val disableLoggingHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun disableLogging( params: TeamDisableLoggingParams, @@ -385,7 +384,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { disableLoggingHandler.handle(it) } .also { @@ -399,7 +398,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val listAvailableHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listAvailable( params: TeamListAvailableParams, @@ -416,7 +414,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listAvailableHandler.handle(it) } .also { @@ -430,7 +428,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val removeMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun removeMember( params: TeamRemoveMemberParams, @@ -448,7 +445,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { removeMemberHandler.handle(it) } .also { @@ -462,7 +459,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: TeamRetrieveInfoParams, @@ -479,7 +475,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { @@ -493,7 +489,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val unblockHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun unblock( params: TeamUnblockParams, @@ -511,7 +506,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { unblockHandler.handle(it) } .also { @@ -525,7 +520,6 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien private val updateMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun updateMember( params: TeamUpdateMemberParams, @@ -543,7 +537,7 @@ class TeamServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateMemberHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt index 795abdce..7c7fe381 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsync.kt @@ -35,17 +35,17 @@ interface TestServiceAsync { */ fun ping(): CompletableFuture = ping(TestPingParams.none()) - /** @see [ping] */ + /** @see ping */ fun ping( params: TestPingParams = TestPingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [ping] */ + /** @see ping */ fun ping(params: TestPingParams = TestPingParams.none()): CompletableFuture = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ fun ping(requestOptions: RequestOptions): CompletableFuture = ping(TestPingParams.none(), requestOptions) @@ -66,19 +66,19 @@ interface TestServiceAsync { fun ping(): CompletableFuture> = ping(TestPingParams.none()) - /** @see [ping] */ + /** @see ping */ fun ping( params: TestPingParams = TestPingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [ping] */ + /** @see ping */ fun ping( params: TestPingParams = TestPingParams.none() ): CompletableFuture> = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ fun ping( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt index c0e4c6fe..d76a4aa4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TestServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class TestServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TestServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,7 @@ class TestServiceAsyncImpl internal constructor(private val clientOptions: Clien ) private val pingHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun ping( params: TestPingParams, @@ -68,7 +69,7 @@ class TestServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { pingHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt index 17e0e5e4..5c8beba3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsync.kt @@ -39,18 +39,18 @@ interface ThreadServiceAsync { */ fun create(): CompletableFuture = create(ThreadCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ThreadCreateParams = ThreadCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: ThreadCreateParams = ThreadCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(ThreadCreateParams.none(), requestOptions) @@ -62,7 +62,7 @@ interface ThreadServiceAsync { fun retrieve(threadId: String): CompletableFuture = retrieve(threadId, ThreadRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), @@ -70,23 +70,23 @@ interface ThreadServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), ): CompletableFuture = retrieve(threadId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: ThreadRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, requestOptions: RequestOptions, @@ -118,19 +118,19 @@ interface ThreadServiceAsync { fun create(): CompletableFuture> = create(ThreadCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ThreadCreateParams = ThreadCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: ThreadCreateParams = ThreadCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -143,7 +143,7 @@ interface ThreadServiceAsync { fun retrieve(threadId: String): CompletableFuture> = retrieve(threadId, ThreadRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), @@ -151,26 +151,26 @@ interface ThreadServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), ): CompletableFuture> = retrieve(threadId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ThreadRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt index 0f474d19..a1962cd4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -65,7 +65,8 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ThreadServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val messages: MessageServiceAsync.WithRawResponse by lazy { MessageServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -88,7 +89,6 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ThreadCreateParams, @@ -106,7 +106,7 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -120,7 +120,6 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ThreadRetrieveParams, @@ -140,7 +139,7 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt index 279edf4d..6b594ca7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt @@ -108,18 +108,18 @@ interface UserServiceAsync { */ fun create(): CompletableFuture = create(UserCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: UserCreateParams = UserCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: UserCreateParams = UserCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(UserCreateParams.none(), requestOptions) @@ -175,18 +175,18 @@ interface UserServiceAsync { */ fun update(): CompletableFuture = update(UserUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( params: UserUpdateParams = UserUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update( params: UserUpdateParams = UserUpdateParams.none() ): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(requestOptions: RequestOptions): CompletableFuture = update(UserUpdateParams.none(), requestOptions) @@ -209,17 +209,17 @@ interface UserServiceAsync { */ fun list(): CompletableFuture = list(UserListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: UserListParams = UserListParams.none()): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(UserListParams.none(), requestOptions) @@ -241,7 +241,7 @@ interface UserServiceAsync { fun delete(params: UserDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: UserDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -261,18 +261,18 @@ interface UserServiceAsync { fun retrieveInfo(): CompletableFuture = retrieveInfo(UserRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none() ): CompletableFuture = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): CompletableFuture = retrieveInfo(UserRetrieveInfoParams.none(), requestOptions) @@ -293,19 +293,19 @@ interface UserServiceAsync { fun create(): CompletableFuture> = create(UserCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: UserCreateParams = UserCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: UserCreateParams = UserCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -318,19 +318,19 @@ interface UserServiceAsync { fun update(): CompletableFuture> = update(UserUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( params: UserUpdateParams = UserUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: UserUpdateParams = UserUpdateParams.none() ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( requestOptions: RequestOptions ): CompletableFuture> = @@ -343,19 +343,19 @@ interface UserServiceAsync { fun list(): CompletableFuture> = list(UserListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: UserListParams = UserListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -370,7 +370,7 @@ interface UserServiceAsync { ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: UserDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -383,19 +383,19 @@ interface UserServiceAsync { fun retrieveInfo(): CompletableFuture> = retrieveInfo(UserRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt index c169e2ec..85e93b33 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -78,7 +78,8 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UserServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -88,7 +89,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: UserCreateParams, @@ -106,7 +107,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -119,7 +120,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: UserUpdateParams, @@ -137,7 +138,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -150,7 +151,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: UserListParams, @@ -167,7 +168,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -180,7 +181,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: UserDeleteParams, @@ -198,7 +199,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -212,7 +213,6 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: UserRetrieveInfoParams, @@ -229,7 +229,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt index 5f2b1507..2827e0a3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsync.kt @@ -43,7 +43,7 @@ interface UtilServiceAsync { ): CompletableFuture = getSupportedOpenAIParams(params, RequestOptions.none()) - /** @see [getSupportedOpenAIParams] */ + /** @see getSupportedOpenAIParams */ fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -53,7 +53,7 @@ interface UtilServiceAsync { fun tokenCounter(params: UtilTokenCounterParams): CompletableFuture = tokenCounter(params, RequestOptions.none()) - /** @see [tokenCounter] */ + /** @see tokenCounter */ fun tokenCounter( params: UtilTokenCounterParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -65,7 +65,7 @@ interface UtilServiceAsync { ): CompletableFuture = transformRequest(params, RequestOptions.none()) - /** @see [transformRequest] */ + /** @see transformRequest */ fun transformRequest( params: UtilTransformRequestParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -90,7 +90,7 @@ interface UtilServiceAsync { ): CompletableFuture> = getSupportedOpenAIParams(params, RequestOptions.none()) - /** @see [getSupportedOpenAIParams] */ + /** @see getSupportedOpenAIParams */ fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -105,7 +105,7 @@ interface UtilServiceAsync { ): CompletableFuture> = tokenCounter(params, RequestOptions.none()) - /** @see [tokenCounter] */ + /** @see tokenCounter */ fun tokenCounter( params: UtilTokenCounterParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -120,7 +120,7 @@ interface UtilServiceAsync { ): CompletableFuture> = transformRequest(params, RequestOptions.none()) - /** @see [transformRequest] */ + /** @see transformRequest */ fun transformRequest( params: UtilTransformRequestParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt index db944d30..4f944509 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -60,7 +60,8 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UtilServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -71,7 +72,6 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien private val getSupportedOpenAIParamsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, @@ -88,7 +88,7 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { getSupportedOpenAIParamsHandler.handle(it) } .also { @@ -102,7 +102,6 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien private val tokenCounterHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun tokenCounter( params: UtilTokenCounterParams, @@ -120,7 +119,7 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { tokenCounterHandler.handle(it) } .also { @@ -134,7 +133,6 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien private val transformRequestHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun transformRequest( params: UtilTransformRequestParams, @@ -152,7 +150,7 @@ class UtilServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { transformRequestHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt index 44cfe4d0..65f0dc00 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsync.kt @@ -40,7 +40,7 @@ interface VertexAiServiceAsync { fun create(endpoint: String): CompletableFuture = create(endpoint, VertexAiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), @@ -48,23 +48,23 @@ interface VertexAiServiceAsync { ): CompletableFuture = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), ): CompletableFuture = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: VertexAiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: VertexAiCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -79,7 +79,7 @@ interface VertexAiServiceAsync { fun retrieve(endpoint: String): CompletableFuture = retrieve(endpoint, VertexAiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), @@ -87,24 +87,24 @@ interface VertexAiServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), ): CompletableFuture = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: VertexAiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: VertexAiRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -119,7 +119,7 @@ interface VertexAiServiceAsync { fun update(endpoint: String): CompletableFuture = update(endpoint, VertexAiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), @@ -127,23 +127,23 @@ interface VertexAiServiceAsync { ): CompletableFuture = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), ): CompletableFuture = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: VertexAiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update(params: VertexAiUpdateParams): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -158,7 +158,7 @@ interface VertexAiServiceAsync { fun delete(endpoint: String): CompletableFuture = delete(endpoint, VertexAiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), @@ -166,23 +166,23 @@ interface VertexAiServiceAsync { ): CompletableFuture = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), ): CompletableFuture = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: VertexAiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [delete] */ + /** @see delete */ fun delete(params: VertexAiDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -197,7 +197,7 @@ interface VertexAiServiceAsync { fun patch(endpoint: String): CompletableFuture = patch(endpoint, VertexAiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), @@ -205,23 +205,23 @@ interface VertexAiServiceAsync { ): CompletableFuture = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), ): CompletableFuture = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [patch] */ + /** @see patch */ fun patch(params: VertexAiPatchParams): CompletableFuture = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, @@ -249,7 +249,7 @@ interface VertexAiServiceAsync { fun create(endpoint: String): CompletableFuture> = create(endpoint, VertexAiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), @@ -257,26 +257,26 @@ interface VertexAiServiceAsync { ): CompletableFuture> = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), ): CompletableFuture> = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: VertexAiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: VertexAiCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, requestOptions: RequestOptions, @@ -292,7 +292,7 @@ interface VertexAiServiceAsync { ): CompletableFuture> = retrieve(endpoint, VertexAiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), @@ -300,26 +300,26 @@ interface VertexAiServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), ): CompletableFuture> = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: VertexAiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: VertexAiRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, requestOptions: RequestOptions, @@ -333,7 +333,7 @@ interface VertexAiServiceAsync { fun update(endpoint: String): CompletableFuture> = update(endpoint, VertexAiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), @@ -341,26 +341,26 @@ interface VertexAiServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), ): CompletableFuture> = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: VertexAiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: VertexAiUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, requestOptions: RequestOptions, @@ -374,7 +374,7 @@ interface VertexAiServiceAsync { fun delete(endpoint: String): CompletableFuture> = delete(endpoint, VertexAiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), @@ -382,26 +382,26 @@ interface VertexAiServiceAsync { ): CompletableFuture> = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), ): CompletableFuture> = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: VertexAiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [delete] */ + /** @see delete */ fun delete( params: VertexAiDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, requestOptions: RequestOptions, @@ -415,7 +415,7 @@ interface VertexAiServiceAsync { fun patch(endpoint: String): CompletableFuture> = patch(endpoint, VertexAiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), @@ -423,26 +423,26 @@ interface VertexAiServiceAsync { ): CompletableFuture> = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), ): CompletableFuture> = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [patch] */ + /** @see patch */ fun patch( params: VertexAiPatchParams ): CompletableFuture> = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt index 0c8c01dc..c14a6f0d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -80,7 +80,8 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : VertexAiServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -91,7 +92,6 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: VertexAiCreateParams, @@ -112,7 +112,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: VertexAiRetrieveParams, @@ -146,7 +145,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -160,7 +159,6 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: VertexAiUpdateParams, @@ -181,7 +179,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -195,7 +193,6 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: VertexAiDeleteParams, @@ -216,7 +213,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -230,7 +227,6 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: VertexAiPatchParams, @@ -251,7 +247,7 @@ class VertexAiServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt index 77d470d4..278d3f3e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsync.kt @@ -31,18 +31,18 @@ interface SpeechServiceAsync { */ fun create(): CompletableFuture = create(SpeechCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: SpeechCreateParams = SpeechCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: SpeechCreateParams = SpeechCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(SpeechCreateParams.none(), requestOptions) @@ -67,19 +67,19 @@ interface SpeechServiceAsync { fun create(): CompletableFuture> = create(SpeechCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: SpeechCreateParams = SpeechCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: SpeechCreateParams = SpeechCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt index dd05d93e..eec07394 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.audio import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SpeechServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: SpeechCreateParams, @@ -71,7 +71,7 @@ class SpeechServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt index f7922b23..e87d3eef 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsync.kt @@ -32,7 +32,7 @@ interface TranscriptionServiceAsync { fun create(params: TranscriptionCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -62,7 +62,7 @@ interface TranscriptionServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt index 4896f1e8..cc37802f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.audio import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.multipartFormData @@ -42,7 +42,8 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TranscriptionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: TranscriptionCreateParams, @@ -71,7 +71,7 @@ class TranscriptionServiceAsyncImpl internal constructor(private val clientOptio return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt index 053da526..58702a0a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsync.kt @@ -40,7 +40,7 @@ interface CancelServiceAsync { fun cancel(batchId: String): CompletableFuture = cancel(batchId, CancelCancelParams.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), @@ -48,23 +48,23 @@ interface CancelServiceAsync { ): CompletableFuture = cancel(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), ): CompletableFuture = cancel(batchId, params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [cancel] */ + /** @see cancel */ fun cancel(params: CancelCancelParams): CompletableFuture = cancel(params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, requestOptions: RequestOptions, @@ -92,7 +92,7 @@ interface CancelServiceAsync { fun cancel(batchId: String): CompletableFuture> = cancel(batchId, CancelCancelParams.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), @@ -100,26 +100,26 @@ interface CancelServiceAsync { ): CompletableFuture> = cancel(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), ): CompletableFuture> = cancel(batchId, params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [cancel] */ + /** @see cancel */ fun cancel( params: CancelCancelParams ): CompletableFuture> = cancel(params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt index e6fca64d..8b947e95 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.batches import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -44,7 +44,8 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CancelServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli private val cancelHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun cancel( params: CancelCancelParams, @@ -76,7 +76,7 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { cancelHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt index 045388c2..de34ce1f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsync.kt @@ -28,18 +28,18 @@ interface RediServiceAsync { fun retrieveInfo(): CompletableFuture = retrieveInfo(RediRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none() ): CompletableFuture = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): CompletableFuture = retrieveInfo(RediRetrieveInfoParams.none(), requestOptions) @@ -60,19 +60,19 @@ interface RediServiceAsync { fun retrieveInfo(): CompletableFuture> = retrieveInfo(RediRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none() ): CompletableFuture> = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt index c5af150d..6e2e0724 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.cache import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class RediServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RediServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class RediServiceAsyncImpl internal constructor(private val clientOptions: Clien private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: RediRetrieveInfoParams, @@ -69,7 +69,7 @@ class RediServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt index f10d9536..1fdb4fba 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsync.kt @@ -46,18 +46,18 @@ interface CompletionServiceAsync { fun create(): CompletableFuture = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(CompletionCreateParams.none(), requestOptions) @@ -83,19 +83,19 @@ interface CompletionServiceAsync { fun create(): CompletableFuture> = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt index 750b6ba5..035b9343 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.chat import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CompletionServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CompletionCreateParams, @@ -71,7 +71,7 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt index 28c8a1ad..013b2449 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt @@ -34,7 +34,7 @@ interface PassThroughEndpointServiceAsync { params: PassThroughEndpointCreateParams ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: PassThroughEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -44,7 +44,7 @@ interface PassThroughEndpointServiceAsync { fun update(endpointId: String): CompletableFuture = update(endpointId, PassThroughEndpointUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), @@ -52,25 +52,25 @@ interface PassThroughEndpointServiceAsync { ): CompletableFuture = update(params.toBuilder().endpointId(endpointId).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), ): CompletableFuture = update(endpointId, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [update] */ + /** @see update */ fun update( params: PassThroughEndpointUpdateParams ): CompletableFuture = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, requestOptions: RequestOptions, @@ -85,18 +85,18 @@ interface PassThroughEndpointServiceAsync { fun list(): CompletableFuture = list(PassThroughEndpointListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none() ): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(PassThroughEndpointListParams.none(), requestOptions) @@ -109,7 +109,7 @@ interface PassThroughEndpointServiceAsync { params: PassThroughEndpointDeleteParams ): CompletableFuture = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: PassThroughEndpointDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -139,7 +139,7 @@ interface PassThroughEndpointServiceAsync { ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: PassThroughEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -154,7 +154,7 @@ interface PassThroughEndpointServiceAsync { ): CompletableFuture> = update(endpointId, PassThroughEndpointUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), @@ -162,26 +162,26 @@ interface PassThroughEndpointServiceAsync { ): CompletableFuture> = update(params.toBuilder().endpointId(endpointId).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), ): CompletableFuture> = update(endpointId, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [update] */ + /** @see update */ fun update( params: PassThroughEndpointUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, requestOptions: RequestOptions, @@ -195,19 +195,19 @@ interface PassThroughEndpointServiceAsync { fun list(): CompletableFuture> = list(PassThroughEndpointListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -222,7 +222,7 @@ interface PassThroughEndpointServiceAsync { ): CompletableFuture> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: PassThroughEndpointDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt index 5b1c9a02..bc9d407a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.config import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -75,7 +75,8 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PassThroughEndpointServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -86,7 +87,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: PassThroughEndpointCreateParams, @@ -104,7 +104,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -118,7 +118,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: PassThroughEndpointUpdateParams, @@ -139,7 +138,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -153,7 +152,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: PassThroughEndpointListParams, @@ -170,7 +168,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -184,7 +182,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: PassThroughEndpointDeleteParams, @@ -202,7 +199,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt index aba04aec..2d95b914 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsync.kt @@ -46,7 +46,7 @@ interface ChatServiceAsync { fun complete(model: String): CompletableFuture = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -54,23 +54,23 @@ interface ChatServiceAsync { ): CompletableFuture = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): CompletableFuture = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [complete] */ + /** @see complete */ fun complete(params: ChatCompleteParams): CompletableFuture = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, @@ -94,7 +94,7 @@ interface ChatServiceAsync { fun complete(model: String): CompletableFuture> = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -102,26 +102,26 @@ interface ChatServiceAsync { ): CompletableFuture> = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): CompletableFuture> = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt index 114a7270..da547e3a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.engines import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -44,7 +44,8 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ChatServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: ChatCompleteParams, @@ -76,7 +76,7 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt index 2fa183aa..b68c7983 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsync.kt @@ -43,7 +43,7 @@ interface ContentServiceAsync { params: ContentRetrieveParams, ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fileId: String, params: ContentRetrieveParams, @@ -51,11 +51,11 @@ interface ContentServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: ContentRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -85,7 +85,7 @@ interface ContentServiceAsync { ): CompletableFuture> = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fileId: String, params: ContentRetrieveParams, @@ -93,13 +93,13 @@ interface ContentServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ContentRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt index cf7b9b24..0317350d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.files import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -43,7 +43,8 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ContentServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ContentRetrieveParams, @@ -80,7 +80,7 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt index 1c2dd224..fa83e8b3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsync.kt @@ -52,7 +52,7 @@ interface JobServiceAsync { fun create(params: JobCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: JobCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -72,7 +72,7 @@ interface JobServiceAsync { ): CompletableFuture = retrieve(fineTuningJobId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fineTuningJobId: String, params: JobRetrieveParams, @@ -80,11 +80,11 @@ interface JobServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: JobRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: JobRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -102,7 +102,7 @@ interface JobServiceAsync { fun list(params: JobListParams): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: JobListParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -127,7 +127,7 @@ interface JobServiceAsync { fun create(params: JobCreateParams): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: JobCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -143,7 +143,7 @@ interface JobServiceAsync { ): CompletableFuture> = retrieve(fineTuningJobId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fineTuningJobId: String, params: JobRetrieveParams, @@ -151,13 +151,13 @@ interface JobServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: JobRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: JobRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -170,7 +170,7 @@ interface JobServiceAsync { fun list(params: JobListParams): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: JobListParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt index bead1635..c8ab7931 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.finetuning import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -68,7 +68,8 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : JobServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val cancel: CancelServiceAsync.WithRawResponse by lazy { CancelServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -84,7 +85,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun cancel(): CancelServiceAsync.WithRawResponse = cancel private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: JobCreateParams, @@ -102,7 +103,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -116,7 +117,6 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: JobRetrieveParams, @@ -136,7 +136,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -149,7 +149,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: JobListParams, @@ -166,7 +166,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt index b7a67db8..774223ab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsync.kt @@ -37,7 +37,7 @@ interface CancelServiceAsync { fun create(fineTuningJobId: String): CompletableFuture = create(fineTuningJobId, CancelCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), @@ -45,24 +45,24 @@ interface CancelServiceAsync { ): CompletableFuture = create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), ): CompletableFuture = create(fineTuningJobId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: CancelCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, requestOptions: RequestOptions, @@ -92,7 +92,7 @@ interface CancelServiceAsync { ): CompletableFuture> = create(fineTuningJobId, CancelCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), @@ -100,26 +100,26 @@ interface CancelServiceAsync { ): CompletableFuture> = create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), ): CompletableFuture> = create(fineTuningJobId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: CancelCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt index c733f5dd..f82c0ade 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.finetuning.jobs import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -44,7 +44,8 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CancelServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CancelCreateParams, @@ -76,7 +76,7 @@ class CancelServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt index 619ec95a..464e2cc0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsync.kt @@ -45,18 +45,18 @@ interface SpendServiceAsync { fun listTags(): CompletableFuture> = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): CompletableFuture> = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags(requestOptions: RequestOptions): CompletableFuture> = listTags(SpendListTagsParams.none(), requestOptions) @@ -70,18 +70,18 @@ interface SpendServiceAsync { */ fun reset(): CompletableFuture = reset(SpendResetParams.none()) - /** @see [reset] */ + /** @see reset */ fun reset( params: SpendResetParams = SpendResetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [reset] */ + /** @see reset */ fun reset( params: SpendResetParams = SpendResetParams.none() ): CompletableFuture = reset(params, RequestOptions.none()) - /** @see [reset] */ + /** @see reset */ fun reset(requestOptions: RequestOptions): CompletableFuture = reset(SpendResetParams.none(), requestOptions) @@ -94,19 +94,19 @@ interface SpendServiceAsync { fun retrieveReport(): CompletableFuture> = retrieveReport(SpendRetrieveReportParams.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none() ): CompletableFuture> = retrieveReport(params, RequestOptions.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( requestOptions: RequestOptions ): CompletableFuture> = @@ -131,19 +131,19 @@ interface SpendServiceAsync { fun listTags(): CompletableFuture>> = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): CompletableFuture>> = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( requestOptions: RequestOptions ): CompletableFuture>> = @@ -156,19 +156,19 @@ interface SpendServiceAsync { fun reset(): CompletableFuture> = reset(SpendResetParams.none()) - /** @see [reset] */ + /** @see reset */ fun reset( params: SpendResetParams = SpendResetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [reset] */ + /** @see reset */ fun reset( params: SpendResetParams = SpendResetParams.none() ): CompletableFuture> = reset(params, RequestOptions.none()) - /** @see [reset] */ + /** @see reset */ fun reset( requestOptions: RequestOptions ): CompletableFuture> = @@ -182,19 +182,19 @@ interface SpendServiceAsync { CompletableFuture>> = retrieveReport(SpendRetrieveReportParams.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none() ): CompletableFuture>> = retrieveReport(params, RequestOptions.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( requestOptions: RequestOptions ): CompletableFuture>> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt index 1b65f174..9660eec3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.global import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -60,7 +60,8 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SpendServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -71,7 +72,6 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val listTagsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listTags( params: SpendListTagsParams, @@ -88,7 +88,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listTagsHandler.handle(it) } .also { @@ -101,7 +101,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie } private val resetHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun reset( params: SpendResetParams, @@ -119,7 +119,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { resetHandler.handle(it) } .also { @@ -133,7 +133,6 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveReportHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveReport( params: SpendRetrieveReportParams, @@ -150,7 +149,7 @@ class SpendServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveReportHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt index c65300d1..faaf57f3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsync.kt @@ -28,18 +28,18 @@ interface GenerationServiceAsync { fun create(): CompletableFuture = create(GenerationCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: GenerationCreateParams = GenerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create( params: GenerationCreateParams = GenerationCreateParams.none() ): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletableFuture = create(GenerationCreateParams.none(), requestOptions) @@ -65,19 +65,19 @@ interface GenerationServiceAsync { fun create(): CompletableFuture> = create(GenerationCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: GenerationCreateParams = GenerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: GenerationCreateParams = GenerationCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt index 7d3b5dfc..8c1a6878 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.images import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class GenerationServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : GenerationServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class GenerationServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: GenerationCreateParams, @@ -71,7 +71,7 @@ class GenerationServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt index 78aafb45..dbbd231a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt @@ -57,17 +57,17 @@ interface InfoServiceAsync { */ fun list(): CompletableFuture = list(InfoListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: InfoListParams = InfoListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: InfoListParams = InfoListParams.none()): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CompletableFuture = list(InfoListParams.none(), requestOptions) @@ -88,19 +88,19 @@ interface InfoServiceAsync { fun list(): CompletableFuture> = list(InfoListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: InfoListParams = InfoListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: InfoListParams = InfoListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt index d6172227..aa709886 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.model import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -41,7 +41,8 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InfoServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien ) private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: InfoListParams, @@ -68,7 +69,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt index 8327e912..d30970dd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt @@ -30,7 +30,7 @@ interface UpdateServiceAsync { fun full(params: UpdateFullParams): CompletableFuture = full(params, RequestOptions.none()) - /** @see [full] */ + /** @see full */ fun full( params: UpdateFullParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,7 +55,7 @@ interface UpdateServiceAsync { params: UpdatePartialParams, ): CompletableFuture = partial(modelId, params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ fun partial( modelId: String, params: UpdatePartialParams, @@ -63,11 +63,11 @@ interface UpdateServiceAsync { ): CompletableFuture = partial(params.toBuilder().modelId(modelId).build(), requestOptions) - /** @see [partial] */ + /** @see partial */ fun partial(params: UpdatePartialParams): CompletableFuture = partial(params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ fun partial( params: UpdatePartialParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -94,7 +94,7 @@ interface UpdateServiceAsync { fun full(params: UpdateFullParams): CompletableFuture> = full(params, RequestOptions.none()) - /** @see [full] */ + /** @see full */ fun full( params: UpdateFullParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -110,7 +110,7 @@ interface UpdateServiceAsync { ): CompletableFuture> = partial(modelId, params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ fun partial( modelId: String, params: UpdatePartialParams, @@ -118,13 +118,13 @@ interface UpdateServiceAsync { ): CompletableFuture> = partial(params.toBuilder().modelId(modelId).build(), requestOptions) - /** @see [partial] */ + /** @see partial */ fun partial( params: UpdatePartialParams ): CompletableFuture> = partial(params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ fun partial( params: UpdatePartialParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt index 880b85bd..db2723a0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.model import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -53,7 +53,8 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UpdateServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,7 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli ) private val fullHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun full( params: UpdateFullParams, @@ -81,7 +82,7 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { fullHandler.handle(it) } .also { @@ -95,7 +96,6 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli private val partialHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun partial( params: UpdatePartialParams, @@ -116,7 +116,7 @@ class UpdateServiceAsyncImpl internal constructor(private val clientOptions: Cli return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { partialHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt index 92613e10..c7629f12 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsync.kt @@ -48,7 +48,7 @@ interface DeploymentServiceAsync { fun complete(model: String): CompletableFuture = complete(model, DeploymentCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), @@ -56,24 +56,24 @@ interface DeploymentServiceAsync { ): CompletableFuture = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), ): CompletableFuture = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: DeploymentCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [complete] */ + /** @see complete */ fun complete(params: DeploymentCompleteParams): CompletableFuture = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, @@ -97,7 +97,7 @@ interface DeploymentServiceAsync { fun embed(model: String): CompletableFuture = embed(model, DeploymentEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), @@ -105,23 +105,23 @@ interface DeploymentServiceAsync { ): CompletableFuture = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), ): CompletableFuture = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [embed] */ + /** @see embed */ fun embed(params: DeploymentEmbedParams): CompletableFuture = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, requestOptions: RequestOptions, @@ -154,7 +154,7 @@ interface DeploymentServiceAsync { ): CompletableFuture> = complete(model, DeploymentCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), @@ -162,26 +162,26 @@ interface DeploymentServiceAsync { ): CompletableFuture> = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), ): CompletableFuture> = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: DeploymentCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [complete] */ + /** @see complete */ fun complete( params: DeploymentCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, @@ -195,7 +195,7 @@ interface DeploymentServiceAsync { fun embed(model: String): CompletableFuture> = embed(model, DeploymentEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), @@ -203,26 +203,26 @@ interface DeploymentServiceAsync { ): CompletableFuture> = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), ): CompletableFuture> = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [embed] */ + /** @see embed */ fun embed( params: DeploymentEmbedParams ): CompletableFuture> = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt index ed0db9b5..561e5824 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.openai import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -59,7 +59,8 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DeploymentServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val chat: ChatServiceAsync.WithRawResponse by lazy { ChatServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -76,7 +77,6 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: DeploymentCompleteParams, @@ -97,7 +97,7 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { @@ -111,7 +111,6 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: private val embedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun embed( params: DeploymentEmbedParams, @@ -132,7 +131,7 @@ class DeploymentServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { embedHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt index bf4c4ca1..1d29cee2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsync.kt @@ -46,7 +46,7 @@ interface ChatServiceAsync { fun complete(model: String): CompletableFuture = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -54,23 +54,23 @@ interface ChatServiceAsync { ): CompletableFuture = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): CompletableFuture = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [complete] */ + /** @see complete */ fun complete(params: ChatCompleteParams): CompletableFuture = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, @@ -94,7 +94,7 @@ interface ChatServiceAsync { fun complete(model: String): CompletableFuture> = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), @@ -102,26 +102,26 @@ interface ChatServiceAsync { ): CompletableFuture> = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): CompletableFuture> = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams ): CompletableFuture> = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt index 92ebcf75..3a5a0d14 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.openai.deployments import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -44,7 +44,8 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ChatServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -55,7 +56,6 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: ChatCompleteParams, @@ -82,7 +82,7 @@ class ChatServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt index 61e3617a..d516cd96 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsync.kt @@ -30,7 +30,7 @@ interface InfoServiceAsync { fun retrieve(params: InfoRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: InfoRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -40,7 +40,7 @@ interface InfoServiceAsync { fun deprecated(params: InfoDeprecatedParams): CompletableFuture = deprecated(params, RequestOptions.none()) - /** @see [deprecated] */ + /** @see deprecated */ fun deprecated( params: InfoDeprecatedParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -65,7 +65,7 @@ interface InfoServiceAsync { ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: InfoRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +80,7 @@ interface InfoServiceAsync { ): CompletableFuture> = deprecated(params, RequestOptions.none()) - /** @see [deprecated] */ + /** @see deprecated */ fun deprecated( params: InfoDeprecatedParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt index 392f5408..5b8f2a79 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.organization import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -51,7 +51,8 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InfoServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -62,7 +63,6 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: InfoRetrieveParams, @@ -79,7 +79,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -93,7 +93,6 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien private val deprecatedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun deprecated( params: InfoDeprecatedParams, @@ -111,7 +110,7 @@ class InfoServiceAsyncImpl internal constructor(private val clientOptions: Clien return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { deprecatedHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt index 1675ef43..5964bf7f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsync.kt @@ -37,7 +37,7 @@ interface InputItemServiceAsync { fun list(responseId: String): CompletableFuture = list(responseId, InputItemListParams.none()) - /** @see [list] */ + /** @see list */ fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), @@ -45,23 +45,23 @@ interface InputItemServiceAsync { ): CompletableFuture = list(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), ): CompletableFuture = list(responseId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: InputItemListParams): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( responseId: String, requestOptions: RequestOptions, @@ -89,7 +89,7 @@ interface InputItemServiceAsync { fun list(responseId: String): CompletableFuture> = list(responseId, InputItemListParams.none()) - /** @see [list] */ + /** @see list */ fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), @@ -97,26 +97,26 @@ interface InputItemServiceAsync { ): CompletableFuture> = list(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), ): CompletableFuture> = list(responseId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: InputItemListParams ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( responseId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt index 0d044a35..c179ca2c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.responses import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -43,7 +43,8 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InputItemServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: InputItemListParams, @@ -74,7 +74,7 @@ class InputItemServiceAsyncImpl internal constructor(private val clientOptions: return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt index 0718b5ad..b81a76a5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsync.kt @@ -48,7 +48,7 @@ interface CallbackServiceAsync { fun retrieve(teamId: String): CompletableFuture = retrieve(teamId, CallbackRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), @@ -56,23 +56,23 @@ interface CallbackServiceAsync { ): CompletableFuture = retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), ): CompletableFuture = retrieve(teamId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: CallbackRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, requestOptions: RequestOptions, @@ -120,7 +120,7 @@ interface CallbackServiceAsync { fun add(teamId: String, params: CallbackAddParams): CompletableFuture = add(teamId, params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( teamId: String, params: CallbackAddParams, @@ -128,11 +128,11 @@ interface CallbackServiceAsync { ): CompletableFuture = add(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [add] */ + /** @see add */ fun add(params: CallbackAddParams): CompletableFuture = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( params: CallbackAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -159,7 +159,7 @@ interface CallbackServiceAsync { fun retrieve(teamId: String): CompletableFuture> = retrieve(teamId, CallbackRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), @@ -167,26 +167,26 @@ interface CallbackServiceAsync { ): CompletableFuture> = retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), ): CompletableFuture> = retrieve(teamId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CallbackRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, requestOptions: RequestOptions, @@ -203,7 +203,7 @@ interface CallbackServiceAsync { ): CompletableFuture> = add(teamId, params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( teamId: String, params: CallbackAddParams, @@ -211,13 +211,13 @@ interface CallbackServiceAsync { ): CompletableFuture> = add(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [add] */ + /** @see add */ fun add( params: CallbackAddParams ): CompletableFuture> = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( params: CallbackAddParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt index 60df18d6..4401d5ee 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.team import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -53,7 +53,8 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CallbackServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,6 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CallbackRetrieveParams, @@ -84,7 +84,7 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -98,7 +98,6 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C private val addHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun add( params: CallbackAddParams, @@ -119,7 +118,7 @@ class CallbackServiceAsyncImpl internal constructor(private val clientOptions: C return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { addHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt index 08d4ebe6..0cc0d4c4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsync.kt @@ -44,7 +44,7 @@ interface ModelServiceAsync { fun add(params: ModelAddParams): CompletableFuture = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( params: ModelAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -69,7 +69,7 @@ interface ModelServiceAsync { fun remove(params: ModelRemoveParams): CompletableFuture = remove(params, RequestOptions.none()) - /** @see [remove] */ + /** @see remove */ fun remove( params: ModelRemoveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -94,7 +94,7 @@ interface ModelServiceAsync { fun add(params: ModelAddParams): CompletableFuture> = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( params: ModelAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -109,7 +109,7 @@ interface ModelServiceAsync { ): CompletableFuture> = remove(params, RequestOptions.none()) - /** @see [remove] */ + /** @see remove */ fun remove( params: ModelRemoveParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt index c11ae795..e223dbf2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.async.team import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -51,7 +51,8 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModelServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -61,7 +62,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie ) private val addHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun add( params: ModelAddParams, @@ -79,7 +80,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { addHandler.handle(it) } .also { @@ -93,7 +94,6 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie private val removeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun remove( params: ModelRemoveParams, @@ -111,7 +111,7 @@ class ModelServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { removeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt index ce96bcce..ea42aba2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsync.kt @@ -34,7 +34,7 @@ interface MessageServiceAsync { fun create(threadId: String): CompletableFuture = create(threadId, MessageCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), @@ -42,23 +42,23 @@ interface MessageServiceAsync { ): CompletableFuture = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), ): CompletableFuture = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: MessageCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: MessageCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, requestOptions: RequestOptions, @@ -73,7 +73,7 @@ interface MessageServiceAsync { fun list(threadId: String): CompletableFuture = list(threadId, MessageListParams.none()) - /** @see [list] */ + /** @see list */ fun list( threadId: String, params: MessageListParams = MessageListParams.none(), @@ -81,23 +81,23 @@ interface MessageServiceAsync { ): CompletableFuture = list(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( threadId: String, params: MessageListParams = MessageListParams.none(), ): CompletableFuture = list(threadId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [list] */ + /** @see list */ fun list(params: MessageListParams): CompletableFuture = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( threadId: String, requestOptions: RequestOptions, @@ -125,7 +125,7 @@ interface MessageServiceAsync { fun create(threadId: String): CompletableFuture> = create(threadId, MessageCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), @@ -133,26 +133,26 @@ interface MessageServiceAsync { ): CompletableFuture> = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), ): CompletableFuture> = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: MessageCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create( params: MessageCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, requestOptions: RequestOptions, @@ -166,7 +166,7 @@ interface MessageServiceAsync { fun list(threadId: String): CompletableFuture> = list(threadId, MessageListParams.none()) - /** @see [list] */ + /** @see list */ fun list( threadId: String, params: MessageListParams = MessageListParams.none(), @@ -174,26 +174,26 @@ interface MessageServiceAsync { ): CompletableFuture> = list(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( threadId: String, params: MessageListParams = MessageListParams.none(), ): CompletableFuture> = list(threadId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [list] */ + /** @see list */ fun list( params: MessageListParams ): CompletableFuture> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( threadId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt index abd8ac86..789bf16f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.threads import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -53,7 +53,8 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : MessageServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -64,7 +65,6 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: MessageCreateParams, @@ -85,7 +85,7 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -99,7 +99,6 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: MessageListParams, @@ -119,7 +118,7 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt index d2cf549d..fc012ec8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsync.kt @@ -32,7 +32,7 @@ interface RunServiceAsync { fun create(threadId: String): CompletableFuture = create(threadId, RunCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), @@ -40,23 +40,23 @@ interface RunServiceAsync { ): CompletableFuture = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), ): CompletableFuture = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see [create] */ + /** @see create */ fun create(params: RunCreateParams): CompletableFuture = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, requestOptions: RequestOptions, @@ -80,7 +80,7 @@ interface RunServiceAsync { fun create(threadId: String): CompletableFuture> = create(threadId, RunCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), @@ -88,24 +88,24 @@ interface RunServiceAsync { ): CompletableFuture> = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), ): CompletableFuture> = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see [create] */ + /** @see create */ fun create(params: RunCreateParams): CompletableFuture> = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, requestOptions: RequestOptions, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt index 6edf708d..c31ac9ea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.async.threads import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -44,7 +44,8 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RunServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: RunCreateParams, @@ -75,7 +76,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt index 1e63de16..40b9d5aa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveService.kt @@ -50,18 +50,18 @@ interface ActiveService { fun listCallbacks(): ActiveListCallbacksResponse = listCallbacks(ActiveListCallbacksParams.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ActiveListCallbacksResponse - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none() ): ActiveListCallbacksResponse = listCallbacks(params, RequestOptions.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ fun listCallbacks(requestOptions: RequestOptions): ActiveListCallbacksResponse = listCallbacks(ActiveListCallbacksParams.none(), requestOptions) @@ -83,21 +83,21 @@ interface ActiveService { fun listCallbacks(): HttpResponseFor = listCallbacks(ActiveListCallbacksParams.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ @MustBeClosed fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [listCallbacks] */ + /** @see listCallbacks */ @MustBeClosed fun listCallbacks( params: ActiveListCallbacksParams = ActiveListCallbacksParams.none() ): HttpResponseFor = listCallbacks(params, RequestOptions.none()) - /** @see [listCallbacks] */ + /** @see listCallbacks */ @MustBeClosed fun listCallbacks( requestOptions: RequestOptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt index 792b5c54..2d3a9e2a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ActiveServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -40,7 +40,8 @@ class ActiveServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ActiveService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,6 @@ class ActiveServiceImpl internal constructor(private val clientOptions: ClientOp private val listCallbacksHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listCallbacks( params: ActiveListCallbacksParams, @@ -66,7 +66,7 @@ class ActiveServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listCallbacksHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt index bd3724b1..7368d9b7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt @@ -28,7 +28,7 @@ interface AddService { fun addAllowedIp(params: AddAddAllowedIpParams): AddAddAllowedIpResponse = addAllowedIp(params, RequestOptions.none()) - /** @see [addAllowedIp] */ + /** @see addAllowedIp */ fun addAllowedIp( params: AddAddAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -52,7 +52,7 @@ interface AddService { fun addAllowedIp(params: AddAddAllowedIpParams): HttpResponseFor = addAllowedIp(params, RequestOptions.none()) - /** @see [addAllowedIp] */ + /** @see addAllowedIp */ @MustBeClosed fun addAllowedIp( params: AddAddAllowedIpParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt index 1047878d..b3849302 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -40,7 +40,8 @@ class AddServiceImpl internal constructor(private val clientOptions: ClientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AddService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,6 @@ class AddServiceImpl internal constructor(private val clientOptions: ClientOptio private val addAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun addAllowedIp( params: AddAddAllowedIpParams, @@ -67,7 +67,7 @@ class AddServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { addAllowedIpHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt index 0f9eee3a..52a9445f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicService.kt @@ -36,7 +36,7 @@ interface AnthropicService { fun create(endpoint: String): AnthropicCreateResponse = create(endpoint, AnthropicCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), @@ -44,23 +44,23 @@ interface AnthropicService { ): AnthropicCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AnthropicCreateParams = AnthropicCreateParams.none(), ): AnthropicCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AnthropicCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: AnthropicCreateParams): AnthropicCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): AnthropicCreateResponse = create(endpoint, AnthropicCreateParams.none(), requestOptions) @@ -68,7 +68,7 @@ interface AnthropicService { fun retrieve(endpoint: String): AnthropicRetrieveResponse = retrieve(endpoint, AnthropicRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), @@ -76,23 +76,23 @@ interface AnthropicService { ): AnthropicRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AnthropicRetrieveParams = AnthropicRetrieveParams.none(), ): AnthropicRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AnthropicRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: AnthropicRetrieveParams): AnthropicRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): AnthropicRetrieveResponse = retrieve(endpoint, AnthropicRetrieveParams.none(), requestOptions) @@ -100,7 +100,7 @@ interface AnthropicService { fun update(endpoint: String): AnthropicUpdateResponse = update(endpoint, AnthropicUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), @@ -108,23 +108,23 @@ interface AnthropicService { ): AnthropicUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AnthropicUpdateParams = AnthropicUpdateParams.none(), ): AnthropicUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AnthropicUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: AnthropicUpdateParams): AnthropicUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): AnthropicUpdateResponse = update(endpoint, AnthropicUpdateParams.none(), requestOptions) @@ -132,7 +132,7 @@ interface AnthropicService { fun delete(endpoint: String): AnthropicDeleteResponse = delete(endpoint, AnthropicDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), @@ -140,23 +140,23 @@ interface AnthropicService { ): AnthropicDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AnthropicDeleteParams = AnthropicDeleteParams.none(), ): AnthropicDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AnthropicDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: AnthropicDeleteParams): AnthropicDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): AnthropicDeleteResponse = delete(endpoint, AnthropicDeleteParams.none(), requestOptions) @@ -164,7 +164,7 @@ interface AnthropicService { fun modify(endpoint: String): AnthropicModifyResponse = modify(endpoint, AnthropicModifyParams.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), @@ -172,23 +172,23 @@ interface AnthropicService { ): AnthropicModifyResponse = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: AnthropicModifyParams = AnthropicModifyParams.none(), ): AnthropicModifyResponse = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): AnthropicModifyResponse - /** @see [modify] */ + /** @see modify */ fun modify(params: AnthropicModifyParams): AnthropicModifyResponse = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify(endpoint: String, requestOptions: RequestOptions): AnthropicModifyResponse = modify(endpoint, AnthropicModifyParams.none(), requestOptions) @@ -210,7 +210,7 @@ interface AnthropicService { fun create(endpoint: String): HttpResponseFor = create(endpoint, AnthropicCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -219,7 +219,7 @@ interface AnthropicService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -227,19 +227,19 @@ interface AnthropicService { ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: AnthropicCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: AnthropicCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -255,7 +255,7 @@ interface AnthropicService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, AnthropicRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -264,7 +264,7 @@ interface AnthropicService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -272,19 +272,19 @@ interface AnthropicService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: AnthropicRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: AnthropicRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -300,7 +300,7 @@ interface AnthropicService { fun update(endpoint: String): HttpResponseFor = update(endpoint, AnthropicUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -309,7 +309,7 @@ interface AnthropicService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -317,19 +317,19 @@ interface AnthropicService { ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: AnthropicUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: AnthropicUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -345,7 +345,7 @@ interface AnthropicService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, AnthropicDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -354,7 +354,7 @@ interface AnthropicService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -362,19 +362,19 @@ interface AnthropicService { ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: AnthropicDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: AnthropicDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -390,7 +390,7 @@ interface AnthropicService { fun modify(endpoint: String): HttpResponseFor = modify(endpoint, AnthropicModifyParams.none()) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( endpoint: String, @@ -399,7 +399,7 @@ interface AnthropicService { ): HttpResponseFor = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( endpoint: String, @@ -407,19 +407,19 @@ interface AnthropicService { ): HttpResponseFor = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( params: AnthropicModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify(params: AnthropicModifyParams): HttpResponseFor = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt index 304f6a89..e0eed126 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AnthropicService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AnthropicCreateParams, @@ -109,7 +109,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: AnthropicRetrieveParams, @@ -140,7 +139,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AnthropicUpdateParams, @@ -172,7 +170,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AnthropicDeleteParams, @@ -204,7 +201,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien private val modifyHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun modify( params: AnthropicModifyParams, @@ -236,7 +232,7 @@ class AnthropicServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { modifyHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt index f52f194d..ca040eee 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiService.kt @@ -36,7 +36,7 @@ interface AssemblyaiService { fun create(endpoint: String): AssemblyaiCreateResponse = create(endpoint, AssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), @@ -44,23 +44,23 @@ interface AssemblyaiService { ): AssemblyaiCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AssemblyaiCreateParams = AssemblyaiCreateParams.none(), ): AssemblyaiCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: AssemblyaiCreateParams): AssemblyaiCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): AssemblyaiCreateResponse = create(endpoint, AssemblyaiCreateParams.none(), requestOptions) @@ -68,7 +68,7 @@ interface AssemblyaiService { fun retrieve(endpoint: String): AssemblyaiRetrieveResponse = retrieve(endpoint, AssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), @@ -76,23 +76,23 @@ interface AssemblyaiService { ): AssemblyaiRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: AssemblyaiRetrieveParams = AssemblyaiRetrieveParams.none(), ): AssemblyaiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: AssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: AssemblyaiRetrieveParams): AssemblyaiRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): AssemblyaiRetrieveResponse = retrieve(endpoint, AssemblyaiRetrieveParams.none(), requestOptions) @@ -100,7 +100,7 @@ interface AssemblyaiService { fun update(endpoint: String): AssemblyaiUpdateResponse = update(endpoint, AssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), @@ -108,23 +108,23 @@ interface AssemblyaiService { ): AssemblyaiUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AssemblyaiUpdateParams = AssemblyaiUpdateParams.none(), ): AssemblyaiUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: AssemblyaiUpdateParams): AssemblyaiUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): AssemblyaiUpdateResponse = update(endpoint, AssemblyaiUpdateParams.none(), requestOptions) @@ -132,7 +132,7 @@ interface AssemblyaiService { fun delete(endpoint: String): AssemblyaiDeleteResponse = delete(endpoint, AssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), @@ -140,23 +140,23 @@ interface AssemblyaiService { ): AssemblyaiDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AssemblyaiDeleteParams = AssemblyaiDeleteParams.none(), ): AssemblyaiDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: AssemblyaiDeleteParams): AssemblyaiDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): AssemblyaiDeleteResponse = delete(endpoint, AssemblyaiDeleteParams.none(), requestOptions) @@ -164,7 +164,7 @@ interface AssemblyaiService { fun patch(endpoint: String): AssemblyaiPatchResponse = patch(endpoint, AssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), @@ -172,23 +172,23 @@ interface AssemblyaiService { ): AssemblyaiPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), ): AssemblyaiPatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): AssemblyaiPatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: AssemblyaiPatchParams): AssemblyaiPatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): AssemblyaiPatchResponse = patch(endpoint, AssemblyaiPatchParams.none(), requestOptions) @@ -212,7 +212,7 @@ interface AssemblyaiService { fun create(endpoint: String): HttpResponseFor = create(endpoint, AssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -221,7 +221,7 @@ interface AssemblyaiService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -229,19 +229,19 @@ interface AssemblyaiService { ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: AssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: AssemblyaiCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -257,7 +257,7 @@ interface AssemblyaiService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, AssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -266,7 +266,7 @@ interface AssemblyaiService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -274,20 +274,20 @@ interface AssemblyaiService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: AssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: AssemblyaiRetrieveParams ): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -303,7 +303,7 @@ interface AssemblyaiService { fun update(endpoint: String): HttpResponseFor = update(endpoint, AssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -312,7 +312,7 @@ interface AssemblyaiService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -320,19 +320,19 @@ interface AssemblyaiService { ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: AssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: AssemblyaiUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -348,7 +348,7 @@ interface AssemblyaiService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, AssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -357,7 +357,7 @@ interface AssemblyaiService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -365,19 +365,19 @@ interface AssemblyaiService { ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: AssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: AssemblyaiDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -393,7 +393,7 @@ interface AssemblyaiService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, AssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -402,26 +402,26 @@ interface AssemblyaiService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: AssemblyaiPatchParams = AssemblyaiPatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: AssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: AssemblyaiPatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt index e1051ba3..911bcc40 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AssemblyaiService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AssemblyaiCreateParams, @@ -109,7 +109,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: AssemblyaiRetrieveParams, @@ -140,7 +139,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AssemblyaiUpdateParams, @@ -172,7 +170,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AssemblyaiDeleteParams, @@ -204,7 +201,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: AssemblyaiPatchParams, @@ -236,7 +232,7 @@ class AssemblyaiServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt index 395b1780..c265d09a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantService.kt @@ -36,18 +36,18 @@ interface AssistantService { */ fun create(): AssistantCreateResponse = create(AssistantCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: AssistantCreateParams = AssistantCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AssistantCreateResponse - /** @see [create] */ + /** @see create */ fun create( params: AssistantCreateParams = AssistantCreateParams.none() ): AssistantCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): AssistantCreateResponse = create(AssistantCreateParams.none(), requestOptions) @@ -58,17 +58,17 @@ interface AssistantService { */ fun list(): AssistantListResponse = list(AssistantListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: AssistantListParams = AssistantListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AssistantListResponse - /** @see [list] */ + /** @see list */ fun list(params: AssistantListParams = AssistantListParams.none()): AssistantListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): AssistantListResponse = list(AssistantListParams.none(), requestOptions) @@ -81,7 +81,7 @@ interface AssistantService { fun delete(assistantId: String): AssistantDeleteResponse = delete(assistantId, AssistantDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), @@ -89,23 +89,23 @@ interface AssistantService { ): AssistantDeleteResponse = delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( assistantId: String, params: AssistantDeleteParams = AssistantDeleteParams.none(), ): AssistantDeleteResponse = delete(assistantId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): AssistantDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: AssistantDeleteParams): AssistantDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(assistantId: String, requestOptions: RequestOptions): AssistantDeleteResponse = delete(assistantId, AssistantDeleteParams.none(), requestOptions) @@ -127,20 +127,20 @@ interface AssistantService { fun create(): HttpResponseFor = create(AssistantCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: AssistantCreateParams = AssistantCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: AssistantCreateParams = AssistantCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(AssistantCreateParams.none(), requestOptions) @@ -152,20 +152,20 @@ interface AssistantService { @MustBeClosed fun list(): HttpResponseFor = list(AssistantListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: AssistantListParams = AssistantListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: AssistantListParams = AssistantListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(AssistantListParams.none(), requestOptions) @@ -178,7 +178,7 @@ interface AssistantService { fun delete(assistantId: String): HttpResponseFor = delete(assistantId, AssistantDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( assistantId: String, @@ -187,7 +187,7 @@ interface AssistantService { ): HttpResponseFor = delete(params.toBuilder().assistantId(assistantId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( assistantId: String, @@ -195,19 +195,19 @@ interface AssistantService { ): HttpResponseFor = delete(assistantId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: AssistantDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: AssistantDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( assistantId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt index 76ed9c7b..b28746e1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AssistantServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -61,7 +61,8 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AssistantService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -72,7 +73,6 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AssistantCreateParams, @@ -88,7 +88,7 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -101,7 +101,6 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: AssistantListParams, @@ -116,7 +115,7 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -129,7 +128,6 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AssistantDeleteParams, @@ -148,7 +146,7 @@ class AssistantServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt index 5e1f1568..5d9f1436 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureService.kt @@ -39,30 +39,30 @@ interface AzureService { */ fun create(endpoint: String): AzureCreateResponse = create(endpoint, AzureCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AzureCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), ): AzureCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: AzureCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AzureCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: AzureCreateParams): AzureCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): AzureCreateResponse = create(endpoint, AzureCreateParams.none(), requestOptions) @@ -73,30 +73,30 @@ interface AzureService { */ fun update(endpoint: String): AzureUpdateResponse = update(endpoint, AzureUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AzureUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), ): AzureUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: AzureUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AzureUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: AzureUpdateParams): AzureUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): AzureUpdateResponse = update(endpoint, AzureUpdateParams.none(), requestOptions) @@ -107,30 +107,30 @@ interface AzureService { */ fun delete(endpoint: String): AzureDeleteResponse = delete(endpoint, AzureDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AzureDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), ): AzureDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: AzureDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): AzureDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: AzureDeleteParams): AzureDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): AzureDeleteResponse = delete(endpoint, AzureDeleteParams.none(), requestOptions) @@ -141,29 +141,29 @@ interface AzureService { */ fun call(endpoint: String): AzureCallResponse = call(endpoint, AzureCallParams.none()) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AzureCallResponse = call(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [call] */ + /** @see call */ fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), ): AzureCallResponse = call(endpoint, params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ fun call( params: AzureCallParams, requestOptions: RequestOptions = RequestOptions.none(), ): AzureCallResponse - /** @see [call] */ + /** @see call */ fun call(params: AzureCallParams): AzureCallResponse = call(params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ fun call(endpoint: String, requestOptions: RequestOptions): AzureCallResponse = call(endpoint, AzureCallParams.none(), requestOptions) @@ -174,29 +174,29 @@ interface AzureService { */ fun patch(endpoint: String): AzurePatchResponse = patch(endpoint, AzurePatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AzurePatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), ): AzurePatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): AzurePatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: AzurePatchParams): AzurePatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): AzurePatchResponse = patch(endpoint, AzurePatchParams.none(), requestOptions) @@ -218,7 +218,7 @@ interface AzureService { fun create(endpoint: String): HttpResponseFor = create(endpoint, AzureCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -227,26 +227,26 @@ interface AzureService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: AzureCreateParams = AzureCreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: AzureCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: AzureCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -262,7 +262,7 @@ interface AzureService { fun update(endpoint: String): HttpResponseFor = update(endpoint, AzureUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -271,26 +271,26 @@ interface AzureService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: AzureUpdateParams = AzureUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: AzureUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: AzureUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -306,7 +306,7 @@ interface AzureService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, AzureDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -315,26 +315,26 @@ interface AzureService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: AzureDeleteParams = AzureDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: AzureDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: AzureDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -350,7 +350,7 @@ interface AzureService { fun call(endpoint: String): HttpResponseFor = call(endpoint, AzureCallParams.none()) - /** @see [call] */ + /** @see call */ @MustBeClosed fun call( endpoint: String, @@ -359,26 +359,26 @@ interface AzureService { ): HttpResponseFor = call(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [call] */ + /** @see call */ @MustBeClosed fun call( endpoint: String, params: AzureCallParams = AzureCallParams.none(), ): HttpResponseFor = call(endpoint, params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ @MustBeClosed fun call( params: AzureCallParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [call] */ + /** @see call */ @MustBeClosed fun call(params: AzureCallParams): HttpResponseFor = call(params, RequestOptions.none()) - /** @see [call] */ + /** @see call */ @MustBeClosed fun call( endpoint: String, @@ -394,7 +394,7 @@ interface AzureService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, AzurePatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -403,26 +403,26 @@ interface AzureService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: AzurePatchParams = AzurePatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: AzurePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: AzurePatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt index 8436ee56..f5c2e8b3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AzureServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -76,7 +76,8 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AzureService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -87,7 +88,6 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: AzureCreateParams, @@ -106,7 +106,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -119,7 +119,6 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: AzureUpdateParams, @@ -138,7 +137,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -151,7 +150,6 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: AzureDeleteParams, @@ -170,7 +168,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -182,7 +180,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt } private val callHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun call( params: AzureCallParams, @@ -200,7 +198,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { callHandler.handle(it) } .also { @@ -212,7 +210,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt } private val patchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun patch( params: AzurePatchParams, @@ -231,7 +229,7 @@ class AzureServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt index 409ea3f8..067ff56c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchService.kt @@ -56,17 +56,17 @@ interface BatchService { */ fun create(): BatchCreateResponse = create(BatchCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: BatchCreateParams = BatchCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BatchCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: BatchCreateParams = BatchCreateParams.none()): BatchCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): BatchCreateResponse = create(BatchCreateParams.none(), requestOptions) @@ -83,30 +83,30 @@ interface BatchService { fun retrieve(batchId: String): BatchRetrieveResponse = retrieve(batchId, BatchRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BatchRetrieveResponse = retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), ): BatchRetrieveResponse = retrieve(batchId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BatchRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): BatchRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: BatchRetrieveParams): BatchRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(batchId: String, requestOptions: RequestOptions): BatchRetrieveResponse = retrieve(batchId, BatchRetrieveParams.none(), requestOptions) @@ -122,17 +122,17 @@ interface BatchService { */ fun list(): BatchListResponse = list(BatchListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: BatchListParams = BatchListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BatchListResponse - /** @see [list] */ + /** @see list */ fun list(params: BatchListParams = BatchListParams.none()): BatchListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): BatchListResponse = list(BatchListParams.none(), requestOptions) @@ -154,7 +154,7 @@ interface BatchService { params: BatchCancelWithProviderParams, ): BatchCancelWithProviderResponse = cancelWithProvider(batchId, params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( batchId: String, params: BatchCancelWithProviderParams, @@ -162,11 +162,11 @@ interface BatchService { ): BatchCancelWithProviderResponse = cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider(params: BatchCancelWithProviderParams): BatchCancelWithProviderResponse = cancelWithProvider(params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ fun cancelWithProvider( params: BatchCancelWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -190,7 +190,7 @@ interface BatchService { fun createWithProvider(provider: String): BatchCreateWithProviderResponse = createWithProvider(provider, BatchCreateWithProviderParams.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), @@ -198,23 +198,23 @@ interface BatchService { ): BatchCreateWithProviderResponse = createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, params: BatchCreateWithProviderParams = BatchCreateWithProviderParams.none(), ): BatchCreateWithProviderResponse = createWithProvider(provider, params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( params: BatchCreateWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): BatchCreateWithProviderResponse - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider(params: BatchCreateWithProviderParams): BatchCreateWithProviderResponse = createWithProvider(params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ fun createWithProvider( provider: String, requestOptions: RequestOptions, @@ -234,7 +234,7 @@ interface BatchService { fun listWithProvider(provider: String): BatchListWithProviderResponse = listWithProvider(provider, BatchListWithProviderParams.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), @@ -242,23 +242,23 @@ interface BatchService { ): BatchListWithProviderResponse = listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, params: BatchListWithProviderParams = BatchListWithProviderParams.none(), ): BatchListWithProviderResponse = listWithProvider(provider, params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( params: BatchListWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): BatchListWithProviderResponse - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider(params: BatchListWithProviderParams): BatchListWithProviderResponse = listWithProvider(params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ fun listWithProvider( provider: String, requestOptions: RequestOptions, @@ -281,7 +281,7 @@ interface BatchService { ): BatchRetrieveWithProviderResponse = retrieveWithProvider(batchId, params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( batchId: String, params: BatchRetrieveWithProviderParams, @@ -289,12 +289,12 @@ interface BatchService { ): BatchRetrieveWithProviderResponse = retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): BatchRetrieveWithProviderResponse = retrieveWithProvider(params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -319,20 +319,20 @@ interface BatchService { @MustBeClosed fun create(): HttpResponseFor = create(BatchCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: BatchCreateParams = BatchCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: BatchCreateParams = BatchCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(BatchCreateParams.none(), requestOptions) @@ -345,7 +345,7 @@ interface BatchService { fun retrieve(batchId: String): HttpResponseFor = retrieve(batchId, BatchRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( batchId: String, @@ -354,26 +354,26 @@ interface BatchService { ): HttpResponseFor = retrieve(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( batchId: String, params: BatchRetrieveParams = BatchRetrieveParams.none(), ): HttpResponseFor = retrieve(batchId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: BatchRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: BatchRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( batchId: String, @@ -387,20 +387,20 @@ interface BatchService { */ @MustBeClosed fun list(): HttpResponseFor = list(BatchListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: BatchListParams = BatchListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: BatchListParams = BatchListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(BatchListParams.none(), requestOptions) @@ -416,7 +416,7 @@ interface BatchService { ): HttpResponseFor = cancelWithProvider(batchId, params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ @MustBeClosed fun cancelWithProvider( batchId: String, @@ -425,14 +425,14 @@ interface BatchService { ): HttpResponseFor = cancelWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ @MustBeClosed fun cancelWithProvider( params: BatchCancelWithProviderParams ): HttpResponseFor = cancelWithProvider(params, RequestOptions.none()) - /** @see [cancelWithProvider] */ + /** @see cancelWithProvider */ @MustBeClosed fun cancelWithProvider( params: BatchCancelWithProviderParams, @@ -447,7 +447,7 @@ interface BatchService { fun createWithProvider(provider: String): HttpResponseFor = createWithProvider(provider, BatchCreateWithProviderParams.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ @MustBeClosed fun createWithProvider( provider: String, @@ -456,7 +456,7 @@ interface BatchService { ): HttpResponseFor = createWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [createWithProvider] */ + /** @see createWithProvider */ @MustBeClosed fun createWithProvider( provider: String, @@ -464,21 +464,21 @@ interface BatchService { ): HttpResponseFor = createWithProvider(provider, params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ @MustBeClosed fun createWithProvider( params: BatchCreateWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [createWithProvider] */ + /** @see createWithProvider */ @MustBeClosed fun createWithProvider( params: BatchCreateWithProviderParams ): HttpResponseFor = createWithProvider(params, RequestOptions.none()) - /** @see [createWithProvider] */ + /** @see createWithProvider */ @MustBeClosed fun createWithProvider( provider: String, @@ -494,7 +494,7 @@ interface BatchService { fun listWithProvider(provider: String): HttpResponseFor = listWithProvider(provider, BatchListWithProviderParams.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ @MustBeClosed fun listWithProvider( provider: String, @@ -503,7 +503,7 @@ interface BatchService { ): HttpResponseFor = listWithProvider(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [listWithProvider] */ + /** @see listWithProvider */ @MustBeClosed fun listWithProvider( provider: String, @@ -511,21 +511,21 @@ interface BatchService { ): HttpResponseFor = listWithProvider(provider, params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ @MustBeClosed fun listWithProvider( params: BatchListWithProviderParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [listWithProvider] */ + /** @see listWithProvider */ @MustBeClosed fun listWithProvider( params: BatchListWithProviderParams ): HttpResponseFor = listWithProvider(params, RequestOptions.none()) - /** @see [listWithProvider] */ + /** @see listWithProvider */ @MustBeClosed fun listWithProvider( provider: String, @@ -544,7 +544,7 @@ interface BatchService { ): HttpResponseFor = retrieveWithProvider(batchId, params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ @MustBeClosed fun retrieveWithProvider( batchId: String, @@ -553,14 +553,14 @@ interface BatchService { ): HttpResponseFor = retrieveWithProvider(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ @MustBeClosed fun retrieveWithProvider( params: BatchRetrieveWithProviderParams ): HttpResponseFor = retrieveWithProvider(params, RequestOptions.none()) - /** @see [retrieveWithProvider] */ + /** @see retrieveWithProvider */ @MustBeClosed fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt index 3f36f888..836c5194 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BatchServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -100,7 +100,8 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BatchService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val cancel: CancelService.WithRawResponse by lazy { CancelServiceImpl.WithRawResponseImpl(clientOptions) @@ -117,7 +118,6 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BatchCreateParams, @@ -133,7 +133,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -146,7 +146,6 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BatchRetrieveParams, @@ -164,7 +163,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -176,7 +175,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: BatchListParams, @@ -191,7 +190,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -204,7 +203,6 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val cancelWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun cancelWithProvider( params: BatchCancelWithProviderParams, @@ -229,7 +227,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { cancelWithProviderHandler.handle(it) } .also { @@ -242,7 +240,6 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val createWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createWithProvider( params: BatchCreateWithProviderParams, @@ -261,7 +258,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createWithProviderHandler.handle(it) } .also { @@ -274,7 +271,6 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val listWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listWithProvider( params: BatchListWithProviderParams, @@ -292,7 +288,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listWithProviderHandler.handle(it) } .also { @@ -305,7 +301,6 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveWithProviderHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveWithProvider( params: BatchRetrieveWithProviderParams, @@ -323,7 +318,7 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveWithProviderHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt index 6fca1e9a..8bf97904 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockService.kt @@ -36,30 +36,30 @@ interface BedrockService { fun create(endpoint: String): BedrockCreateResponse = create(endpoint, BedrockCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BedrockCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), ): BedrockCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: BedrockCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): BedrockCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: BedrockCreateParams): BedrockCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): BedrockCreateResponse = create(endpoint, BedrockCreateParams.none(), requestOptions) @@ -67,7 +67,7 @@ interface BedrockService { fun retrieve(endpoint: String): BedrockRetrieveResponse = retrieve(endpoint, BedrockRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), @@ -75,23 +75,23 @@ interface BedrockService { ): BedrockRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: BedrockRetrieveParams = BedrockRetrieveParams.none(), ): BedrockRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BedrockRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): BedrockRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: BedrockRetrieveParams): BedrockRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): BedrockRetrieveResponse = retrieve(endpoint, BedrockRetrieveParams.none(), requestOptions) @@ -99,30 +99,30 @@ interface BedrockService { fun update(endpoint: String): BedrockUpdateResponse = update(endpoint, BedrockUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BedrockUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), ): BedrockUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: BedrockUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): BedrockUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: BedrockUpdateParams): BedrockUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): BedrockUpdateResponse = update(endpoint, BedrockUpdateParams.none(), requestOptions) @@ -130,60 +130,60 @@ interface BedrockService { fun delete(endpoint: String): BedrockDeleteResponse = delete(endpoint, BedrockDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BedrockDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), ): BedrockDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: BedrockDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): BedrockDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: BedrockDeleteParams): BedrockDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): BedrockDeleteResponse = delete(endpoint, BedrockDeleteParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ fun patch(endpoint: String): BedrockPatchResponse = patch(endpoint, BedrockPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BedrockPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), ): BedrockPatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): BedrockPatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: BedrockPatchParams): BedrockPatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): BedrockPatchResponse = patch(endpoint, BedrockPatchParams.none(), requestOptions) @@ -205,7 +205,7 @@ interface BedrockService { fun create(endpoint: String): HttpResponseFor = create(endpoint, BedrockCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -214,26 +214,26 @@ interface BedrockService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: BedrockCreateParams = BedrockCreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: BedrockCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: BedrockCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -249,7 +249,7 @@ interface BedrockService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, BedrockRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -258,7 +258,7 @@ interface BedrockService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -266,19 +266,19 @@ interface BedrockService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: BedrockRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: BedrockRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -294,7 +294,7 @@ interface BedrockService { fun update(endpoint: String): HttpResponseFor = update(endpoint, BedrockUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -303,26 +303,26 @@ interface BedrockService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: BedrockUpdateParams = BedrockUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: BedrockUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: BedrockUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -338,7 +338,7 @@ interface BedrockService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, BedrockDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -347,26 +347,26 @@ interface BedrockService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: BedrockDeleteParams = BedrockDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: BedrockDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: BedrockDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -382,7 +382,7 @@ interface BedrockService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, BedrockPatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -391,26 +391,26 @@ interface BedrockService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: BedrockPatchParams = BedrockPatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: BedrockPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: BedrockPatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt index 2afc25ba..282b0748 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BedrockServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BedrockService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BedrockCreateParams, @@ -109,7 +109,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BedrockRetrieveParams, @@ -140,7 +139,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: BedrockUpdateParams, @@ -172,7 +170,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: BedrockDeleteParams, @@ -204,7 +201,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: BedrockPatchParams, @@ -236,7 +232,7 @@ class BedrockServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt index 0aeb20f8..cc682589 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt @@ -53,7 +53,7 @@ interface BudgetService { fun create(params: BudgetCreateParams): BudgetCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: BudgetCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -78,7 +78,7 @@ interface BudgetService { fun update(params: BudgetUpdateParams): BudgetUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: BudgetUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -87,17 +87,17 @@ interface BudgetService { /** List all the created budgets in proxy db. Used on Admin UI. */ fun list(): BudgetListResponse = list(BudgetListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: BudgetListParams = BudgetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): BudgetListResponse - /** @see [list] */ + /** @see list */ fun list(params: BudgetListParams = BudgetListParams.none()): BudgetListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): BudgetListResponse = list(BudgetListParams.none(), requestOptions) @@ -110,7 +110,7 @@ interface BudgetService { fun delete(params: BudgetDeleteParams): BudgetDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: BudgetDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -124,7 +124,7 @@ interface BudgetService { */ fun info(params: BudgetInfoParams): BudgetInfoResponse = info(params, RequestOptions.none()) - /** @see [info] */ + /** @see info */ fun info( params: BudgetInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -141,7 +141,7 @@ interface BudgetService { fun settings(params: BudgetSettingsParams): BudgetSettingsResponse = settings(params, RequestOptions.none()) - /** @see [settings] */ + /** @see settings */ fun settings( params: BudgetSettingsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -165,7 +165,7 @@ interface BudgetService { fun create(params: BudgetCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: BudgetCreateParams, @@ -180,7 +180,7 @@ interface BudgetService { fun update(params: BudgetUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: BudgetUpdateParams, @@ -194,20 +194,20 @@ interface BudgetService { @MustBeClosed fun list(): HttpResponseFor = list(BudgetListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: BudgetListParams = BudgetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: BudgetListParams = BudgetListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(BudgetListParams.none(), requestOptions) @@ -220,7 +220,7 @@ interface BudgetService { fun delete(params: BudgetDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: BudgetDeleteParams, @@ -235,7 +235,7 @@ interface BudgetService { fun info(params: BudgetInfoParams): HttpResponseFor = info(params, RequestOptions.none()) - /** @see [info] */ + /** @see info */ @MustBeClosed fun info( params: BudgetInfoParams, @@ -250,7 +250,7 @@ interface BudgetService { fun settings(params: BudgetSettingsParams): HttpResponseFor = settings(params, RequestOptions.none()) - /** @see [settings] */ + /** @see settings */ @MustBeClosed fun settings( params: BudgetSettingsParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt index 585a5570..8c1d5bb2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -86,7 +86,8 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BudgetService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -97,7 +98,6 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: BudgetCreateParams, @@ -113,7 +113,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: BudgetUpdateParams, @@ -142,7 +141,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -154,7 +153,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: BudgetListParams, @@ -169,7 +168,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -182,7 +181,6 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: BudgetDeleteParams, @@ -198,7 +196,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -210,7 +208,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp } private val infoHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun info( params: BudgetInfoParams, @@ -226,7 +224,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { infoHandler.handle(it) } .also { @@ -239,7 +237,6 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp private val settingsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun settings( params: BudgetSettingsParams, @@ -254,7 +251,7 @@ class BudgetServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { settingsHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt index 64fdfecd..03557ded 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt @@ -45,17 +45,17 @@ interface CacheService { */ fun delete(): CacheDeleteResponse = delete(CacheDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CacheDeleteParams = CacheDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CacheDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: CacheDeleteParams = CacheDeleteParams.none()): CacheDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(requestOptions: RequestOptions): CacheDeleteResponse = delete(CacheDeleteParams.none(), requestOptions) @@ -71,34 +71,34 @@ interface CacheService { */ fun flushAll(): CacheFlushAllResponse = flushAll(CacheFlushAllParams.none()) - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CacheFlushAllResponse - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll(params: CacheFlushAllParams = CacheFlushAllParams.none()): CacheFlushAllResponse = flushAll(params, RequestOptions.none()) - /** @see [flushAll] */ + /** @see flushAll */ fun flushAll(requestOptions: RequestOptions): CacheFlushAllResponse = flushAll(CacheFlushAllParams.none(), requestOptions) /** Endpoint for checking if cache can be pinged */ fun ping(): CachePingResponse = ping(CachePingParams.none()) - /** @see [ping] */ + /** @see ping */ fun ping( params: CachePingParams = CachePingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CachePingResponse - /** @see [ping] */ + /** @see ping */ fun ping(params: CachePingParams = CachePingParams.none()): CachePingResponse = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ fun ping(requestOptions: RequestOptions): CachePingResponse = ping(CachePingParams.none(), requestOptions) @@ -121,20 +121,20 @@ interface CacheService { @MustBeClosed fun delete(): HttpResponseFor = delete(CacheDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: CacheDeleteParams = CacheDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: CacheDeleteParams = CacheDeleteParams.none() ): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(requestOptions: RequestOptions): HttpResponseFor = delete(CacheDeleteParams.none(), requestOptions) @@ -147,20 +147,20 @@ interface CacheService { fun flushAll(): HttpResponseFor = flushAll(CacheFlushAllParams.none()) - /** @see [flushAll] */ + /** @see flushAll */ @MustBeClosed fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [flushAll] */ + /** @see flushAll */ @MustBeClosed fun flushAll( params: CacheFlushAllParams = CacheFlushAllParams.none() ): HttpResponseFor = flushAll(params, RequestOptions.none()) - /** @see [flushAll] */ + /** @see flushAll */ @MustBeClosed fun flushAll(requestOptions: RequestOptions): HttpResponseFor = flushAll(CacheFlushAllParams.none(), requestOptions) @@ -171,20 +171,20 @@ interface CacheService { */ @MustBeClosed fun ping(): HttpResponseFor = ping(CachePingParams.none()) - /** @see [ping] */ + /** @see ping */ @MustBeClosed fun ping( params: CachePingParams = CachePingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [ping] */ + /** @see ping */ @MustBeClosed fun ping( params: CachePingParams = CachePingParams.none() ): HttpResponseFor = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ @MustBeClosed fun ping(requestOptions: RequestOptions): HttpResponseFor = ping(CachePingParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt index b9d928ad..d63b8500 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -62,7 +62,8 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CacheService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val redis: RediService.WithRawResponse by lazy { RediServiceImpl.WithRawResponseImpl(clientOptions) @@ -79,7 +80,6 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CacheDeleteParams, @@ -95,7 +95,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -108,7 +108,6 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt private val flushAllHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun flushAll( params: CacheFlushAllParams, @@ -124,7 +123,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { flushAllHandler.handle(it) } .also { @@ -136,7 +135,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt } private val pingHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun ping( params: CachePingParams, @@ -151,7 +150,7 @@ class CacheServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { pingHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt index 691ddbc7..cef53e90 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereService.kt @@ -35,30 +35,30 @@ interface CohereService { /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ fun create(endpoint: String): CohereCreateResponse = create(endpoint, CohereCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CohereCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), ): CohereCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CohereCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CohereCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: CohereCreateParams): CohereCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): CohereCreateResponse = create(endpoint, CohereCreateParams.none(), requestOptions) @@ -66,7 +66,7 @@ interface CohereService { fun retrieve(endpoint: String): CohereRetrieveResponse = retrieve(endpoint, CohereRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), @@ -74,113 +74,113 @@ interface CohereService { ): CohereRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: CohereRetrieveParams = CohereRetrieveParams.none(), ): CohereRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CohereRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CohereRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: CohereRetrieveParams): CohereRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): CohereRetrieveResponse = retrieve(endpoint, CohereRetrieveParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ fun update(endpoint: String): CohereUpdateResponse = update(endpoint, CohereUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CohereUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), ): CohereUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: CohereUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CohereUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: CohereUpdateParams): CohereUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): CohereUpdateResponse = update(endpoint, CohereUpdateParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ fun delete(endpoint: String): CohereDeleteResponse = delete(endpoint, CohereDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CohereDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), ): CohereDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CohereDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CohereDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: CohereDeleteParams): CohereDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): CohereDeleteResponse = delete(endpoint, CohereDeleteParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ fun modify(endpoint: String): CohereModifyResponse = modify(endpoint, CohereModifyParams.none()) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CohereModifyResponse = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), ): CohereModifyResponse = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify( params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CohereModifyResponse - /** @see [modify] */ + /** @see modify */ fun modify(params: CohereModifyParams): CohereModifyResponse = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ fun modify(endpoint: String, requestOptions: RequestOptions): CohereModifyResponse = modify(endpoint, CohereModifyParams.none(), requestOptions) @@ -202,7 +202,7 @@ interface CohereService { fun create(endpoint: String): HttpResponseFor = create(endpoint, CohereCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -211,26 +211,26 @@ interface CohereService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: CohereCreateParams = CohereCreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CohereCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: CohereCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -246,7 +246,7 @@ interface CohereService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, CohereRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -255,7 +255,7 @@ interface CohereService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -263,19 +263,19 @@ interface CohereService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: CohereRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: CohereRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -291,7 +291,7 @@ interface CohereService { fun update(endpoint: String): HttpResponseFor = update(endpoint, CohereUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -300,26 +300,26 @@ interface CohereService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: CohereUpdateParams = CohereUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: CohereUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: CohereUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -335,7 +335,7 @@ interface CohereService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, CohereDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -344,26 +344,26 @@ interface CohereService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: CohereDeleteParams = CohereDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: CohereDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: CohereDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -379,7 +379,7 @@ interface CohereService { fun modify(endpoint: String): HttpResponseFor = modify(endpoint, CohereModifyParams.none()) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( endpoint: String, @@ -388,26 +388,26 @@ interface CohereService { ): HttpResponseFor = modify(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( endpoint: String, params: CohereModifyParams = CohereModifyParams.none(), ): HttpResponseFor = modify(endpoint, params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( params: CohereModifyParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify(params: CohereModifyParams): HttpResponseFor = modify(params, RequestOptions.none()) - /** @see [modify] */ + /** @see modify */ @MustBeClosed fun modify( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt index 567f004f..c948b2d0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CohereServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CohereService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CohereCreateParams, @@ -109,7 +109,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CohereRetrieveParams, @@ -140,7 +139,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: CohereUpdateParams, @@ -172,7 +170,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CohereDeleteParams, @@ -204,7 +201,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp private val modifyHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun modify( params: CohereModifyParams, @@ -236,7 +232,7 @@ class CohereServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { modifyHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt index 329ece6f..90f492e6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionService.kt @@ -42,18 +42,18 @@ interface CompletionService { */ fun create(): CompletionCreateResponse = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletionCreateResponse - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletionCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletionCreateResponse = create(CompletionCreateParams.none(), requestOptions) @@ -77,20 +77,20 @@ interface CompletionService { fun create(): HttpResponseFor = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(CompletionCreateParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt index 4542d3e9..32e93425 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CompletionServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CompletionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CompletionCreateParams, @@ -68,7 +68,7 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt index 947a99ce..ec3987e4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialService.kt @@ -35,7 +35,7 @@ interface CredentialService { fun create(params: CredentialCreateParams): CredentialCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CredentialCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -44,17 +44,17 @@ interface CredentialService { /** [BETA] endpoint. This might change unexpectedly. */ fun list(): CredentialListResponse = list(CredentialListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: CredentialListParams = CredentialListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CredentialListResponse - /** @see [list] */ + /** @see list */ fun list(params: CredentialListParams = CredentialListParams.none()): CredentialListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): CredentialListResponse = list(CredentialListParams.none(), requestOptions) @@ -62,7 +62,7 @@ interface CredentialService { fun delete(credentialName: String): CredentialDeleteResponse = delete(credentialName, CredentialDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), @@ -70,23 +70,23 @@ interface CredentialService { ): CredentialDeleteResponse = delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( credentialName: String, params: CredentialDeleteParams = CredentialDeleteParams.none(), ): CredentialDeleteResponse = delete(credentialName, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CredentialDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: CredentialDeleteParams): CredentialDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(credentialName: String, requestOptions: RequestOptions): CredentialDeleteResponse = delete(credentialName, CredentialDeleteParams.none(), requestOptions) @@ -110,7 +110,7 @@ interface CredentialService { fun create(params: CredentialCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CredentialCreateParams, @@ -124,20 +124,20 @@ interface CredentialService { @MustBeClosed fun list(): HttpResponseFor = list(CredentialListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: CredentialListParams = CredentialListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: CredentialListParams = CredentialListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(CredentialListParams.none(), requestOptions) @@ -150,7 +150,7 @@ interface CredentialService { fun delete(credentialName: String): HttpResponseFor = delete(credentialName, CredentialDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( credentialName: String, @@ -159,7 +159,7 @@ interface CredentialService { ): HttpResponseFor = delete(params.toBuilder().credentialName(credentialName).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( credentialName: String, @@ -167,19 +167,19 @@ interface CredentialService { ): HttpResponseFor = delete(credentialName, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: CredentialDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: CredentialDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( credentialName: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt index 97d200e2..e8d93978 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CredentialServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -61,7 +61,8 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CredentialService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -72,7 +73,6 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CredentialCreateParams, @@ -88,7 +88,7 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -101,7 +101,6 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CredentialListParams, @@ -116,7 +115,7 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -129,7 +128,6 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CredentialDeleteParams, @@ -148,7 +146,7 @@ class CredentialServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt index 07c71ced..9bbe1eed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt @@ -87,7 +87,7 @@ interface CustomerService { fun create(params: CustomerCreateParams): CustomerCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CustomerCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -120,7 +120,7 @@ interface CustomerService { fun update(params: CustomerUpdateParams): CustomerUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: CustomerUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -136,17 +136,17 @@ interface CustomerService { */ fun list(): List = list(CustomerListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: CustomerListParams = CustomerListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): List - /** @see [list] */ + /** @see list */ fun list(params: CustomerListParams = CustomerListParams.none()): List = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): List = list(CustomerListParams.none(), requestOptions) @@ -168,7 +168,7 @@ interface CustomerService { fun delete(params: CustomerDeleteParams): CustomerDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: CustomerDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -188,7 +188,7 @@ interface CustomerService { fun block(params: CustomerBlockParams): CustomerBlockResponse = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: CustomerBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -208,7 +208,7 @@ interface CustomerService { fun retrieveInfo(params: CustomerRetrieveInfoParams): CustomerRetrieveInfoResponse = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: CustomerRetrieveInfoParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -230,7 +230,7 @@ interface CustomerService { fun unblock(params: CustomerUnblockParams): CustomerUnblockResponse = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: CustomerUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -254,7 +254,7 @@ interface CustomerService { fun create(params: CustomerCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CustomerCreateParams, @@ -269,7 +269,7 @@ interface CustomerService { fun update(params: CustomerUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: CustomerUpdateParams, @@ -283,20 +283,20 @@ interface CustomerService { @MustBeClosed fun list(): HttpResponseFor> = list(CustomerListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: CustomerListParams = CustomerListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: CustomerListParams = CustomerListParams.none() ): HttpResponseFor> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor> = list(CustomerListParams.none(), requestOptions) @@ -309,7 +309,7 @@ interface CustomerService { fun delete(params: CustomerDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: CustomerDeleteParams, @@ -324,7 +324,7 @@ interface CustomerService { fun block(params: CustomerBlockParams): HttpResponseFor = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ @MustBeClosed fun block( params: CustomerBlockParams, @@ -341,7 +341,7 @@ interface CustomerService { ): HttpResponseFor = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: CustomerRetrieveInfoParams, @@ -356,7 +356,7 @@ interface CustomerService { fun unblock(params: CustomerUnblockParams): HttpResponseFor = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ @MustBeClosed fun unblock( params: CustomerUnblockParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt index fa143567..2a5e417d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -95,7 +95,8 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -106,7 +107,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CustomerCreateParams, @@ -122,7 +122,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -135,7 +135,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: CustomerUpdateParams, @@ -151,7 +150,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -164,7 +163,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: CustomerListParams, @@ -179,7 +177,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -192,7 +190,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: CustomerDeleteParams, @@ -208,7 +205,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -221,7 +218,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val blockHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun block( params: CustomerBlockParams, @@ -237,7 +233,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { blockHandler.handle(it) } .also { @@ -250,7 +246,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: CustomerRetrieveInfoParams, @@ -265,7 +260,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { @@ -278,7 +273,6 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client private val unblockHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun unblock( params: CustomerUnblockParams, @@ -294,7 +288,7 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { unblockHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt index 28347298..b9c5b89e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt @@ -28,7 +28,7 @@ interface DeleteService { fun createAllowedIp(params: DeleteCreateAllowedIpParams): DeleteCreateAllowedIpResponse = createAllowedIp(params, RequestOptions.none()) - /** @see [createAllowedIp] */ + /** @see createAllowedIp */ fun createAllowedIp( params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -54,7 +54,7 @@ interface DeleteService { ): HttpResponseFor = createAllowedIp(params, RequestOptions.none()) - /** @see [createAllowedIp] */ + /** @see createAllowedIp */ @MustBeClosed fun createAllowedIp( params: DeleteCreateAllowedIpParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt index 1e6e6655..43276599 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class DeleteServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DeleteService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class DeleteServiceImpl internal constructor(private val clientOptions: ClientOp private val createAllowedIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createAllowedIp( params: DeleteCreateAllowedIpParams, @@ -68,7 +68,7 @@ class DeleteServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createAllowedIpHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt index ea8ccc9d..75f58ae9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingService.kt @@ -40,18 +40,18 @@ interface EmbeddingService { */ fun create(): EmbeddingCreateResponse = create(EmbeddingCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): EmbeddingCreateResponse - /** @see [create] */ + /** @see create */ fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none() ): EmbeddingCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): EmbeddingCreateResponse = create(EmbeddingCreateParams.none(), requestOptions) @@ -73,20 +73,20 @@ interface EmbeddingService { fun create(): HttpResponseFor = create(EmbeddingCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: EmbeddingCreateParams = EmbeddingCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(EmbeddingCreateParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt index bedce9bc..3bd78445 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EmbeddingService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: EmbeddingCreateParams, @@ -68,7 +68,7 @@ class EmbeddingServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt index 0588b494..161f4be4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineService.kt @@ -48,30 +48,30 @@ interface EngineService { fun complete(model: String): EngineCompleteResponse = complete(model, EngineCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): EngineCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), ): EngineCompleteResponse = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: EngineCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): EngineCompleteResponse - /** @see [complete] */ + /** @see complete */ fun complete(params: EngineCompleteParams): EngineCompleteResponse = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete(model: String, requestOptions: RequestOptions): EngineCompleteResponse = complete(model, EngineCompleteParams.none(), requestOptions) @@ -91,29 +91,29 @@ interface EngineService { */ fun embed(model: String): EngineEmbedResponse = embed(model, EngineEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): EngineEmbedResponse = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), ): EngineEmbedResponse = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): EngineEmbedResponse - /** @see [embed] */ + /** @see embed */ fun embed(params: EngineEmbedParams): EngineEmbedResponse = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed(model: String, requestOptions: RequestOptions): EngineEmbedResponse = embed(model, EngineEmbedParams.none(), requestOptions) @@ -137,7 +137,7 @@ interface EngineService { fun complete(model: String): HttpResponseFor = complete(model, EngineCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -146,26 +146,26 @@ interface EngineService { ): HttpResponseFor = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, params: EngineCompleteParams = EngineCompleteParams.none(), ): HttpResponseFor = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( params: EngineCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete(params: EngineCompleteParams): HttpResponseFor = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -181,7 +181,7 @@ interface EngineService { fun embed(model: String): HttpResponseFor = embed(model, EngineEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( model: String, @@ -190,26 +190,26 @@ interface EngineService { ): HttpResponseFor = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( model: String, params: EngineEmbedParams = EngineEmbedParams.none(), ): HttpResponseFor = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( params: EngineEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed(params: EngineEmbedParams): HttpResponseFor = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( model: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt index 4fcc2511..a270effc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EngineServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -58,7 +58,8 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EngineService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val chat: ChatService.WithRawResponse by lazy { ChatServiceImpl.WithRawResponseImpl(clientOptions) @@ -75,7 +76,6 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: EngineCompleteParams, @@ -94,7 +94,7 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { @@ -107,7 +107,6 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp private val embedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun embed( params: EngineEmbedParams, @@ -126,7 +125,7 @@ class EngineServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { embedHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt index 7789f5ce..89aed195 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiService.kt @@ -36,7 +36,7 @@ interface EuAssemblyaiService { fun create(endpoint: String): EuAssemblyaiCreateResponse = create(endpoint, EuAssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), @@ -44,23 +44,23 @@ interface EuAssemblyaiService { ): EuAssemblyaiCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: EuAssemblyaiCreateParams = EuAssemblyaiCreateParams.none(), ): EuAssemblyaiCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: EuAssemblyaiCreateParams): EuAssemblyaiCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiCreateResponse = create(endpoint, EuAssemblyaiCreateParams.none(), requestOptions) @@ -68,7 +68,7 @@ interface EuAssemblyaiService { fun retrieve(endpoint: String): EuAssemblyaiRetrieveResponse = retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), @@ -76,23 +76,23 @@ interface EuAssemblyaiService { ): EuAssemblyaiRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: EuAssemblyaiRetrieveParams = EuAssemblyaiRetrieveParams.none(), ): EuAssemblyaiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: EuAssemblyaiRetrieveParams): EuAssemblyaiRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiRetrieveResponse = retrieve(endpoint, EuAssemblyaiRetrieveParams.none(), requestOptions) @@ -100,7 +100,7 @@ interface EuAssemblyaiService { fun update(endpoint: String): EuAssemblyaiUpdateResponse = update(endpoint, EuAssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), @@ -108,23 +108,23 @@ interface EuAssemblyaiService { ): EuAssemblyaiUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: EuAssemblyaiUpdateParams = EuAssemblyaiUpdateParams.none(), ): EuAssemblyaiUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: EuAssemblyaiUpdateParams): EuAssemblyaiUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiUpdateResponse = update(endpoint, EuAssemblyaiUpdateParams.none(), requestOptions) @@ -132,7 +132,7 @@ interface EuAssemblyaiService { fun delete(endpoint: String): EuAssemblyaiDeleteResponse = delete(endpoint, EuAssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), @@ -140,23 +140,23 @@ interface EuAssemblyaiService { ): EuAssemblyaiDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: EuAssemblyaiDeleteParams = EuAssemblyaiDeleteParams.none(), ): EuAssemblyaiDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: EuAssemblyaiDeleteParams): EuAssemblyaiDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiDeleteResponse = delete(endpoint, EuAssemblyaiDeleteParams.none(), requestOptions) @@ -164,7 +164,7 @@ interface EuAssemblyaiService { fun patch(endpoint: String): EuAssemblyaiPatchResponse = patch(endpoint, EuAssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), @@ -172,23 +172,23 @@ interface EuAssemblyaiService { ): EuAssemblyaiPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: EuAssemblyaiPatchParams = EuAssemblyaiPatchParams.none(), ): EuAssemblyaiPatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): EuAssemblyaiPatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: EuAssemblyaiPatchParams): EuAssemblyaiPatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): EuAssemblyaiPatchResponse = patch(endpoint, EuAssemblyaiPatchParams.none(), requestOptions) @@ -214,7 +214,7 @@ interface EuAssemblyaiService { fun create(endpoint: String): HttpResponseFor = create(endpoint, EuAssemblyaiCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -223,7 +223,7 @@ interface EuAssemblyaiService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -231,19 +231,19 @@ interface EuAssemblyaiService { ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: EuAssemblyaiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: EuAssemblyaiCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -259,7 +259,7 @@ interface EuAssemblyaiService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, EuAssemblyaiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -268,7 +268,7 @@ interface EuAssemblyaiService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -276,20 +276,20 @@ interface EuAssemblyaiService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: EuAssemblyaiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: EuAssemblyaiRetrieveParams ): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -305,7 +305,7 @@ interface EuAssemblyaiService { fun update(endpoint: String): HttpResponseFor = update(endpoint, EuAssemblyaiUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -314,7 +314,7 @@ interface EuAssemblyaiService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -322,19 +322,19 @@ interface EuAssemblyaiService { ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: EuAssemblyaiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: EuAssemblyaiUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -350,7 +350,7 @@ interface EuAssemblyaiService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, EuAssemblyaiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -359,7 +359,7 @@ interface EuAssemblyaiService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -367,19 +367,19 @@ interface EuAssemblyaiService { ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: EuAssemblyaiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: EuAssemblyaiDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -395,7 +395,7 @@ interface EuAssemblyaiService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, EuAssemblyaiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -404,7 +404,7 @@ interface EuAssemblyaiService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -412,19 +412,19 @@ interface EuAssemblyaiService { ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: EuAssemblyaiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: EuAssemblyaiPatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt index d0ccbc3f..77cfe748 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EuAssemblyaiService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: EuAssemblyaiCreateParams, @@ -109,7 +109,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: EuAssemblyaiRetrieveParams, @@ -140,7 +139,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: EuAssemblyaiUpdateParams, @@ -172,7 +170,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: EuAssemblyaiDeleteParams, @@ -204,7 +201,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: EuAssemblyaiPatchParams, @@ -236,7 +232,7 @@ class EuAssemblyaiServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt index 19666c33..593a5c85 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileService.kt @@ -49,17 +49,17 @@ interface FileService { fun create(provider: String, params: FileCreateParams): FileCreateResponse = create(provider, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( provider: String, params: FileCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileCreateResponse = create(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create(params: FileCreateParams): FileCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: FileCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -81,18 +81,18 @@ interface FileService { fun retrieve(fileId: String, params: FileRetrieveParams): FileRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fileId: String, params: FileRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: FileRetrieveParams): FileRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: FileRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -113,27 +113,27 @@ interface FileService { */ fun list(provider: String): FileListResponse = list(provider, FileListParams.none()) - /** @see [list] */ + /** @see list */ fun list( provider: String, params: FileListParams = FileListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): FileListResponse = list(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list(provider: String, params: FileListParams = FileListParams.none()): FileListResponse = list(provider, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: FileListParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileListResponse - /** @see [list] */ + /** @see list */ fun list(params: FileListParams): FileListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(provider: String, requestOptions: RequestOptions): FileListResponse = list(provider, FileListParams.none(), requestOptions) @@ -153,17 +153,17 @@ interface FileService { fun delete(fileId: String, params: FileDeleteParams): FileDeleteResponse = delete(fileId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( fileId: String, params: FileDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileDeleteResponse = delete(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete(params: FileDeleteParams): FileDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: FileDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -191,7 +191,7 @@ interface FileService { params: FileCreateParams, ): HttpResponseFor = create(provider, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( provider: String, @@ -200,12 +200,12 @@ interface FileService { ): HttpResponseFor = create(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: FileCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: FileCreateParams, @@ -222,7 +222,7 @@ interface FileService { params: FileRetrieveParams, ): HttpResponseFor = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( fileId: String, @@ -231,12 +231,12 @@ interface FileService { ): HttpResponseFor = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: FileRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: FileRetrieveParams, @@ -251,7 +251,7 @@ interface FileService { fun list(provider: String): HttpResponseFor = list(provider, FileListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( provider: String, @@ -260,26 +260,26 @@ interface FileService { ): HttpResponseFor = list(params.toBuilder().provider(provider).build(), requestOptions) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( provider: String, params: FileListParams = FileListParams.none(), ): HttpResponseFor = list(provider, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: FileListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(params: FileListParams): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( provider: String, @@ -294,7 +294,7 @@ interface FileService { fun delete(fileId: String, params: FileDeleteParams): HttpResponseFor = delete(fileId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( fileId: String, @@ -303,12 +303,12 @@ interface FileService { ): HttpResponseFor = delete(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: FileDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: FileDeleteParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt index d32a1bfb..68e34591 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/FileServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -73,7 +73,8 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FileService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val content: ContentService.WithRawResponse by lazy { ContentServiceImpl.WithRawResponseImpl(clientOptions) @@ -89,7 +90,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti override fun content(): ContentService.WithRawResponse = content private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: FileCreateParams, @@ -108,7 +109,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -121,7 +122,6 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: FileRetrieveParams, @@ -139,7 +139,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -151,7 +151,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: FileListParams, @@ -169,7 +169,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -181,7 +181,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: FileDeleteParams, @@ -200,7 +200,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt index 80140a68..d122a3ec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiService.kt @@ -35,30 +35,30 @@ interface GeminiService { /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ fun create(endpoint: String): GeminiCreateResponse = create(endpoint, GeminiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GeminiCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), ): GeminiCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: GeminiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): GeminiCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: GeminiCreateParams): GeminiCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): GeminiCreateResponse = create(endpoint, GeminiCreateParams.none(), requestOptions) @@ -66,7 +66,7 @@ interface GeminiService { fun retrieve(endpoint: String): GeminiRetrieveResponse = retrieve(endpoint, GeminiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), @@ -74,112 +74,112 @@ interface GeminiService { ): GeminiRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: GeminiRetrieveParams = GeminiRetrieveParams.none(), ): GeminiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: GeminiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): GeminiRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: GeminiRetrieveParams): GeminiRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): GeminiRetrieveResponse = retrieve(endpoint, GeminiRetrieveParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ fun update(endpoint: String): GeminiUpdateResponse = update(endpoint, GeminiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GeminiUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), ): GeminiUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: GeminiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): GeminiUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: GeminiUpdateParams): GeminiUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): GeminiUpdateResponse = update(endpoint, GeminiUpdateParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ fun delete(endpoint: String): GeminiDeleteResponse = delete(endpoint, GeminiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GeminiDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), ): GeminiDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: GeminiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): GeminiDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: GeminiDeleteParams): GeminiDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): GeminiDeleteResponse = delete(endpoint, GeminiDeleteParams.none(), requestOptions) /** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ fun patch(endpoint: String): GeminiPatchResponse = patch(endpoint, GeminiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GeminiPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), ): GeminiPatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): GeminiPatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: GeminiPatchParams): GeminiPatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): GeminiPatchResponse = patch(endpoint, GeminiPatchParams.none(), requestOptions) @@ -201,7 +201,7 @@ interface GeminiService { fun create(endpoint: String): HttpResponseFor = create(endpoint, GeminiCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -210,26 +210,26 @@ interface GeminiService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: GeminiCreateParams = GeminiCreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: GeminiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: GeminiCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -245,7 +245,7 @@ interface GeminiService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, GeminiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -254,7 +254,7 @@ interface GeminiService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -262,19 +262,19 @@ interface GeminiService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: GeminiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: GeminiRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -290,7 +290,7 @@ interface GeminiService { fun update(endpoint: String): HttpResponseFor = update(endpoint, GeminiUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -299,26 +299,26 @@ interface GeminiService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: GeminiUpdateParams = GeminiUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: GeminiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: GeminiUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -334,7 +334,7 @@ interface GeminiService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, GeminiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -343,26 +343,26 @@ interface GeminiService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: GeminiDeleteParams = GeminiDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: GeminiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: GeminiDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -378,7 +378,7 @@ interface GeminiService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, GeminiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -387,26 +387,26 @@ interface GeminiService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: GeminiPatchParams = GeminiPatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: GeminiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: GeminiPatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt index e495e100..f8e626c8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GeminiServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : GeminiService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: GeminiCreateParams, @@ -109,7 +109,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: GeminiRetrieveParams, @@ -140,7 +139,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: GeminiUpdateParams, @@ -172,7 +170,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: GeminiDeleteParams, @@ -204,7 +201,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: GeminiPatchParams, @@ -236,7 +232,7 @@ class GeminiServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt index d654171f..033c3624 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt @@ -60,17 +60,17 @@ interface GuardrailService { */ fun list(): GuardrailListResponse = list(GuardrailListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: GuardrailListParams = GuardrailListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GuardrailListResponse - /** @see [list] */ + /** @see list */ fun list(params: GuardrailListParams = GuardrailListParams.none()): GuardrailListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): GuardrailListResponse = list(GuardrailListParams.none(), requestOptions) @@ -91,20 +91,20 @@ interface GuardrailService { @MustBeClosed fun list(): HttpResponseFor = list(GuardrailListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: GuardrailListParams = GuardrailListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: GuardrailListParams = GuardrailListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(GuardrailListParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt index dfda49ec..f58597e0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -40,7 +40,8 @@ class GuardrailServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : GuardrailService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,6 @@ class GuardrailServiceImpl internal constructor(private val clientOptions: Clien private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: GuardrailListParams, @@ -66,7 +66,7 @@ class GuardrailServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt index 4442b3ed..ca5ceea6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthService.kt @@ -50,18 +50,18 @@ interface HealthService { */ fun checkAll(): HealthCheckAllResponse = checkAll(HealthCheckAllParams.none()) - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HealthCheckAllResponse - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none() ): HealthCheckAllResponse = checkAll(params, RequestOptions.none()) - /** @see [checkAll] */ + /** @see checkAll */ fun checkAll(requestOptions: RequestOptions): HealthCheckAllResponse = checkAll(HealthCheckAllParams.none(), requestOptions) @@ -69,18 +69,18 @@ interface HealthService { fun checkLiveliness(): HealthCheckLivelinessResponse = checkLiveliness(HealthCheckLivelinessParams.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HealthCheckLivelinessResponse - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none() ): HealthCheckLivelinessResponse = checkLiveliness(params, RequestOptions.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ fun checkLiveliness(requestOptions: RequestOptions): HealthCheckLivelinessResponse = checkLiveliness(HealthCheckLivelinessParams.none(), requestOptions) @@ -88,18 +88,18 @@ interface HealthService { fun checkLiveness(): HealthCheckLivenessResponse = checkLiveness(HealthCheckLivenessParams.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HealthCheckLivenessResponse - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none() ): HealthCheckLivenessResponse = checkLiveness(params, RequestOptions.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ fun checkLiveness(requestOptions: RequestOptions): HealthCheckLivenessResponse = checkLiveness(HealthCheckLivenessParams.none(), requestOptions) @@ -107,18 +107,18 @@ interface HealthService { fun checkReadiness(): HealthCheckReadinessResponse = checkReadiness(HealthCheckReadinessParams.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HealthCheckReadinessResponse - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none() ): HealthCheckReadinessResponse = checkReadiness(params, RequestOptions.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ fun checkReadiness(requestOptions: RequestOptions): HealthCheckReadinessResponse = checkReadiness(HealthCheckReadinessParams.none(), requestOptions) @@ -133,7 +133,7 @@ interface HealthService { fun checkServices(params: HealthCheckServicesParams): HealthCheckServicesResponse = checkServices(params, RequestOptions.none()) - /** @see [checkServices] */ + /** @see checkServices */ fun checkServices( params: HealthCheckServicesParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -157,20 +157,20 @@ interface HealthService { fun checkAll(): HttpResponseFor = checkAll(HealthCheckAllParams.none()) - /** @see [checkAll] */ + /** @see checkAll */ @MustBeClosed fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [checkAll] */ + /** @see checkAll */ @MustBeClosed fun checkAll( params: HealthCheckAllParams = HealthCheckAllParams.none() ): HttpResponseFor = checkAll(params, RequestOptions.none()) - /** @see [checkAll] */ + /** @see checkAll */ @MustBeClosed fun checkAll(requestOptions: RequestOptions): HttpResponseFor = checkAll(HealthCheckAllParams.none(), requestOptions) @@ -183,21 +183,21 @@ interface HealthService { fun checkLiveliness(): HttpResponseFor = checkLiveliness(HealthCheckLivelinessParams.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ @MustBeClosed fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ @MustBeClosed fun checkLiveliness( params: HealthCheckLivelinessParams = HealthCheckLivelinessParams.none() ): HttpResponseFor = checkLiveliness(params, RequestOptions.none()) - /** @see [checkLiveliness] */ + /** @see checkLiveliness */ @MustBeClosed fun checkLiveliness( requestOptions: RequestOptions @@ -212,21 +212,21 @@ interface HealthService { fun checkLiveness(): HttpResponseFor = checkLiveness(HealthCheckLivenessParams.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ @MustBeClosed fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [checkLiveness] */ + /** @see checkLiveness */ @MustBeClosed fun checkLiveness( params: HealthCheckLivenessParams = HealthCheckLivenessParams.none() ): HttpResponseFor = checkLiveness(params, RequestOptions.none()) - /** @see [checkLiveness] */ + /** @see checkLiveness */ @MustBeClosed fun checkLiveness( requestOptions: RequestOptions @@ -241,21 +241,21 @@ interface HealthService { fun checkReadiness(): HttpResponseFor = checkReadiness(HealthCheckReadinessParams.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ @MustBeClosed fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [checkReadiness] */ + /** @see checkReadiness */ @MustBeClosed fun checkReadiness( params: HealthCheckReadinessParams = HealthCheckReadinessParams.none() ): HttpResponseFor = checkReadiness(params, RequestOptions.none()) - /** @see [checkReadiness] */ + /** @see checkReadiness */ @MustBeClosed fun checkReadiness( requestOptions: RequestOptions @@ -272,7 +272,7 @@ interface HealthService { ): HttpResponseFor = checkServices(params, RequestOptions.none()) - /** @see [checkServices] */ + /** @see checkServices */ @MustBeClosed fun checkServices( params: HealthCheckServicesParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt index 2a7950c2..2800dc55 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/HealthServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -76,7 +76,8 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : HealthService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -87,7 +88,6 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp private val checkAllHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkAll( params: HealthCheckAllParams, @@ -102,7 +102,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkAllHandler.handle(it) } .also { @@ -115,7 +115,6 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp private val checkLivelinessHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkLiveliness( params: HealthCheckLivelinessParams, @@ -130,7 +129,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkLivelinessHandler.handle(it) } .also { @@ -143,7 +142,6 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp private val checkLivenessHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkLiveness( params: HealthCheckLivenessParams, @@ -158,7 +156,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkLivenessHandler.handle(it) } .also { @@ -171,7 +169,6 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp private val checkReadinessHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkReadiness( params: HealthCheckReadinessParams, @@ -186,7 +183,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkReadinessHandler.handle(it) } .also { @@ -199,7 +196,6 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp private val checkServicesHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkServices( params: HealthCheckServicesParams, @@ -214,7 +210,7 @@ class HealthServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkServicesHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt index cccd22af..3e2252f0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt @@ -101,7 +101,7 @@ interface KeyService { */ fun update(params: KeyUpdateParams): KeyUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: KeyUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -115,17 +115,17 @@ interface KeyService { */ fun list(): KeyListResponse = list(KeyListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: KeyListParams = KeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): KeyListResponse - /** @see [list] */ + /** @see list */ fun list(params: KeyListParams = KeyListParams.none()): KeyListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): KeyListResponse = list(KeyListParams.none(), requestOptions) @@ -153,17 +153,17 @@ interface KeyService { */ fun delete(): KeyDeleteResponse = delete(KeyDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: KeyDeleteParams = KeyDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): KeyDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: KeyDeleteParams = KeyDeleteParams.none()): KeyDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(requestOptions: RequestOptions): KeyDeleteResponse = delete(KeyDeleteParams.none(), requestOptions) @@ -186,7 +186,7 @@ interface KeyService { fun block(params: KeyBlockParams): Optional = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: KeyBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -232,18 +232,18 @@ interface KeyService { */ fun checkHealth(): KeyCheckHealthResponse = checkHealth(KeyCheckHealthParams.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): KeyCheckHealthResponse - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none() ): KeyCheckHealthResponse = checkHealth(params, RequestOptions.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ fun checkHealth(requestOptions: RequestOptions): KeyCheckHealthResponse = checkHealth(KeyCheckHealthParams.none(), requestOptions) @@ -324,17 +324,17 @@ interface KeyService { */ fun generate(): GenerateKeyResponse = generate(KeyGenerateParams.none()) - /** @see [generate] */ + /** @see generate */ fun generate( params: KeyGenerateParams = KeyGenerateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GenerateKeyResponse - /** @see [generate] */ + /** @see generate */ fun generate(params: KeyGenerateParams = KeyGenerateParams.none()): GenerateKeyResponse = generate(params, RequestOptions.none()) - /** @see [generate] */ + /** @see generate */ fun generate(requestOptions: RequestOptions): GenerateKeyResponse = generate(KeyGenerateParams.none(), requestOptions) @@ -389,7 +389,7 @@ interface KeyService { fun regenerateByKey(pathKey: String): Optional = regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), @@ -397,23 +397,23 @@ interface KeyService { ): Optional = regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, params: KeyRegenerateByKeyParams = KeyRegenerateByKeyParams.none(), ): Optional = regenerateByKey(pathKey, params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( params: KeyRegenerateByKeyParams, requestOptions: RequestOptions = RequestOptions.none(), ): Optional - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey(params: KeyRegenerateByKeyParams): Optional = regenerateByKey(params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ fun regenerateByKey( pathKey: String, requestOptions: RequestOptions, @@ -439,18 +439,18 @@ interface KeyService { */ fun retrieveInfo(): KeyRetrieveInfoResponse = retrieveInfo(KeyRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): KeyRetrieveInfoResponse - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none() ): KeyRetrieveInfoResponse = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): KeyRetrieveInfoResponse = retrieveInfo(KeyRetrieveInfoParams.none(), requestOptions) @@ -473,7 +473,7 @@ interface KeyService { fun unblock(params: KeyUnblockParams): KeyUnblockResponse = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: KeyUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -499,7 +499,7 @@ interface KeyService { fun update(params: KeyUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: KeyUpdateParams, @@ -512,19 +512,19 @@ interface KeyService { */ @MustBeClosed fun list(): HttpResponseFor = list(KeyListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: KeyListParams = KeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(params: KeyListParams = KeyListParams.none()): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(KeyListParams.none(), requestOptions) @@ -536,20 +536,20 @@ interface KeyService { @MustBeClosed fun delete(): HttpResponseFor = delete(KeyDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: KeyDeleteParams = KeyDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: KeyDeleteParams = KeyDeleteParams.none() ): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(requestOptions: RequestOptions): HttpResponseFor = delete(KeyDeleteParams.none(), requestOptions) @@ -562,7 +562,7 @@ interface KeyService { fun block(params: KeyBlockParams): HttpResponseFor> = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ @MustBeClosed fun block( params: KeyBlockParams, @@ -577,20 +577,20 @@ interface KeyService { fun checkHealth(): HttpResponseFor = checkHealth(KeyCheckHealthParams.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ @MustBeClosed fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [checkHealth] */ + /** @see checkHealth */ @MustBeClosed fun checkHealth( params: KeyCheckHealthParams = KeyCheckHealthParams.none() ): HttpResponseFor = checkHealth(params, RequestOptions.none()) - /** @see [checkHealth] */ + /** @see checkHealth */ @MustBeClosed fun checkHealth(requestOptions: RequestOptions): HttpResponseFor = checkHealth(KeyCheckHealthParams.none(), requestOptions) @@ -602,20 +602,20 @@ interface KeyService { @MustBeClosed fun generate(): HttpResponseFor = generate(KeyGenerateParams.none()) - /** @see [generate] */ + /** @see generate */ @MustBeClosed fun generate( params: KeyGenerateParams = KeyGenerateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [generate] */ + /** @see generate */ @MustBeClosed fun generate( params: KeyGenerateParams = KeyGenerateParams.none() ): HttpResponseFor = generate(params, RequestOptions.none()) - /** @see [generate] */ + /** @see generate */ @MustBeClosed fun generate(requestOptions: RequestOptions): HttpResponseFor = generate(KeyGenerateParams.none(), requestOptions) @@ -628,7 +628,7 @@ interface KeyService { fun regenerateByKey(pathKey: String): HttpResponseFor> = regenerateByKey(pathKey, KeyRegenerateByKeyParams.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ @MustBeClosed fun regenerateByKey( pathKey: String, @@ -637,7 +637,7 @@ interface KeyService { ): HttpResponseFor> = regenerateByKey(params.toBuilder().pathKey(pathKey).build(), requestOptions) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ @MustBeClosed fun regenerateByKey( pathKey: String, @@ -645,21 +645,21 @@ interface KeyService { ): HttpResponseFor> = regenerateByKey(pathKey, params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ @MustBeClosed fun regenerateByKey( params: KeyRegenerateByKeyParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ @MustBeClosed fun regenerateByKey( params: KeyRegenerateByKeyParams ): HttpResponseFor> = regenerateByKey(params, RequestOptions.none()) - /** @see [regenerateByKey] */ + /** @see regenerateByKey */ @MustBeClosed fun regenerateByKey( pathKey: String, @@ -675,20 +675,20 @@ interface KeyService { fun retrieveInfo(): HttpResponseFor = retrieveInfo(KeyRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: KeyRetrieveInfoParams = KeyRetrieveInfoParams.none() ): HttpResponseFor = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo(requestOptions: RequestOptions): HttpResponseFor = retrieveInfo(KeyRetrieveInfoParams.none(), requestOptions) @@ -701,7 +701,7 @@ interface KeyService { fun unblock(params: KeyUnblockParams): HttpResponseFor = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ @MustBeClosed fun unblock( params: KeyUnblockParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt index 4def9ab4..214921b7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -117,7 +117,8 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : KeyService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val regenerate: RegenerateService.WithRawResponse by lazy { RegenerateServiceImpl.WithRawResponseImpl(clientOptions) @@ -133,7 +134,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio override fun regenerate(): RegenerateService.WithRawResponse = regenerate private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: KeyUpdateParams, @@ -149,7 +150,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -161,7 +162,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: KeyListParams, @@ -176,7 +177,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -188,7 +189,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: KeyDeleteParams, @@ -204,7 +205,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +218,6 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio private val blockHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun block( params: KeyBlockParams, @@ -233,7 +233,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { blockHandler.handle(it) } .also { @@ -246,7 +246,6 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio private val checkHealthHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun checkHealth( params: KeyCheckHealthParams, @@ -262,7 +261,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { checkHealthHandler.handle(it) } .also { @@ -275,7 +274,6 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio private val generateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun generate( params: KeyGenerateParams, @@ -291,7 +289,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { generateHandler.handle(it) } .also { @@ -304,7 +302,6 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio private val regenerateByKeyHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun regenerateByKey( params: KeyRegenerateByKeyParams, @@ -323,7 +320,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { regenerateByKeyHandler.handle(it) } .also { @@ -336,7 +333,6 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: KeyRetrieveInfoParams, @@ -351,7 +347,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { @@ -363,7 +359,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio } private val unblockHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun unblock( params: KeyUnblockParams, @@ -379,7 +375,7 @@ class KeyServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { unblockHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt index 4fb0b2e2..f7d6dca5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseService.kt @@ -40,7 +40,7 @@ interface LangfuseService { fun create(endpoint: String): LangfuseCreateResponse = create(endpoint, LangfuseCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), @@ -48,23 +48,23 @@ interface LangfuseService { ): LangfuseCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), ): LangfuseCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: LangfuseCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: LangfuseCreateParams): LangfuseCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): LangfuseCreateResponse = create(endpoint, LangfuseCreateParams.none(), requestOptions) @@ -76,7 +76,7 @@ interface LangfuseService { fun retrieve(endpoint: String): LangfuseRetrieveResponse = retrieve(endpoint, LangfuseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), @@ -84,23 +84,23 @@ interface LangfuseService { ): LangfuseRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: LangfuseRetrieveParams = LangfuseRetrieveParams.none(), ): LangfuseRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: LangfuseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: LangfuseRetrieveParams): LangfuseRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): LangfuseRetrieveResponse = retrieve(endpoint, LangfuseRetrieveParams.none(), requestOptions) @@ -112,7 +112,7 @@ interface LangfuseService { fun update(endpoint: String): LangfuseUpdateResponse = update(endpoint, LangfuseUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), @@ -120,23 +120,23 @@ interface LangfuseService { ): LangfuseUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), ): LangfuseUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: LangfuseUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: LangfuseUpdateParams): LangfuseUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): LangfuseUpdateResponse = update(endpoint, LangfuseUpdateParams.none(), requestOptions) @@ -148,7 +148,7 @@ interface LangfuseService { fun delete(endpoint: String): LangfuseDeleteResponse = delete(endpoint, LangfuseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), @@ -156,23 +156,23 @@ interface LangfuseService { ): LangfuseDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), ): LangfuseDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: LangfuseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): LangfuseDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: LangfuseDeleteParams): LangfuseDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): LangfuseDeleteResponse = delete(endpoint, LangfuseDeleteParams.none(), requestOptions) @@ -183,30 +183,30 @@ interface LangfuseService { */ fun patch(endpoint: String): LangfusePatchResponse = patch(endpoint, LangfusePatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): LangfusePatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), ): LangfusePatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): LangfusePatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: LangfusePatchParams): LangfusePatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): LangfusePatchResponse = patch(endpoint, LangfusePatchParams.none(), requestOptions) @@ -228,7 +228,7 @@ interface LangfuseService { fun create(endpoint: String): HttpResponseFor = create(endpoint, LangfuseCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -237,26 +237,26 @@ interface LangfuseService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: LangfuseCreateParams = LangfuseCreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: LangfuseCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: LangfuseCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -272,7 +272,7 @@ interface LangfuseService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, LangfuseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -281,7 +281,7 @@ interface LangfuseService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -289,19 +289,19 @@ interface LangfuseService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: LangfuseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: LangfuseRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -317,7 +317,7 @@ interface LangfuseService { fun update(endpoint: String): HttpResponseFor = update(endpoint, LangfuseUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -326,26 +326,26 @@ interface LangfuseService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: LangfuseUpdateParams = LangfuseUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: LangfuseUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: LangfuseUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -361,7 +361,7 @@ interface LangfuseService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, LangfuseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -370,26 +370,26 @@ interface LangfuseService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: LangfuseDeleteParams = LangfuseDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: LangfuseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: LangfuseDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -405,7 +405,7 @@ interface LangfuseService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, LangfusePatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -414,26 +414,26 @@ interface LangfuseService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: LangfusePatchParams = LangfusePatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: LangfusePatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: LangfusePatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt index 4e5b550b..dfafec18 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LangfuseService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: LangfuseCreateParams, @@ -109,7 +109,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: LangfuseRetrieveParams, @@ -140,7 +139,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: LangfuseUpdateParams, @@ -172,7 +170,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: LangfuseDeleteParams, @@ -204,7 +201,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: LangfusePatchParams, @@ -236,7 +232,7 @@ class LangfuseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt index 02532a16..5da6b861 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt @@ -165,18 +165,18 @@ interface ModelGroupService { fun retrieveInfo(): ModelGroupRetrieveInfoResponse = retrieveInfo(ModelGroupRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ModelGroupRetrieveInfoResponse - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none() ): ModelGroupRetrieveInfoResponse = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): ModelGroupRetrieveInfoResponse = retrieveInfo(ModelGroupRetrieveInfoParams.none(), requestOptions) @@ -200,21 +200,21 @@ interface ModelGroupService { fun retrieveInfo(): HttpResponseFor = retrieveInfo(ModelGroupRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: ModelGroupRetrieveInfoParams = ModelGroupRetrieveInfoParams.none() ): HttpResponseFor = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt index e2de0524..473df151 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -40,7 +40,8 @@ class ModelGroupServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModelGroupService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,6 @@ class ModelGroupServiceImpl internal constructor(private val clientOptions: Clie private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: ModelGroupRetrieveInfoParams, @@ -66,7 +66,7 @@ class ModelGroupServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt index 7c75c065..7f965e15 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelService.kt @@ -36,7 +36,7 @@ interface ModelService { fun create(params: ModelCreateParams): ModelCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: ModelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +46,7 @@ interface ModelService { fun delete(params: ModelDeleteParams): ModelDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: ModelDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -74,7 +74,7 @@ interface ModelService { fun create(params: ModelCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ModelCreateParams, @@ -89,7 +89,7 @@ interface ModelService { fun delete(params: ModelDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: ModelDeleteParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt index 6338e447..7c364db4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -62,7 +62,8 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModelService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val info: InfoService.WithRawResponse by lazy { InfoServiceImpl.WithRawResponseImpl(clientOptions) @@ -85,7 +86,6 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ModelCreateParams, @@ -101,7 +101,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -114,7 +114,6 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: ModelDeleteParams, @@ -130,7 +129,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt index f4a6d24d..f44abfdd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationService.kt @@ -36,18 +36,18 @@ interface ModerationService { */ fun create(): ModerationCreateResponse = create(ModerationCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ModerationCreateParams = ModerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ModerationCreateResponse - /** @see [create] */ + /** @see create */ fun create( params: ModerationCreateParams = ModerationCreateParams.none() ): ModerationCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): ModerationCreateResponse = create(ModerationCreateParams.none(), requestOptions) @@ -71,20 +71,20 @@ interface ModerationService { fun create(): HttpResponseFor = create(ModerationCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ModerationCreateParams = ModerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ModerationCreateParams = ModerationCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(ModerationCreateParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt index 71c19002..a67bbf29 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModerationServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModerationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ModerationCreateParams, @@ -68,7 +68,7 @@ class ModerationServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt index 993d0766..0a37028c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIService.kt @@ -40,30 +40,30 @@ interface OpenAIService { */ fun create(endpoint: String): OpenAICreateResponse = create(endpoint, OpenAICreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OpenAICreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), ): OpenAICreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: OpenAICreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): OpenAICreateResponse - /** @see [create] */ + /** @see create */ fun create(params: OpenAICreateParams): OpenAICreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): OpenAICreateResponse = create(endpoint, OpenAICreateParams.none(), requestOptions) @@ -73,7 +73,7 @@ interface OpenAIService { fun retrieve(endpoint: String): OpenAIRetrieveResponse = retrieve(endpoint, OpenAIRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), @@ -81,23 +81,23 @@ interface OpenAIService { ): OpenAIRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: OpenAIRetrieveParams = OpenAIRetrieveParams.none(), ): OpenAIRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: OpenAIRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: OpenAIRetrieveParams): OpenAIRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): OpenAIRetrieveResponse = retrieve(endpoint, OpenAIRetrieveParams.none(), requestOptions) @@ -106,30 +106,30 @@ interface OpenAIService { */ fun update(endpoint: String): OpenAIUpdateResponse = update(endpoint, OpenAIUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), ): OpenAIUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: OpenAIUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: OpenAIUpdateParams): OpenAIUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): OpenAIUpdateResponse = update(endpoint, OpenAIUpdateParams.none(), requestOptions) @@ -138,30 +138,30 @@ interface OpenAIService { */ fun delete(endpoint: String): OpenAIDeleteResponse = delete(endpoint, OpenAIDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), ): OpenAIDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: OpenAIDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: OpenAIDeleteParams): OpenAIDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): OpenAIDeleteResponse = delete(endpoint, OpenAIDeleteParams.none(), requestOptions) @@ -170,29 +170,29 @@ interface OpenAIService { */ fun patch(endpoint: String): OpenAIPatchResponse = patch(endpoint, OpenAIPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), ): OpenAIPatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): OpenAIPatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: OpenAIPatchParams): OpenAIPatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): OpenAIPatchResponse = patch(endpoint, OpenAIPatchParams.none(), requestOptions) @@ -216,7 +216,7 @@ interface OpenAIService { fun create(endpoint: String): HttpResponseFor = create(endpoint, OpenAICreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -225,26 +225,26 @@ interface OpenAIService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: OpenAICreateParams = OpenAICreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: OpenAICreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: OpenAICreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -260,7 +260,7 @@ interface OpenAIService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, OpenAIRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -269,7 +269,7 @@ interface OpenAIService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -277,19 +277,19 @@ interface OpenAIService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: OpenAIRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: OpenAIRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -305,7 +305,7 @@ interface OpenAIService { fun update(endpoint: String): HttpResponseFor = update(endpoint, OpenAIUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -314,26 +314,26 @@ interface OpenAIService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: OpenAIUpdateParams = OpenAIUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: OpenAIUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: OpenAIUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -349,7 +349,7 @@ interface OpenAIService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, OpenAIDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -358,26 +358,26 @@ interface OpenAIService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: OpenAIDeleteParams = OpenAIDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: OpenAIDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: OpenAIDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -393,7 +393,7 @@ interface OpenAIService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, OpenAIPatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -402,26 +402,26 @@ interface OpenAIService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: OpenAIPatchParams = OpenAIPatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: OpenAIPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: OpenAIPatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt index 922ab4ae..014b3eb4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -85,7 +85,8 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OpenAIService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val deployments: DeploymentService.WithRawResponse by lazy { DeploymentServiceImpl.WithRawResponseImpl(clientOptions) @@ -102,7 +103,6 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: OpenAICreateParams, @@ -121,7 +121,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -134,7 +134,6 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: OpenAIRetrieveParams, @@ -152,7 +151,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -165,7 +164,6 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: OpenAIUpdateParams, @@ -184,7 +182,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -197,7 +195,6 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: OpenAIDeleteParams, @@ -216,7 +213,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -229,7 +226,6 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: OpenAIPatchParams, @@ -248,7 +244,7 @@ class OpenAIServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt index 984cb991..fcbd39af 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt @@ -104,7 +104,7 @@ interface OrganizationService { fun create(params: OrganizationCreateParams): OrganizationCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: OrganizationCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -113,18 +113,18 @@ interface OrganizationService { /** Update an organization */ fun update(): OrganizationUpdateResponse = update(OrganizationUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OrganizationUpdateResponse - /** @see [update] */ + /** @see update */ fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none() ): OrganizationUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(requestOptions: RequestOptions): OrganizationUpdateResponse = update(OrganizationUpdateParams.none(), requestOptions) @@ -135,18 +135,18 @@ interface OrganizationService { */ fun list(): List = list(OrganizationListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): List - /** @see [list] */ + /** @see list */ fun list( params: OrganizationListParams = OrganizationListParams.none() ): List = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): List = list(OrganizationListParams.none(), requestOptions) @@ -159,7 +159,7 @@ interface OrganizationService { fun delete(params: OrganizationDeleteParams): List = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -203,7 +203,7 @@ interface OrganizationService { fun addMember(params: OrganizationAddMemberParams): OrganizationAddMemberResponse = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ fun addMember( params: OrganizationAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -213,7 +213,7 @@ interface OrganizationService { fun deleteMember(params: OrganizationDeleteMemberParams): OrganizationDeleteMemberResponse = deleteMember(params, RequestOptions.none()) - /** @see [deleteMember] */ + /** @see deleteMember */ fun deleteMember( params: OrganizationDeleteMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -223,7 +223,7 @@ interface OrganizationService { fun updateMember(params: OrganizationUpdateMemberParams): OrganizationUpdateMemberResponse = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ fun updateMember( params: OrganizationUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -253,7 +253,7 @@ interface OrganizationService { fun create(params: OrganizationCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: OrganizationCreateParams, @@ -268,20 +268,20 @@ interface OrganizationService { fun update(): HttpResponseFor = update(OrganizationUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: OrganizationUpdateParams = OrganizationUpdateParams.none() ): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(requestOptions: RequestOptions): HttpResponseFor = update(OrganizationUpdateParams.none(), requestOptions) @@ -294,20 +294,20 @@ interface OrganizationService { fun list(): HttpResponseFor> = list(OrganizationListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: OrganizationListParams = OrganizationListParams.none() ): HttpResponseFor> = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor> = list(OrganizationListParams.none(), requestOptions) @@ -321,7 +321,7 @@ interface OrganizationService { params: OrganizationDeleteParams ): HttpResponseFor> = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: OrganizationDeleteParams, @@ -337,7 +337,7 @@ interface OrganizationService { params: OrganizationAddMemberParams ): HttpResponseFor = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ @MustBeClosed fun addMember( params: OrganizationAddMemberParams, @@ -354,7 +354,7 @@ interface OrganizationService { ): HttpResponseFor = deleteMember(params, RequestOptions.none()) - /** @see [deleteMember] */ + /** @see deleteMember */ @MustBeClosed fun deleteMember( params: OrganizationDeleteMemberParams, @@ -371,7 +371,7 @@ interface OrganizationService { ): HttpResponseFor = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ @MustBeClosed fun updateMember( params: OrganizationUpdateMemberParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt index 2f3ca7a6..b7b46f69 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -101,7 +101,8 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val info: InfoService.WithRawResponse by lazy { InfoServiceImpl.WithRawResponseImpl(clientOptions) @@ -118,7 +119,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: OrganizationCreateParams, @@ -134,7 +134,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -147,7 +147,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: OrganizationUpdateParams, @@ -163,7 +162,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -176,7 +175,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: OrganizationListParams, @@ -191,7 +189,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -204,7 +202,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val deleteHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: OrganizationDeleteParams, @@ -220,7 +217,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -233,7 +230,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val addMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun addMember( params: OrganizationAddMemberParams, @@ -249,7 +245,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { addMemberHandler.handle(it) } .also { @@ -262,7 +258,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val deleteMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun deleteMember( params: OrganizationDeleteMemberParams, @@ -278,7 +273,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteMemberHandler.handle(it) } .also { @@ -291,7 +286,6 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val updateMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun updateMember( params: OrganizationUpdateMemberParams, @@ -307,7 +301,7 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateMemberHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt index 70bb6708..d60bb514 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt @@ -71,18 +71,18 @@ interface ProviderService { */ fun listBudgets(): ProviderListBudgetsResponse = listBudgets(ProviderListBudgetsParams.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProviderListBudgetsResponse - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none() ): ProviderListBudgetsResponse = listBudgets(params, RequestOptions.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ fun listBudgets(requestOptions: RequestOptions): ProviderListBudgetsResponse = listBudgets(ProviderListBudgetsParams.none(), requestOptions) @@ -104,20 +104,20 @@ interface ProviderService { fun listBudgets(): HttpResponseFor = listBudgets(ProviderListBudgetsParams.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ @MustBeClosed fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [listBudgets] */ + /** @see listBudgets */ @MustBeClosed fun listBudgets( params: ProviderListBudgetsParams = ProviderListBudgetsParams.none() ): HttpResponseFor = listBudgets(params, RequestOptions.none()) - /** @see [listBudgets] */ + /** @see listBudgets */ @MustBeClosed fun listBudgets( requestOptions: RequestOptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt index b9aeace8..2b14538f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -40,7 +40,8 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ProviderService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,6 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client private val listBudgetsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listBudgets( params: ProviderListBudgetsParams, @@ -66,7 +66,7 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listBudgetsHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt index 9bca8589..d37e1fa5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankService.kt @@ -31,53 +31,53 @@ interface RerankService { /** Rerank */ fun create(): RerankCreateResponse = create(RerankCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: RerankCreateParams = RerankCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RerankCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: RerankCreateParams = RerankCreateParams.none()): RerankCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): RerankCreateResponse = create(RerankCreateParams.none(), requestOptions) /** Rerank */ fun createV1(): RerankCreateV1Response = createV1(RerankCreateV1Params.none()) - /** @see [createV1] */ + /** @see createV1 */ fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RerankCreateV1Response - /** @see [createV1] */ + /** @see createV1 */ fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none() ): RerankCreateV1Response = createV1(params, RequestOptions.none()) - /** @see [createV1] */ + /** @see createV1 */ fun createV1(requestOptions: RequestOptions): RerankCreateV1Response = createV1(RerankCreateV1Params.none(), requestOptions) /** Rerank */ fun createV2(): RerankCreateV2Response = createV2(RerankCreateV2Params.none()) - /** @see [createV2] */ + /** @see createV2 */ fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RerankCreateV2Response - /** @see [createV2] */ + /** @see createV2 */ fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none() ): RerankCreateV2Response = createV2(params, RequestOptions.none()) - /** @see [createV2] */ + /** @see createV2 */ fun createV2(requestOptions: RequestOptions): RerankCreateV2Response = createV2(RerankCreateV2Params.none(), requestOptions) @@ -98,20 +98,20 @@ interface RerankService { @MustBeClosed fun create(): HttpResponseFor = create(RerankCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: RerankCreateParams = RerankCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: RerankCreateParams = RerankCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(RerankCreateParams.none(), requestOptions) @@ -124,20 +124,20 @@ interface RerankService { fun createV1(): HttpResponseFor = createV1(RerankCreateV1Params.none()) - /** @see [createV1] */ + /** @see createV1 */ @MustBeClosed fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [createV1] */ + /** @see createV1 */ @MustBeClosed fun createV1( params: RerankCreateV1Params = RerankCreateV1Params.none() ): HttpResponseFor = createV1(params, RequestOptions.none()) - /** @see [createV1] */ + /** @see createV1 */ @MustBeClosed fun createV1(requestOptions: RequestOptions): HttpResponseFor = createV1(RerankCreateV1Params.none(), requestOptions) @@ -150,20 +150,20 @@ interface RerankService { fun createV2(): HttpResponseFor = createV2(RerankCreateV2Params.none()) - /** @see [createV2] */ + /** @see createV2 */ @MustBeClosed fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [createV2] */ + /** @see createV2 */ @MustBeClosed fun createV2( params: RerankCreateV2Params = RerankCreateV2Params.none() ): HttpResponseFor = createV2(params, RequestOptions.none()) - /** @see [createV2] */ + /** @see createV2 */ @MustBeClosed fun createV2(requestOptions: RequestOptions): HttpResponseFor = createV2(RerankCreateV2Params.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt index f029887e..818f4198 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RerankServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -59,7 +59,8 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RerankService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -70,7 +71,6 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: RerankCreateParams, @@ -86,7 +86,7 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -99,7 +99,6 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp private val createV1Handler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createV1( params: RerankCreateV1Params, @@ -115,7 +114,7 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createV1Handler.handle(it) } .also { @@ -128,7 +127,6 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp private val createV2Handler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun createV2( params: RerankCreateV2Params, @@ -144,7 +142,7 @@ class RerankServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createV2Handler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt index a02c1473..a8c60a0a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseService.kt @@ -44,17 +44,17 @@ interface ResponseService { */ fun create(): ResponseCreateResponse = create(ResponseCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ResponseCreateParams = ResponseCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ResponseCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: ResponseCreateParams = ResponseCreateParams.none()): ResponseCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): ResponseCreateResponse = create(ResponseCreateParams.none(), requestOptions) @@ -71,7 +71,7 @@ interface ResponseService { fun retrieve(responseId: String): ResponseRetrieveResponse = retrieve(responseId, ResponseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), @@ -79,23 +79,23 @@ interface ResponseService { ): ResponseRetrieveResponse = retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( responseId: String, params: ResponseRetrieveParams = ResponseRetrieveParams.none(), ): ResponseRetrieveResponse = retrieve(responseId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ResponseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): ResponseRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: ResponseRetrieveParams): ResponseRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(responseId: String, requestOptions: RequestOptions): ResponseRetrieveResponse = retrieve(responseId, ResponseRetrieveParams.none(), requestOptions) @@ -112,7 +112,7 @@ interface ResponseService { fun delete(responseId: String): ResponseDeleteResponse = delete(responseId, ResponseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), @@ -120,23 +120,23 @@ interface ResponseService { ): ResponseDeleteResponse = delete(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( responseId: String, params: ResponseDeleteParams = ResponseDeleteParams.none(), ): ResponseDeleteResponse = delete(responseId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): ResponseDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: ResponseDeleteParams): ResponseDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(responseId: String, requestOptions: RequestOptions): ResponseDeleteResponse = delete(responseId, ResponseDeleteParams.none(), requestOptions) @@ -159,20 +159,20 @@ interface ResponseService { @MustBeClosed fun create(): HttpResponseFor = create(ResponseCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ResponseCreateParams = ResponseCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ResponseCreateParams = ResponseCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(ResponseCreateParams.none(), requestOptions) @@ -185,7 +185,7 @@ interface ResponseService { fun retrieve(responseId: String): HttpResponseFor = retrieve(responseId, ResponseRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( responseId: String, @@ -194,7 +194,7 @@ interface ResponseService { ): HttpResponseFor = retrieve(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( responseId: String, @@ -202,19 +202,19 @@ interface ResponseService { ): HttpResponseFor = retrieve(responseId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: ResponseRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: ResponseRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( responseId: String, @@ -230,7 +230,7 @@ interface ResponseService { fun delete(responseId: String): HttpResponseFor = delete(responseId, ResponseDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( responseId: String, @@ -239,7 +239,7 @@ interface ResponseService { ): HttpResponseFor = delete(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( responseId: String, @@ -247,19 +247,19 @@ interface ResponseService { ): HttpResponseFor = delete(responseId, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: ResponseDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: ResponseDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( responseId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt index d28e35fd..9d916309 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ResponseServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -67,7 +67,8 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ResponseService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val inputItems: InputItemService.WithRawResponse by lazy { InputItemServiceImpl.WithRawResponseImpl(clientOptions) @@ -84,7 +85,6 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ResponseCreateParams, @@ -100,7 +100,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -113,7 +113,6 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ResponseRetrieveParams, @@ -131,7 +130,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -144,7 +143,6 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: ResponseDeleteParams, @@ -163,7 +161,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt index d21319b5..9ece4f3a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteService.kt @@ -27,17 +27,17 @@ interface RouteService { /** Get a list of available routes in the FastAPI application. */ fun list(): RouteListResponse = list(RouteListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: RouteListParams = RouteListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RouteListResponse - /** @see [list] */ + /** @see list */ fun list(params: RouteListParams = RouteListParams.none()): RouteListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): RouteListResponse = list(RouteListParams.none(), requestOptions) @@ -57,20 +57,20 @@ interface RouteService { */ @MustBeClosed fun list(): HttpResponseFor = list(RouteListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: RouteListParams = RouteListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: RouteListParams = RouteListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(RouteListParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt index c05b2393..4b8c8ce9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/RouteServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -37,7 +37,8 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RouteService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -47,7 +48,7 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt ) private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: RouteListParams, @@ -62,7 +63,7 @@ class RouteServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt index ee1987ea..ecf4f66f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingService.kt @@ -49,18 +49,18 @@ interface SettingService { */ fun retrieve(): SettingRetrieveResponse = retrieve(SettingRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): SettingRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none() ): SettingRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(requestOptions: RequestOptions): SettingRetrieveResponse = retrieve(SettingRetrieveParams.none(), requestOptions) @@ -82,20 +82,20 @@ interface SettingService { fun retrieve(): HttpResponseFor = retrieve(SettingRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: SettingRetrieveParams = SettingRetrieveParams.none() ): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(requestOptions: RequestOptions): HttpResponseFor = retrieve(SettingRetrieveParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt index c6ff0c6f..5928d6ef 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SettingServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -40,7 +40,8 @@ class SettingServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SettingService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -51,7 +52,6 @@ class SettingServiceImpl internal constructor(private val clientOptions: ClientO private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: SettingRetrieveParams, @@ -66,7 +66,7 @@ class SettingServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt index 911be7c5..50325e7f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendService.kt @@ -79,18 +79,18 @@ interface SpendService { fun calculateSpend(): SpendCalculateSpendResponse = calculateSpend(SpendCalculateSpendParams.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): SpendCalculateSpendResponse - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none() ): SpendCalculateSpendResponse = calculateSpend(params, RequestOptions.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ fun calculateSpend(requestOptions: RequestOptions): SpendCalculateSpendResponse = calculateSpend(SpendCalculateSpendParams.none(), requestOptions) @@ -124,18 +124,18 @@ interface SpendService { */ fun listLogs(): List = listLogs(SpendListLogsParams.none()) - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): List - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none() ): List = listLogs(params, RequestOptions.none()) - /** @see [listLogs] */ + /** @see listLogs */ fun listLogs(requestOptions: RequestOptions): List = listLogs(SpendListLogsParams.none(), requestOptions) @@ -155,18 +155,18 @@ interface SpendService { */ fun listTags(): List = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): List - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): List = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags(requestOptions: RequestOptions): List = listTags(SpendListTagsParams.none(), requestOptions) @@ -188,21 +188,21 @@ interface SpendService { fun calculateSpend(): HttpResponseFor = calculateSpend(SpendCalculateSpendParams.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ @MustBeClosed fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [calculateSpend] */ + /** @see calculateSpend */ @MustBeClosed fun calculateSpend( params: SpendCalculateSpendParams = SpendCalculateSpendParams.none() ): HttpResponseFor = calculateSpend(params, RequestOptions.none()) - /** @see [calculateSpend] */ + /** @see calculateSpend */ @MustBeClosed fun calculateSpend( requestOptions: RequestOptions @@ -217,20 +217,20 @@ interface SpendService { fun listLogs(): HttpResponseFor> = listLogs(SpendListLogsParams.none()) - /** @see [listLogs] */ + /** @see listLogs */ @MustBeClosed fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [listLogs] */ + /** @see listLogs */ @MustBeClosed fun listLogs( params: SpendListLogsParams = SpendListLogsParams.none() ): HttpResponseFor> = listLogs(params, RequestOptions.none()) - /** @see [listLogs] */ + /** @see listLogs */ @MustBeClosed fun listLogs(requestOptions: RequestOptions): HttpResponseFor> = listLogs(SpendListLogsParams.none(), requestOptions) @@ -243,20 +243,20 @@ interface SpendService { fun listTags(): HttpResponseFor> = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [listTags] */ + /** @see listTags */ @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): HttpResponseFor> = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ @MustBeClosed fun listTags(requestOptions: RequestOptions): HttpResponseFor> = listTags(SpendListTagsParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt index 0b5fa6e7..7e7992af 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/SpendServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -59,7 +59,8 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SpendService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -70,7 +71,6 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val calculateSpendHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun calculateSpend( params: SpendCalculateSpendParams, @@ -86,7 +86,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { calculateSpendHandler.handle(it) } .also { @@ -99,7 +99,6 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val listLogsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listLogs( params: SpendListLogsParams, @@ -114,7 +113,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listLogsHandler.handle(it) } .also { @@ -127,7 +126,6 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val listTagsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listTags( params: SpendListTagsParams, @@ -142,7 +140,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listTagsHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt index 44f60e51..a5d37b88 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt @@ -113,17 +113,17 @@ interface TeamService { */ fun create(): TeamCreateResponse = create(TeamCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: TeamCreateParams = TeamCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): TeamCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: TeamCreateParams = TeamCreateParams.none()): TeamCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): TeamCreateResponse = create(TeamCreateParams.none(), requestOptions) @@ -177,7 +177,7 @@ interface TeamService { */ fun update(params: TeamUpdateParams): TeamUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: TeamUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -195,17 +195,17 @@ interface TeamService { */ fun list(): TeamListResponse = list(TeamListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: TeamListParams = TeamListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): TeamListResponse - /** @see [list] */ + /** @see list */ fun list(params: TeamListParams = TeamListParams.none()): TeamListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): TeamListResponse = list(TeamListParams.none(), requestOptions) @@ -224,7 +224,7 @@ interface TeamService { */ fun delete(params: TeamDeleteParams): TeamDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: TeamDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -248,7 +248,7 @@ interface TeamService { fun addMember(params: TeamAddMemberParams): TeamAddMemberResponse = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ fun addMember( params: TeamAddMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -272,7 +272,7 @@ interface TeamService { */ fun block(params: TeamBlockParams): TeamBlockResponse = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ fun block( params: TeamBlockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -292,7 +292,7 @@ interface TeamService { fun disableLogging(teamId: String): TeamDisableLoggingResponse = disableLogging(teamId, TeamDisableLoggingParams.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), @@ -300,41 +300,41 @@ interface TeamService { ): TeamDisableLoggingResponse = disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( teamId: String, params: TeamDisableLoggingParams = TeamDisableLoggingParams.none(), ): TeamDisableLoggingResponse = disableLogging(teamId, params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging( params: TeamDisableLoggingParams, requestOptions: RequestOptions = RequestOptions.none(), ): TeamDisableLoggingResponse - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging(params: TeamDisableLoggingParams): TeamDisableLoggingResponse = disableLogging(params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ fun disableLogging(teamId: String, requestOptions: RequestOptions): TeamDisableLoggingResponse = disableLogging(teamId, TeamDisableLoggingParams.none(), requestOptions) /** List Available Teams */ fun listAvailable(): TeamListAvailableResponse = listAvailable(TeamListAvailableParams.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): TeamListAvailableResponse - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none() ): TeamListAvailableResponse = listAvailable(params, RequestOptions.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ fun listAvailable(requestOptions: RequestOptions): TeamListAvailableResponse = listAvailable(TeamListAvailableParams.none(), requestOptions) @@ -358,7 +358,7 @@ interface TeamService { fun removeMember(params: TeamRemoveMemberParams): TeamRemoveMemberResponse = removeMember(params, RequestOptions.none()) - /** @see [removeMember] */ + /** @see removeMember */ fun removeMember( params: TeamRemoveMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -376,18 +376,18 @@ interface TeamService { */ fun retrieveInfo(): TeamRetrieveInfoResponse = retrieveInfo(TeamRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): TeamRetrieveInfoResponse - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none() ): TeamRetrieveInfoResponse = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): TeamRetrieveInfoResponse = retrieveInfo(TeamRetrieveInfoParams.none(), requestOptions) @@ -407,7 +407,7 @@ interface TeamService { fun unblock(params: TeamUnblockParams): TeamUnblockResponse = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ fun unblock( params: TeamUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -421,7 +421,7 @@ interface TeamService { fun updateMember(params: TeamUpdateMemberParams): TeamUpdateMemberResponse = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ fun updateMember( params: TeamUpdateMemberParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -448,20 +448,20 @@ interface TeamService { @MustBeClosed fun create(): HttpResponseFor = create(TeamCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: TeamCreateParams = TeamCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: TeamCreateParams = TeamCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(TeamCreateParams.none(), requestOptions) @@ -474,7 +474,7 @@ interface TeamService { fun update(params: TeamUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: TeamUpdateParams, @@ -487,20 +487,20 @@ interface TeamService { */ @MustBeClosed fun list(): HttpResponseFor = list(TeamListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: TeamListParams = TeamListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: TeamListParams = TeamListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(TeamListParams.none(), requestOptions) @@ -513,7 +513,7 @@ interface TeamService { fun delete(params: TeamDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: TeamDeleteParams, @@ -528,7 +528,7 @@ interface TeamService { fun addMember(params: TeamAddMemberParams): HttpResponseFor = addMember(params, RequestOptions.none()) - /** @see [addMember] */ + /** @see addMember */ @MustBeClosed fun addMember( params: TeamAddMemberParams, @@ -543,7 +543,7 @@ interface TeamService { fun block(params: TeamBlockParams): HttpResponseFor = block(params, RequestOptions.none()) - /** @see [block] */ + /** @see block */ @MustBeClosed fun block( params: TeamBlockParams, @@ -558,7 +558,7 @@ interface TeamService { fun disableLogging(teamId: String): HttpResponseFor = disableLogging(teamId, TeamDisableLoggingParams.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ @MustBeClosed fun disableLogging( teamId: String, @@ -567,7 +567,7 @@ interface TeamService { ): HttpResponseFor = disableLogging(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [disableLogging] */ + /** @see disableLogging */ @MustBeClosed fun disableLogging( teamId: String, @@ -575,21 +575,21 @@ interface TeamService { ): HttpResponseFor = disableLogging(teamId, params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ @MustBeClosed fun disableLogging( params: TeamDisableLoggingParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [disableLogging] */ + /** @see disableLogging */ @MustBeClosed fun disableLogging( params: TeamDisableLoggingParams ): HttpResponseFor = disableLogging(params, RequestOptions.none()) - /** @see [disableLogging] */ + /** @see disableLogging */ @MustBeClosed fun disableLogging( teamId: String, @@ -605,20 +605,20 @@ interface TeamService { fun listAvailable(): HttpResponseFor = listAvailable(TeamListAvailableParams.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ @MustBeClosed fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [listAvailable] */ + /** @see listAvailable */ @MustBeClosed fun listAvailable( params: TeamListAvailableParams = TeamListAvailableParams.none() ): HttpResponseFor = listAvailable(params, RequestOptions.none()) - /** @see [listAvailable] */ + /** @see listAvailable */ @MustBeClosed fun listAvailable( requestOptions: RequestOptions @@ -634,7 +634,7 @@ interface TeamService { params: TeamRemoveMemberParams ): HttpResponseFor = removeMember(params, RequestOptions.none()) - /** @see [removeMember] */ + /** @see removeMember */ @MustBeClosed fun removeMember( params: TeamRemoveMemberParams, @@ -649,20 +649,20 @@ interface TeamService { fun retrieveInfo(): HttpResponseFor = retrieveInfo(TeamRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: TeamRetrieveInfoParams = TeamRetrieveInfoParams.none() ): HttpResponseFor = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions @@ -677,7 +677,7 @@ interface TeamService { fun unblock(params: TeamUnblockParams): HttpResponseFor = unblock(params, RequestOptions.none()) - /** @see [unblock] */ + /** @see unblock */ @MustBeClosed fun unblock( params: TeamUnblockParams, @@ -693,7 +693,7 @@ interface TeamService { params: TeamUpdateMemberParams ): HttpResponseFor = updateMember(params, RequestOptions.none()) - /** @see [updateMember] */ + /** @see updateMember */ @MustBeClosed fun updateMember( params: TeamUpdateMemberParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt index ae97643f..1be8736a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -147,7 +147,8 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TeamService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val model: ModelService.WithRawResponse by lazy { ModelServiceImpl.WithRawResponseImpl(clientOptions) @@ -169,7 +170,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti override fun callback(): CallbackService.WithRawResponse = callback private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: TeamCreateParams, @@ -185,7 +186,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -197,7 +198,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: TeamUpdateParams, @@ -213,7 +214,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -225,7 +226,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: TeamListParams, @@ -240,7 +241,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -252,7 +253,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: TeamDeleteParams, @@ -268,7 +269,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -281,7 +282,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val addMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun addMember( params: TeamAddMemberParams, @@ -297,7 +297,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { addMemberHandler.handle(it) } .also { @@ -309,7 +309,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti } private val blockHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun block( params: TeamBlockParams, @@ -325,7 +325,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { blockHandler.handle(it) } .also { @@ -338,7 +338,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val disableLoggingHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun disableLogging( params: TeamDisableLoggingParams, @@ -357,7 +356,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { disableLoggingHandler.handle(it) } .also { @@ -370,7 +369,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val listAvailableHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listAvailable( params: TeamListAvailableParams, @@ -385,7 +383,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listAvailableHandler.handle(it) } .also { @@ -398,7 +396,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val removeMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun removeMember( params: TeamRemoveMemberParams, @@ -414,7 +411,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { removeMemberHandler.handle(it) } .also { @@ -427,7 +424,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: TeamRetrieveInfoParams, @@ -442,7 +438,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { @@ -455,7 +451,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val unblockHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun unblock( params: TeamUnblockParams, @@ -471,7 +466,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { unblockHandler.handle(it) } .also { @@ -484,7 +479,6 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti private val updateMemberHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun updateMember( params: TeamUpdateMemberParams, @@ -500,7 +494,7 @@ class TeamServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateMemberHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt index e20da335..07d16673 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestService.kt @@ -35,17 +35,17 @@ interface TestService { */ fun ping(): TestPingResponse = ping(TestPingParams.none()) - /** @see [ping] */ + /** @see ping */ fun ping( params: TestPingParams = TestPingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): TestPingResponse - /** @see [ping] */ + /** @see ping */ fun ping(params: TestPingParams = TestPingParams.none()): TestPingResponse = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ fun ping(requestOptions: RequestOptions): TestPingResponse = ping(TestPingParams.none(), requestOptions) @@ -65,20 +65,20 @@ interface TestService { */ @MustBeClosed fun ping(): HttpResponseFor = ping(TestPingParams.none()) - /** @see [ping] */ + /** @see ping */ @MustBeClosed fun ping( params: TestPingParams = TestPingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [ping] */ + /** @see ping */ @MustBeClosed fun ping( params: TestPingParams = TestPingParams.none() ): HttpResponseFor = ping(params, RequestOptions.none()) - /** @see [ping] */ + /** @see ping */ @MustBeClosed fun ping(requestOptions: RequestOptions): HttpResponseFor = ping(TestPingParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt index ecde0ed1..0acf6a96 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TestServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -36,7 +36,8 @@ class TestServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TestService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -46,7 +47,7 @@ class TestServiceImpl internal constructor(private val clientOptions: ClientOpti ) private val pingHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun ping( params: TestPingParams, @@ -61,7 +62,7 @@ class TestServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { pingHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt index e93300d5..49ae8eb6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadService.kt @@ -39,17 +39,17 @@ interface ThreadService { */ fun create(): ThreadCreateResponse = create(ThreadCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: ThreadCreateParams = ThreadCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ThreadCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: ThreadCreateParams = ThreadCreateParams.none()): ThreadCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): ThreadCreateResponse = create(ThreadCreateParams.none(), requestOptions) @@ -61,7 +61,7 @@ interface ThreadService { fun retrieve(threadId: String): ThreadRetrieveResponse = retrieve(threadId, ThreadRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), @@ -69,23 +69,23 @@ interface ThreadService { ): ThreadRetrieveResponse = retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( threadId: String, params: ThreadRetrieveParams = ThreadRetrieveParams.none(), ): ThreadRetrieveResponse = retrieve(threadId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): ThreadRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: ThreadRetrieveParams): ThreadRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(threadId: String, requestOptions: RequestOptions): ThreadRetrieveResponse = retrieve(threadId, ThreadRetrieveParams.none(), requestOptions) @@ -110,20 +110,20 @@ interface ThreadService { @MustBeClosed fun create(): HttpResponseFor = create(ThreadCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ThreadCreateParams = ThreadCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: ThreadCreateParams = ThreadCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(ThreadCreateParams.none(), requestOptions) @@ -136,7 +136,7 @@ interface ThreadService { fun retrieve(threadId: String): HttpResponseFor = retrieve(threadId, ThreadRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( threadId: String, @@ -145,7 +145,7 @@ interface ThreadService { ): HttpResponseFor = retrieve(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( threadId: String, @@ -153,19 +153,19 @@ interface ThreadService { ): HttpResponseFor = retrieve(threadId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: ThreadRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: ThreadRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( threadId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt index c79265da..6208175e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ThreadServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -64,7 +64,8 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ThreadService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val messages: MessageService.WithRawResponse by lazy { MessageServiceImpl.WithRawResponseImpl(clientOptions) @@ -87,7 +88,6 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: ThreadCreateParams, @@ -103,7 +103,7 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -116,7 +116,6 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ThreadRetrieveParams, @@ -134,7 +133,7 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt index 86b05648..0a6077a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt @@ -108,17 +108,17 @@ interface UserService { */ fun create(): UserCreateResponse = create(UserCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: UserCreateParams = UserCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): UserCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: UserCreateParams = UserCreateParams.none()): UserCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): UserCreateResponse = create(UserCreateParams.none(), requestOptions) @@ -174,17 +174,17 @@ interface UserService { */ fun update(): UserUpdateResponse = update(UserUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( params: UserUpdateParams = UserUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): UserUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: UserUpdateParams = UserUpdateParams.none()): UserUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(requestOptions: RequestOptions): UserUpdateResponse = update(UserUpdateParams.none(), requestOptions) @@ -207,17 +207,17 @@ interface UserService { */ fun list(): UserListResponse = list(UserListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): UserListResponse - /** @see [list] */ + /** @see list */ fun list(params: UserListParams = UserListParams.none()): UserListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): UserListResponse = list(UserListParams.none(), requestOptions) @@ -238,7 +238,7 @@ interface UserService { */ fun delete(params: UserDeleteParams): UserDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: UserDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -257,18 +257,18 @@ interface UserService { */ fun retrieveInfo(): UserRetrieveInfoResponse = retrieveInfo(UserRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): UserRetrieveInfoResponse - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none() ): UserRetrieveInfoResponse = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): UserRetrieveInfoResponse = retrieveInfo(UserRetrieveInfoParams.none(), requestOptions) @@ -289,20 +289,20 @@ interface UserService { @MustBeClosed fun create(): HttpResponseFor = create(UserCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: UserCreateParams = UserCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: UserCreateParams = UserCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(UserCreateParams.none(), requestOptions) @@ -314,20 +314,20 @@ interface UserService { @MustBeClosed fun update(): HttpResponseFor = update(UserUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: UserUpdateParams = UserUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: UserUpdateParams = UserUpdateParams.none() ): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(requestOptions: RequestOptions): HttpResponseFor = update(UserUpdateParams.none(), requestOptions) @@ -338,20 +338,20 @@ interface UserService { */ @MustBeClosed fun list(): HttpResponseFor = list(UserListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: UserListParams = UserListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(UserListParams.none(), requestOptions) @@ -364,7 +364,7 @@ interface UserService { fun delete(params: UserDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: UserDeleteParams, @@ -379,20 +379,20 @@ interface UserService { fun retrieveInfo(): HttpResponseFor = retrieveInfo(UserRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: UserRetrieveInfoParams = UserRetrieveInfoParams.none() ): HttpResponseFor = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt index c324d5ff..e2d18dc7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -73,7 +73,8 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UserService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -83,7 +84,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: UserCreateParams, @@ -99,7 +100,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -111,7 +112,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun update( params: UserUpdateParams, @@ -127,7 +128,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -139,7 +140,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: UserListParams, @@ -154,7 +155,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -166,7 +167,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun delete( params: UserDeleteParams, @@ -182,7 +183,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -195,7 +196,6 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: UserRetrieveInfoParams, @@ -210,7 +210,7 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt index 40ad3d72..3482d8d3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilService.kt @@ -43,7 +43,7 @@ interface UtilService { ): UtilGetSupportedOpenAIParamsResponse = getSupportedOpenAIParams(params, RequestOptions.none()) - /** @see [getSupportedOpenAIParams] */ + /** @see getSupportedOpenAIParams */ fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -53,7 +53,7 @@ interface UtilService { fun tokenCounter(params: UtilTokenCounterParams): UtilTokenCounterResponse = tokenCounter(params, RequestOptions.none()) - /** @see [tokenCounter] */ + /** @see tokenCounter */ fun tokenCounter( params: UtilTokenCounterParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -63,7 +63,7 @@ interface UtilService { fun transformRequest(params: UtilTransformRequestParams): UtilTransformRequestResponse = transformRequest(params, RequestOptions.none()) - /** @see [transformRequest] */ + /** @see transformRequest */ fun transformRequest( params: UtilTransformRequestParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -89,7 +89,7 @@ interface UtilService { ): HttpResponseFor = getSupportedOpenAIParams(params, RequestOptions.none()) - /** @see [getSupportedOpenAIParams] */ + /** @see getSupportedOpenAIParams */ @MustBeClosed fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, @@ -105,7 +105,7 @@ interface UtilService { params: UtilTokenCounterParams ): HttpResponseFor = tokenCounter(params, RequestOptions.none()) - /** @see [tokenCounter] */ + /** @see tokenCounter */ @MustBeClosed fun tokenCounter( params: UtilTokenCounterParams, @@ -122,7 +122,7 @@ interface UtilService { ): HttpResponseFor = transformRequest(params, RequestOptions.none()) - /** @see [transformRequest] */ + /** @see transformRequest */ @MustBeClosed fun transformRequest( params: UtilTransformRequestParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt index 5841e564..1db1e065 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UtilServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -58,7 +58,8 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UtilService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -69,7 +70,6 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti private val getSupportedOpenAIParamsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun getSupportedOpenAIParams( params: UtilGetSupportedOpenAIParamsParams, @@ -84,7 +84,7 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { getSupportedOpenAIParamsHandler.handle(it) } .also { @@ -97,7 +97,6 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti private val tokenCounterHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun tokenCounter( params: UtilTokenCounterParams, @@ -113,7 +112,7 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { tokenCounterHandler.handle(it) } .also { @@ -126,7 +125,6 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti private val transformRequestHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun transformRequest( params: UtilTransformRequestParams, @@ -142,7 +140,7 @@ class UtilServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { transformRequestHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt index 22663562..9c65ad32 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiService.kt @@ -40,7 +40,7 @@ interface VertexAiService { fun create(endpoint: String): VertexAiCreateResponse = create(endpoint, VertexAiCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), @@ -48,23 +48,23 @@ interface VertexAiService { ): VertexAiCreateResponse = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), ): VertexAiCreateResponse = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: VertexAiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: VertexAiCreateParams): VertexAiCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(endpoint: String, requestOptions: RequestOptions): VertexAiCreateResponse = create(endpoint, VertexAiCreateParams.none(), requestOptions) @@ -76,7 +76,7 @@ interface VertexAiService { fun retrieve(endpoint: String): VertexAiRetrieveResponse = retrieve(endpoint, VertexAiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), @@ -84,23 +84,23 @@ interface VertexAiService { ): VertexAiRetrieveResponse = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( endpoint: String, params: VertexAiRetrieveParams = VertexAiRetrieveParams.none(), ): VertexAiRetrieveResponse = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: VertexAiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: VertexAiRetrieveParams): VertexAiRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(endpoint: String, requestOptions: RequestOptions): VertexAiRetrieveResponse = retrieve(endpoint, VertexAiRetrieveParams.none(), requestOptions) @@ -112,7 +112,7 @@ interface VertexAiService { fun update(endpoint: String): VertexAiUpdateResponse = update(endpoint, VertexAiUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), @@ -120,23 +120,23 @@ interface VertexAiService { ): VertexAiUpdateResponse = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), ): VertexAiUpdateResponse = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: VertexAiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: VertexAiUpdateParams): VertexAiUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update(endpoint: String, requestOptions: RequestOptions): VertexAiUpdateResponse = update(endpoint, VertexAiUpdateParams.none(), requestOptions) @@ -148,7 +148,7 @@ interface VertexAiService { fun delete(endpoint: String): VertexAiDeleteResponse = delete(endpoint, VertexAiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), @@ -156,23 +156,23 @@ interface VertexAiService { ): VertexAiDeleteResponse = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), ): VertexAiDeleteResponse = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: VertexAiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiDeleteResponse - /** @see [delete] */ + /** @see delete */ fun delete(params: VertexAiDeleteParams): VertexAiDeleteResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete(endpoint: String, requestOptions: RequestOptions): VertexAiDeleteResponse = delete(endpoint, VertexAiDeleteParams.none(), requestOptions) @@ -183,30 +183,30 @@ interface VertexAiService { */ fun patch(endpoint: String): VertexAiPatchResponse = patch(endpoint, VertexAiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiPatchResponse = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), ): VertexAiPatchResponse = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch( params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): VertexAiPatchResponse - /** @see [patch] */ + /** @see patch */ fun patch(params: VertexAiPatchParams): VertexAiPatchResponse = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ fun patch(endpoint: String, requestOptions: RequestOptions): VertexAiPatchResponse = patch(endpoint, VertexAiPatchParams.none(), requestOptions) @@ -228,7 +228,7 @@ interface VertexAiService { fun create(endpoint: String): HttpResponseFor = create(endpoint, VertexAiCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -237,26 +237,26 @@ interface VertexAiService { ): HttpResponseFor = create(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, params: VertexAiCreateParams = VertexAiCreateParams.none(), ): HttpResponseFor = create(endpoint, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: VertexAiCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: VertexAiCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( endpoint: String, @@ -272,7 +272,7 @@ interface VertexAiService { fun retrieve(endpoint: String): HttpResponseFor = retrieve(endpoint, VertexAiRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -281,7 +281,7 @@ interface VertexAiService { ): HttpResponseFor = retrieve(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -289,19 +289,19 @@ interface VertexAiService { ): HttpResponseFor = retrieve(endpoint, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: VertexAiRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: VertexAiRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( endpoint: String, @@ -317,7 +317,7 @@ interface VertexAiService { fun update(endpoint: String): HttpResponseFor = update(endpoint, VertexAiUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -326,26 +326,26 @@ interface VertexAiService { ): HttpResponseFor = update(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, params: VertexAiUpdateParams = VertexAiUpdateParams.none(), ): HttpResponseFor = update(endpoint, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: VertexAiUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update(params: VertexAiUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpoint: String, @@ -361,7 +361,7 @@ interface VertexAiService { fun delete(endpoint: String): HttpResponseFor = delete(endpoint, VertexAiDeleteParams.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -370,26 +370,26 @@ interface VertexAiService { ): HttpResponseFor = delete(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, params: VertexAiDeleteParams = VertexAiDeleteParams.none(), ): HttpResponseFor = delete(endpoint, params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: VertexAiDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete(params: VertexAiDeleteParams): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( endpoint: String, @@ -405,7 +405,7 @@ interface VertexAiService { fun patch(endpoint: String): HttpResponseFor = patch(endpoint, VertexAiPatchParams.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, @@ -414,26 +414,26 @@ interface VertexAiService { ): HttpResponseFor = patch(params.toBuilder().endpoint(endpoint).build(), requestOptions) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, params: VertexAiPatchParams = VertexAiPatchParams.none(), ): HttpResponseFor = patch(endpoint, params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( params: VertexAiPatchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch(params: VertexAiPatchParams): HttpResponseFor = patch(params, RequestOptions.none()) - /** @see [patch] */ + /** @see patch */ @MustBeClosed fun patch( endpoint: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt index 7c4fc474..7c45d90b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -79,7 +79,8 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : VertexAiService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -90,7 +91,6 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: VertexAiCreateParams, @@ -109,7 +109,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -122,7 +122,6 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: VertexAiRetrieveParams, @@ -140,7 +139,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -153,7 +152,6 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: VertexAiUpdateParams, @@ -172,7 +170,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -185,7 +183,6 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: VertexAiDeleteParams, @@ -204,7 +201,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { @@ -217,7 +214,6 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client private val patchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun patch( params: VertexAiPatchParams, @@ -236,7 +232,7 @@ class VertexAiServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { patchHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt index fdcfcd32..dd4eefa0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechService.kt @@ -31,17 +31,17 @@ interface SpeechService { */ fun create(): SpeechCreateResponse = create(SpeechCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: SpeechCreateParams = SpeechCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): SpeechCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: SpeechCreateParams = SpeechCreateParams.none()): SpeechCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): SpeechCreateResponse = create(SpeechCreateParams.none(), requestOptions) @@ -62,20 +62,20 @@ interface SpeechService { @MustBeClosed fun create(): HttpResponseFor = create(SpeechCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: SpeechCreateParams = SpeechCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: SpeechCreateParams = SpeechCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(SpeechCreateParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt index bb990a33..0257ccb6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.audio import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SpeechService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: SpeechCreateParams, @@ -68,7 +68,7 @@ class SpeechServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt index 8972f093..9136ac98 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionService.kt @@ -32,7 +32,7 @@ interface TranscriptionService { fun create(params: TranscriptionCreateParams): TranscriptionCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: TranscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -61,7 +61,7 @@ interface TranscriptionService { params: TranscriptionCreateParams ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: TranscriptionCreateParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt index b76669e7..eceebf20 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.audio import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.multipartFormData @@ -41,7 +41,8 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TranscriptionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: TranscriptionCreateParams, @@ -68,7 +68,7 @@ class TranscriptionServiceImpl internal constructor(private val clientOptions: C .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt index ce4a1fe5..ff67b69b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelService.kt @@ -39,30 +39,30 @@ interface CancelService { */ fun cancel(batchId: String): CancelCancelResponse = cancel(batchId, CancelCancelParams.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CancelCancelResponse = cancel(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancel] */ + /** @see cancel */ fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), ): CancelCancelResponse = cancel(batchId, params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel( params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): CancelCancelResponse - /** @see [cancel] */ + /** @see cancel */ fun cancel(params: CancelCancelParams): CancelCancelResponse = cancel(params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ fun cancel(batchId: String, requestOptions: RequestOptions): CancelCancelResponse = cancel(batchId, CancelCancelParams.none(), requestOptions) @@ -84,7 +84,7 @@ interface CancelService { fun cancel(batchId: String): HttpResponseFor = cancel(batchId, CancelCancelParams.none()) - /** @see [cancel] */ + /** @see cancel */ @MustBeClosed fun cancel( batchId: String, @@ -93,26 +93,26 @@ interface CancelService { ): HttpResponseFor = cancel(params.toBuilder().batchId(batchId).build(), requestOptions) - /** @see [cancel] */ + /** @see cancel */ @MustBeClosed fun cancel( batchId: String, params: CancelCancelParams = CancelCancelParams.none(), ): HttpResponseFor = cancel(batchId, params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ @MustBeClosed fun cancel( params: CancelCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [cancel] */ + /** @see cancel */ @MustBeClosed fun cancel(params: CancelCancelParams): HttpResponseFor = cancel(params, RequestOptions.none()) - /** @see [cancel] */ + /** @see cancel */ @MustBeClosed fun cancel( batchId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt index 34cac9ab..50bae164 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.batches import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -43,7 +43,8 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CancelService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp private val cancelHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun cancel( params: CancelCancelParams, @@ -73,7 +73,7 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { cancelHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt index 7a530f93..70536e43 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediService.kt @@ -27,18 +27,18 @@ interface RediService { /** Endpoint for getting /redis/info */ fun retrieveInfo(): RediRetrieveInfoResponse = retrieveInfo(RediRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RediRetrieveInfoResponse - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none() ): RediRetrieveInfoResponse = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ fun retrieveInfo(requestOptions: RequestOptions): RediRetrieveInfoResponse = retrieveInfo(RediRetrieveInfoParams.none(), requestOptions) @@ -60,20 +60,20 @@ interface RediService { fun retrieveInfo(): HttpResponseFor = retrieveInfo(RediRetrieveInfoParams.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( params: RediRetrieveInfoParams = RediRetrieveInfoParams.none() ): HttpResponseFor = retrieveInfo(params, RequestOptions.none()) - /** @see [retrieveInfo] */ + /** @see retrieveInfo */ @MustBeClosed fun retrieveInfo( requestOptions: RequestOptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt index c0537ce0..f951f102 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.cache import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -39,7 +39,8 @@ class RediServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RediService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -50,7 +51,6 @@ class RediServiceImpl internal constructor(private val clientOptions: ClientOpti private val retrieveInfoHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveInfo( params: RediRetrieveInfoParams, @@ -65,7 +65,7 @@ class RediServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveInfoHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt index bbdaf223..677f2688 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionService.kt @@ -45,18 +45,18 @@ interface CompletionService { */ fun create(): CompletionCreateResponse = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletionCreateResponse - /** @see [create] */ + /** @see create */ fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): CompletionCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): CompletionCreateResponse = create(CompletionCreateParams.none(), requestOptions) @@ -80,20 +80,20 @@ interface CompletionService { fun create(): HttpResponseFor = create(CompletionCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CompletionCreateParams = CompletionCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(CompletionCreateParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt index 19fd27a3..9cb2a6bf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.chat import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CompletionService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CompletionCreateParams, @@ -68,7 +68,7 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt index 6a33d646..15c42ddf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt @@ -33,7 +33,7 @@ interface PassThroughEndpointService { fun create(params: PassThroughEndpointCreateParams): PassThroughEndpointCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: PassThroughEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -43,7 +43,7 @@ interface PassThroughEndpointService { fun update(endpointId: String): PassThroughEndpointUpdateResponse = update(endpointId, PassThroughEndpointUpdateParams.none()) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), @@ -51,23 +51,23 @@ interface PassThroughEndpointService { ): PassThroughEndpointUpdateResponse = update(params.toBuilder().endpointId(endpointId).build(), requestOptions) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, params: PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams.none(), ): PassThroughEndpointUpdateResponse = update(endpointId, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): PassThroughEndpointUpdateResponse - /** @see [update] */ + /** @see update */ fun update(params: PassThroughEndpointUpdateParams): PassThroughEndpointUpdateResponse = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ fun update( endpointId: String, requestOptions: RequestOptions, @@ -81,18 +81,18 @@ interface PassThroughEndpointService { */ fun list(): PassThroughEndpointResponse = list(PassThroughEndpointListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): PassThroughEndpointResponse - /** @see [list] */ + /** @see list */ fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none() ): PassThroughEndpointResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): PassThroughEndpointResponse = list(PassThroughEndpointListParams.none(), requestOptions) @@ -104,7 +104,7 @@ interface PassThroughEndpointService { fun delete(params: PassThroughEndpointDeleteParams): PassThroughEndpointResponse = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ fun delete( params: PassThroughEndpointDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -135,7 +135,7 @@ interface PassThroughEndpointService { ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: PassThroughEndpointCreateParams, @@ -150,7 +150,7 @@ interface PassThroughEndpointService { fun update(endpointId: String): HttpResponseFor = update(endpointId, PassThroughEndpointUpdateParams.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpointId: String, @@ -159,7 +159,7 @@ interface PassThroughEndpointService { ): HttpResponseFor = update(params.toBuilder().endpointId(endpointId).build(), requestOptions) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpointId: String, @@ -167,21 +167,21 @@ interface PassThroughEndpointService { ): HttpResponseFor = update(endpointId, params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: PassThroughEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( params: PassThroughEndpointUpdateParams ): HttpResponseFor = update(params, RequestOptions.none()) - /** @see [update] */ + /** @see update */ @MustBeClosed fun update( endpointId: String, @@ -197,20 +197,20 @@ interface PassThroughEndpointService { fun list(): HttpResponseFor = list(PassThroughEndpointListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: PassThroughEndpointListParams = PassThroughEndpointListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(PassThroughEndpointListParams.none(), requestOptions) @@ -224,7 +224,7 @@ interface PassThroughEndpointService { params: PassThroughEndpointDeleteParams ): HttpResponseFor = delete(params, RequestOptions.none()) - /** @see [delete] */ + /** @see delete */ @MustBeClosed fun delete( params: PassThroughEndpointDeleteParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt index ac263f5b..5110aa0e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.config import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -71,7 +71,8 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PassThroughEndpointService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -82,7 +83,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: PassThroughEndpointCreateParams, @@ -98,7 +98,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -111,7 +111,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun update( params: PassThroughEndpointUpdateParams, @@ -130,7 +129,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { updateHandler.handle(it) } .also { @@ -143,7 +142,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: PassThroughEndpointListParams, @@ -158,7 +156,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { @@ -171,7 +169,6 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun delete( params: PassThroughEndpointDeleteParams, @@ -187,7 +184,7 @@ internal constructor(private val clientOptions: ClientOptions) : PassThroughEndp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deleteHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt index 21f28c1b..9ccbb9b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatService.kt @@ -45,30 +45,30 @@ interface ChatService { */ fun complete(model: String): ChatCompleteResponse = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ChatCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): ChatCompleteResponse = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): ChatCompleteResponse - /** @see [complete] */ + /** @see complete */ fun complete(params: ChatCompleteParams): ChatCompleteResponse = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete(model: String, requestOptions: RequestOptions): ChatCompleteResponse = complete(model, ChatCompleteParams.none(), requestOptions) @@ -90,7 +90,7 @@ interface ChatService { fun complete(model: String): HttpResponseFor = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -99,26 +99,26 @@ interface ChatService { ): HttpResponseFor = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): HttpResponseFor = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete(params: ChatCompleteParams): HttpResponseFor = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt index b38025ec..d9a3a19c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.engines import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ChatService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: ChatCompleteParams, @@ -72,7 +72,7 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt index 1467ab4b..b5f7641b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentService.kt @@ -41,18 +41,18 @@ interface ContentService { fun retrieve(fileId: String, params: ContentRetrieveParams): ContentRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fileId: String, params: ContentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): ContentRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: ContentRetrieveParams): ContentRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: ContentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +79,7 @@ interface ContentService { ): HttpResponseFor = retrieve(fileId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( fileId: String, @@ -88,12 +88,12 @@ interface ContentService { ): HttpResponseFor = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: ContentRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: ContentRetrieveParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt index 7ce25d87..bfcd5b77 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.files import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -42,7 +42,8 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ContentService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: ContentRetrieveParams, @@ -77,7 +77,7 @@ class ContentServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt index e0a2ef4c..0437cb47 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobService.kt @@ -51,7 +51,7 @@ interface JobService { */ fun create(params: JobCreateParams): JobCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: JobCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -68,7 +68,7 @@ interface JobService { fun retrieve(fineTuningJobId: String, params: JobRetrieveParams): JobRetrieveResponse = retrieve(fineTuningJobId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( fineTuningJobId: String, params: JobRetrieveParams, @@ -76,11 +76,11 @@ interface JobService { ): JobRetrieveResponse = retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: JobRetrieveParams): JobRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: JobRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -97,7 +97,7 @@ interface JobService { */ fun list(params: JobListParams): JobListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: JobListParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -123,7 +123,7 @@ interface JobService { fun create(params: JobCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: JobCreateParams, @@ -141,7 +141,7 @@ interface JobService { ): HttpResponseFor = retrieve(fineTuningJobId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( fineTuningJobId: String, @@ -150,12 +150,12 @@ interface JobService { ): HttpResponseFor = retrieve(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: JobRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: JobRetrieveParams, @@ -170,7 +170,7 @@ interface JobService { fun list(params: JobListParams): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: JobListParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt index 5f34b86e..9024a2c3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.finetuning import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -63,7 +63,8 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : JobService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val cancel: CancelService.WithRawResponse by lazy { CancelServiceImpl.WithRawResponseImpl(clientOptions) @@ -79,7 +80,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun cancel(): CancelService.WithRawResponse = cancel private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: JobCreateParams, @@ -95,7 +96,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -108,7 +109,6 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: JobRetrieveParams, @@ -126,7 +126,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -138,7 +138,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: JobListParams, @@ -153,7 +153,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt index b78de5a4..30753a41 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelService.kt @@ -37,7 +37,7 @@ interface CancelService { fun create(fineTuningJobId: String): CancelCreateResponse = create(fineTuningJobId, CancelCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), @@ -45,23 +45,23 @@ interface CancelService { ): CancelCreateResponse = create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( fineTuningJobId: String, params: CancelCreateParams = CancelCreateParams.none(), ): CancelCreateResponse = create(fineTuningJobId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CancelCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: CancelCreateParams): CancelCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(fineTuningJobId: String, requestOptions: RequestOptions): CancelCreateResponse = create(fineTuningJobId, CancelCreateParams.none(), requestOptions) @@ -83,7 +83,7 @@ interface CancelService { fun create(fineTuningJobId: String): HttpResponseFor = create(fineTuningJobId, CancelCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( fineTuningJobId: String, @@ -92,7 +92,7 @@ interface CancelService { ): HttpResponseFor = create(params.toBuilder().fineTuningJobId(fineTuningJobId).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( fineTuningJobId: String, @@ -100,19 +100,19 @@ interface CancelService { ): HttpResponseFor = create(fineTuningJobId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: CancelCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: CancelCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( fineTuningJobId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt index 446a0186..307e6ebe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.finetuning.jobs import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -43,7 +43,8 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CancelService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -54,7 +55,6 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: CancelCreateParams, @@ -73,7 +73,7 @@ class CancelServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt index aaa5480d..ca2d2b39 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendService.kt @@ -44,18 +44,18 @@ interface SpendService { */ fun listTags(): List = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): List - /** @see [listTags] */ + /** @see listTags */ fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): List = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ fun listTags(requestOptions: RequestOptions): List = listTags(SpendListTagsParams.none(), requestOptions) @@ -69,17 +69,17 @@ interface SpendService { */ fun reset(): SpendResetResponse = reset(SpendResetParams.none()) - /** @see [reset] */ + /** @see reset */ fun reset( params: SpendResetParams = SpendResetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): SpendResetResponse - /** @see [reset] */ + /** @see reset */ fun reset(params: SpendResetParams = SpendResetParams.none()): SpendResetResponse = reset(params, RequestOptions.none()) - /** @see [reset] */ + /** @see reset */ fun reset(requestOptions: RequestOptions): SpendResetResponse = reset(SpendResetParams.none(), requestOptions) @@ -92,18 +92,18 @@ interface SpendService { fun retrieveReport(): List = retrieveReport(SpendRetrieveReportParams.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): List - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none() ): List = retrieveReport(params, RequestOptions.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ fun retrieveReport(requestOptions: RequestOptions): List = retrieveReport(SpendRetrieveReportParams.none(), requestOptions) @@ -125,20 +125,20 @@ interface SpendService { fun listTags(): HttpResponseFor> = listTags(SpendListTagsParams.none()) - /** @see [listTags] */ + /** @see listTags */ @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [listTags] */ + /** @see listTags */ @MustBeClosed fun listTags( params: SpendListTagsParams = SpendListTagsParams.none() ): HttpResponseFor> = listTags(params, RequestOptions.none()) - /** @see [listTags] */ + /** @see listTags */ @MustBeClosed fun listTags(requestOptions: RequestOptions): HttpResponseFor> = listTags(SpendListTagsParams.none(), requestOptions) @@ -150,20 +150,20 @@ interface SpendService { @MustBeClosed fun reset(): HttpResponseFor = reset(SpendResetParams.none()) - /** @see [reset] */ + /** @see reset */ @MustBeClosed fun reset( params: SpendResetParams = SpendResetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [reset] */ + /** @see reset */ @MustBeClosed fun reset( params: SpendResetParams = SpendResetParams.none() ): HttpResponseFor = reset(params, RequestOptions.none()) - /** @see [reset] */ + /** @see reset */ @MustBeClosed fun reset(requestOptions: RequestOptions): HttpResponseFor = reset(SpendResetParams.none(), requestOptions) @@ -176,21 +176,21 @@ interface SpendService { fun retrieveReport(): HttpResponseFor> = retrieveReport(SpendRetrieveReportParams.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ @MustBeClosed fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> - /** @see [retrieveReport] */ + /** @see retrieveReport */ @MustBeClosed fun retrieveReport( params: SpendRetrieveReportParams = SpendRetrieveReportParams.none() ): HttpResponseFor> = retrieveReport(params, RequestOptions.none()) - /** @see [retrieveReport] */ + /** @see retrieveReport */ @MustBeClosed fun retrieveReport( requestOptions: RequestOptions diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt index 6ede6dfe..45782bd9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.global import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -59,7 +59,8 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SpendService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -70,7 +71,6 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val listTagsHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun listTags( params: SpendListTagsParams, @@ -85,7 +85,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listTagsHandler.handle(it) } .also { @@ -97,7 +97,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt } private val resetHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun reset( params: SpendResetParams, @@ -113,7 +113,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { resetHandler.handle(it) } .also { @@ -126,7 +126,6 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveReportHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveReport( params: SpendRetrieveReportParams, @@ -141,7 +140,7 @@ class SpendServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveReportHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt index 32984638..e2c5fd7a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationService.kt @@ -27,18 +27,18 @@ interface GenerationService { /** Image Generation */ fun create(): GenerationCreateResponse = create(GenerationCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( params: GenerationCreateParams = GenerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GenerationCreateResponse - /** @see [create] */ + /** @see create */ fun create( params: GenerationCreateParams = GenerationCreateParams.none() ): GenerationCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(requestOptions: RequestOptions): GenerationCreateResponse = create(GenerationCreateParams.none(), requestOptions) @@ -62,20 +62,20 @@ interface GenerationService { fun create(): HttpResponseFor = create(GenerationCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: GenerationCreateParams = GenerationCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: GenerationCreateParams = GenerationCreateParams.none() ): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(requestOptions: RequestOptions): HttpResponseFor = create(GenerationCreateParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt index fffca83d..b6f6f3bc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.images import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -41,7 +41,8 @@ class GenerationServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : GenerationService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,6 @@ class GenerationServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: GenerationCreateParams, @@ -68,7 +68,7 @@ class GenerationServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt index 6542e8c2..3fe1e904 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt @@ -57,17 +57,17 @@ interface InfoService { */ fun list(): InfoListResponse = list(InfoListParams.none()) - /** @see [list] */ + /** @see list */ fun list( params: InfoListParams = InfoListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): InfoListResponse - /** @see [list] */ + /** @see list */ fun list(params: InfoListParams = InfoListParams.none()): InfoListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(requestOptions: RequestOptions): InfoListResponse = list(InfoListParams.none(), requestOptions) @@ -87,20 +87,20 @@ interface InfoService { */ @MustBeClosed fun list(): HttpResponseFor = list(InfoListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: InfoListParams = InfoListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: InfoListParams = InfoListParams.none() ): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(InfoListParams.none(), requestOptions) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt index d26a8647..db63a715 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.model import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -36,7 +36,8 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InfoService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -46,7 +47,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti ) private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun list( params: InfoListParams, @@ -61,7 +62,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt index 5c62a43c..89e4b772 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt @@ -29,7 +29,7 @@ interface UpdateService { /** Edit existing model params */ fun full(params: UpdateFullParams): UpdateFullResponse = full(params, RequestOptions.none()) - /** @see [full] */ + /** @see full */ fun full( params: UpdateFullParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -52,18 +52,18 @@ interface UpdateService { fun partial(modelId: String, params: UpdatePartialParams): UpdatePartialResponse = partial(modelId, params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ fun partial( modelId: String, params: UpdatePartialParams, requestOptions: RequestOptions = RequestOptions.none(), ): UpdatePartialResponse = partial(params.toBuilder().modelId(modelId).build(), requestOptions) - /** @see [partial] */ + /** @see partial */ fun partial(params: UpdatePartialParams): UpdatePartialResponse = partial(params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ fun partial( params: UpdatePartialParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -87,7 +87,7 @@ interface UpdateService { fun full(params: UpdateFullParams): HttpResponseFor = full(params, RequestOptions.none()) - /** @see [full] */ + /** @see full */ @MustBeClosed fun full( params: UpdateFullParams, @@ -104,7 +104,7 @@ interface UpdateService { params: UpdatePartialParams, ): HttpResponseFor = partial(modelId, params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ @MustBeClosed fun partial( modelId: String, @@ -113,12 +113,12 @@ interface UpdateService { ): HttpResponseFor = partial(params.toBuilder().modelId(modelId).build(), requestOptions) - /** @see [partial] */ + /** @see partial */ @MustBeClosed fun partial(params: UpdatePartialParams): HttpResponseFor = partial(params, RequestOptions.none()) - /** @see [partial] */ + /** @see partial */ @MustBeClosed fun partial( params: UpdatePartialParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt index 6586928b..e5c33550 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.model import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -52,7 +52,8 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UpdateService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -62,7 +63,7 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp ) private val fullHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun full( params: UpdateFullParams, @@ -78,7 +79,7 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { fullHandler.handle(it) } .also { @@ -91,7 +92,6 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp private val partialHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun partial( params: UpdatePartialParams, @@ -110,7 +110,7 @@ class UpdateServiceImpl internal constructor(private val clientOptions: ClientOp .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { partialHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt index d8ea71e2..1da2fa02 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentService.kt @@ -48,7 +48,7 @@ interface DeploymentService { fun complete(model: String): DeploymentCompleteResponse = complete(model, DeploymentCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), @@ -56,23 +56,23 @@ interface DeploymentService { ): DeploymentCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: DeploymentCompleteParams = DeploymentCompleteParams.none(), ): DeploymentCompleteResponse = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: DeploymentCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): DeploymentCompleteResponse - /** @see [complete] */ + /** @see complete */ fun complete(params: DeploymentCompleteParams): DeploymentCompleteResponse = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete(model: String, requestOptions: RequestOptions): DeploymentCompleteResponse = complete(model, DeploymentCompleteParams.none(), requestOptions) @@ -92,30 +92,30 @@ interface DeploymentService { */ fun embed(model: String): DeploymentEmbedResponse = embed(model, DeploymentEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): DeploymentEmbedResponse = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), ): DeploymentEmbedResponse = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed( params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): DeploymentEmbedResponse - /** @see [embed] */ + /** @see embed */ fun embed(params: DeploymentEmbedParams): DeploymentEmbedResponse = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ fun embed(model: String, requestOptions: RequestOptions): DeploymentEmbedResponse = embed(model, DeploymentEmbedParams.none(), requestOptions) @@ -141,7 +141,7 @@ interface DeploymentService { fun complete(model: String): HttpResponseFor = complete(model, DeploymentCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -150,7 +150,7 @@ interface DeploymentService { ): HttpResponseFor = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -158,20 +158,20 @@ interface DeploymentService { ): HttpResponseFor = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( params: DeploymentCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( params: DeploymentCompleteParams ): HttpResponseFor = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -187,7 +187,7 @@ interface DeploymentService { fun embed(model: String): HttpResponseFor = embed(model, DeploymentEmbedParams.none()) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( model: String, @@ -196,26 +196,26 @@ interface DeploymentService { ): HttpResponseFor = embed(params.toBuilder().model(model).build(), requestOptions) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( model: String, params: DeploymentEmbedParams = DeploymentEmbedParams.none(), ): HttpResponseFor = embed(model, params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( params: DeploymentEmbedParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed(params: DeploymentEmbedParams): HttpResponseFor = embed(params, RequestOptions.none()) - /** @see [embed] */ + /** @see embed */ @MustBeClosed fun embed( model: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt index e322f076..b3f811ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.openai import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -58,7 +58,8 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DeploymentService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) private val chat: ChatService.WithRawResponse by lazy { ChatServiceImpl.WithRawResponseImpl(clientOptions) @@ -75,7 +76,6 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: DeploymentCompleteParams, @@ -94,7 +94,7 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { @@ -107,7 +107,6 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie private val embedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun embed( params: DeploymentEmbedParams, @@ -126,7 +125,7 @@ class DeploymentServiceImpl internal constructor(private val clientOptions: Clie .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { embedHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt index 13b234ac..595e76ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatService.kt @@ -45,30 +45,30 @@ interface ChatService { */ fun complete(model: String): ChatCompleteResponse = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ChatCompleteResponse = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): ChatCompleteResponse = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): ChatCompleteResponse - /** @see [complete] */ + /** @see complete */ fun complete(params: ChatCompleteParams): ChatCompleteResponse = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ fun complete(model: String, requestOptions: RequestOptions): ChatCompleteResponse = complete(model, ChatCompleteParams.none(), requestOptions) @@ -90,7 +90,7 @@ interface ChatService { fun complete(model: String): HttpResponseFor = complete(model, ChatCompleteParams.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, @@ -99,26 +99,26 @@ interface ChatService { ): HttpResponseFor = complete(params.toBuilder().model(model).build(), requestOptions) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, params: ChatCompleteParams = ChatCompleteParams.none(), ): HttpResponseFor = complete(model, params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( params: ChatCompleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete(params: ChatCompleteParams): HttpResponseFor = complete(params, RequestOptions.none()) - /** @see [complete] */ + /** @see complete */ @MustBeClosed fun complete( model: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt index d0f71ccb..8d36cfcd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.openai.deployments import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ChatService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti private val completeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun complete( params: ChatCompleteParams, @@ -78,7 +78,7 @@ class ChatServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { completeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt index 94b63ac9..5d21665c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoService.kt @@ -30,7 +30,7 @@ interface InfoService { fun retrieve(params: InfoRetrieveParams): InfoRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: InfoRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -40,7 +40,7 @@ interface InfoService { fun deprecated(params: InfoDeprecatedParams): InfoDeprecatedResponse = deprecated(params, RequestOptions.none()) - /** @see [deprecated] */ + /** @see deprecated */ fun deprecated( params: InfoDeprecatedParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -64,7 +64,7 @@ interface InfoService { fun retrieve(params: InfoRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: InfoRetrieveParams, @@ -79,7 +79,7 @@ interface InfoService { fun deprecated(params: InfoDeprecatedParams): HttpResponseFor = deprecated(params, RequestOptions.none()) - /** @see [deprecated] */ + /** @see deprecated */ @MustBeClosed fun deprecated( params: InfoDeprecatedParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt index 0cb47ed8..9ed92abe 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.organization import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -49,7 +49,8 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InfoService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -60,7 +61,6 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: InfoRetrieveParams, @@ -75,7 +75,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -88,7 +88,6 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti private val deprecatedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun deprecated( params: InfoDeprecatedParams, @@ -104,7 +103,7 @@ class InfoServiceImpl internal constructor(private val clientOptions: ClientOpti .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { deprecatedHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt index 83d12b99..110f7fb9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemService.kt @@ -37,7 +37,7 @@ interface InputItemService { fun list(responseId: String): InputItemListResponse = list(responseId, InputItemListParams.none()) - /** @see [list] */ + /** @see list */ fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), @@ -45,23 +45,23 @@ interface InputItemService { ): InputItemListResponse = list(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), ): InputItemListResponse = list(responseId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): InputItemListResponse - /** @see [list] */ + /** @see list */ fun list(params: InputItemListParams): InputItemListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(responseId: String, requestOptions: RequestOptions): InputItemListResponse = list(responseId, InputItemListParams.none(), requestOptions) @@ -83,7 +83,7 @@ interface InputItemService { fun list(responseId: String): HttpResponseFor = list(responseId, InputItemListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( responseId: String, @@ -92,26 +92,26 @@ interface InputItemService { ): HttpResponseFor = list(params.toBuilder().responseId(responseId).build(), requestOptions) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( responseId: String, params: InputItemListParams = InputItemListParams.none(), ): HttpResponseFor = list(responseId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: InputItemListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(params: InputItemListParams): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( responseId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt index 1052562e..ab366af9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.responses import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.parseable @@ -42,7 +42,8 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InputItemService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -53,7 +54,6 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: InputItemListParams, @@ -71,7 +71,7 @@ class InputItemServiceImpl internal constructor(private val clientOptions: Clien .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt index dfbbc139..6b65bb1e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackService.kt @@ -48,7 +48,7 @@ interface CallbackService { fun retrieve(teamId: String): CallbackRetrieveResponse = retrieve(teamId, CallbackRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), @@ -56,23 +56,23 @@ interface CallbackService { ): CallbackRetrieveResponse = retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( teamId: String, params: CallbackRetrieveParams = CallbackRetrieveParams.none(), ): CallbackRetrieveResponse = retrieve(teamId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CallbackRetrieveResponse - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(params: CallbackRetrieveParams): CallbackRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve(teamId: String, requestOptions: RequestOptions): CallbackRetrieveResponse = retrieve(teamId, CallbackRetrieveParams.none(), requestOptions) @@ -117,17 +117,17 @@ interface CallbackService { fun add(teamId: String, params: CallbackAddParams): CallbackAddResponse = add(teamId, params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( teamId: String, params: CallbackAddParams, requestOptions: RequestOptions = RequestOptions.none(), ): CallbackAddResponse = add(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [add] */ + /** @see add */ fun add(params: CallbackAddParams): CallbackAddResponse = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( params: CallbackAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -151,7 +151,7 @@ interface CallbackService { fun retrieve(teamId: String): HttpResponseFor = retrieve(teamId, CallbackRetrieveParams.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( teamId: String, @@ -160,7 +160,7 @@ interface CallbackService { ): HttpResponseFor = retrieve(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( teamId: String, @@ -168,19 +168,19 @@ interface CallbackService { ): HttpResponseFor = retrieve(teamId, params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: CallbackRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve(params: CallbackRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( teamId: String, @@ -196,7 +196,7 @@ interface CallbackService { fun add(teamId: String, params: CallbackAddParams): HttpResponseFor = add(teamId, params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ @MustBeClosed fun add( teamId: String, @@ -205,12 +205,12 @@ interface CallbackService { ): HttpResponseFor = add(params.toBuilder().teamId(teamId).build(), requestOptions) - /** @see [add] */ + /** @see add */ @MustBeClosed fun add(params: CallbackAddParams): HttpResponseFor = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ @MustBeClosed fun add( params: CallbackAddParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt index 4331a6b8..c8d4b40c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.team import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -52,7 +52,8 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CallbackService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,6 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: CallbackRetrieveParams, @@ -81,7 +81,7 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -94,7 +94,6 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client private val addHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun add( params: CallbackAddParams, @@ -113,7 +112,7 @@ class CallbackServiceImpl internal constructor(private val clientOptions: Client .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { addHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt index d774bcba..eb3acb29 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelService.kt @@ -43,7 +43,7 @@ interface ModelService { */ fun add(params: ModelAddParams): ModelAddResponse = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ fun add( params: ModelAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -68,7 +68,7 @@ interface ModelService { fun remove(params: ModelRemoveParams): ModelRemoveResponse = remove(params, RequestOptions.none()) - /** @see [remove] */ + /** @see remove */ fun remove( params: ModelRemoveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +92,7 @@ interface ModelService { fun add(params: ModelAddParams): HttpResponseFor = add(params, RequestOptions.none()) - /** @see [add] */ + /** @see add */ @MustBeClosed fun add( params: ModelAddParams, @@ -107,7 +107,7 @@ interface ModelService { fun remove(params: ModelRemoveParams): HttpResponseFor = remove(params, RequestOptions.none()) - /** @see [remove] */ + /** @see remove */ @MustBeClosed fun remove( params: ModelRemoveParams, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt index 1436fed1..e3f19842 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceImpl.kt @@ -3,13 +3,13 @@ package ai.hanzo.api.services.blocking.team import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -47,7 +47,8 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ModelService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -57,7 +58,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt ) private val addHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun add( params: ModelAddParams, @@ -73,7 +74,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { addHandler.handle(it) } .also { @@ -86,7 +87,6 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt private val removeHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun remove( params: ModelRemoveParams, @@ -102,7 +102,7 @@ class ModelServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { removeHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt index 6e1c4399..15a95029 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageService.kt @@ -34,30 +34,30 @@ interface MessageService { fun create(threadId: String): MessageCreateResponse = create(threadId, MessageCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): MessageCreateResponse = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), ): MessageCreateResponse = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: MessageCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): MessageCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: MessageCreateParams): MessageCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(threadId: String, requestOptions: RequestOptions): MessageCreateResponse = create(threadId, MessageCreateParams.none(), requestOptions) @@ -68,29 +68,29 @@ interface MessageService { */ fun list(threadId: String): MessageListResponse = list(threadId, MessageListParams.none()) - /** @see [list] */ + /** @see list */ fun list( threadId: String, params: MessageListParams = MessageListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): MessageListResponse = list(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [list] */ + /** @see list */ fun list( threadId: String, params: MessageListParams = MessageListParams.none(), ): MessageListResponse = list(threadId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list( params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): MessageListResponse - /** @see [list] */ + /** @see list */ fun list(params: MessageListParams): MessageListResponse = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ fun list(threadId: String, requestOptions: RequestOptions): MessageListResponse = list(threadId, MessageListParams.none(), requestOptions) @@ -112,7 +112,7 @@ interface MessageService { fun create(threadId: String): HttpResponseFor = create(threadId, MessageCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( threadId: String, @@ -121,26 +121,26 @@ interface MessageService { ): HttpResponseFor = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( threadId: String, params: MessageCreateParams = MessageCreateParams.none(), ): HttpResponseFor = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: MessageCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: MessageCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( threadId: String, @@ -156,7 +156,7 @@ interface MessageService { fun list(threadId: String): HttpResponseFor = list(threadId, MessageListParams.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( threadId: String, @@ -165,26 +165,26 @@ interface MessageService { ): HttpResponseFor = list(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( threadId: String, params: MessageListParams = MessageListParams.none(), ): HttpResponseFor = list(threadId, params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( params: MessageListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [list] */ + /** @see list */ @MustBeClosed fun list(params: MessageListParams): HttpResponseFor = list(params, RequestOptions.none()) - /** @see [list] */ + /** @see list */ @MustBeClosed fun list( threadId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt index a099d2fe..4b5d22f2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.threads import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -52,7 +52,8 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : MessageService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -63,7 +64,6 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun create( params: MessageCreateParams, @@ -82,7 +82,7 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { @@ -95,7 +95,6 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun list( params: MessageListParams, @@ -113,7 +112,7 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { listHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt index ba2bcc24..cbeffa7d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunService.kt @@ -31,29 +31,29 @@ interface RunService { */ fun create(threadId: String): RunCreateResponse = create(threadId, RunCreateParams.none()) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RunCreateResponse = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), ): RunCreateResponse = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): RunCreateResponse - /** @see [create] */ + /** @see create */ fun create(params: RunCreateParams): RunCreateResponse = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ fun create(threadId: String, requestOptions: RequestOptions): RunCreateResponse = create(threadId, RunCreateParams.none(), requestOptions) @@ -75,7 +75,7 @@ interface RunService { fun create(threadId: String): HttpResponseFor = create(threadId, RunCreateParams.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( threadId: String, @@ -84,26 +84,26 @@ interface RunService { ): HttpResponseFor = create(params.toBuilder().threadId(threadId).build(), requestOptions) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( threadId: String, params: RunCreateParams = RunCreateParams.none(), ): HttpResponseFor = create(threadId, params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see [create] */ + /** @see create */ @MustBeClosed fun create(params: RunCreateParams): HttpResponseFor = create(params, RequestOptions.none()) - /** @see [create] */ + /** @see create */ @MustBeClosed fun create( threadId: String, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt index 9a3a9939..39083659 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceImpl.kt @@ -3,14 +3,14 @@ package ai.hanzo.api.services.blocking.threads import ai.hanzo.api.core.ClientOptions -import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.handlers.errorBodyHandler import ai.hanzo.api.core.handlers.errorHandler import ai.hanzo.api.core.handlers.jsonHandler -import ai.hanzo.api.core.handlers.withErrorHandler import ai.hanzo.api.core.http.HttpMethod import ai.hanzo.api.core.http.HttpRequest +import ai.hanzo.api.core.http.HttpResponse import ai.hanzo.api.core.http.HttpResponse.Handler import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.core.http.json @@ -42,7 +42,8 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RunService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -52,7 +53,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio ) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) override fun create( params: RunCreateParams, @@ -71,7 +72,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { createHandler.handle(it) } .also { diff --git a/hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro b/hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro new file mode 100644 index 00000000..cfe843a6 --- /dev/null +++ b/hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). +-keep class com.fasterxml.jackson.core.type.TypeReference { *; } +-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } + +# Jackson uses reflection to access our class serializers and deserializers. +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class ai.hanzo.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class ai.hanzo.api.** { *; } + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class ai.hanzo.api.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt index deb04eb1..775aefa2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.core.http import ai.hanzo.api.client.okhttp.OkHttpClient import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.errors.HanzoRetryableException import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest @@ -251,6 +252,82 @@ internal class RetryingHttpClientTest { assertNoResponseLeaks() } + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw HanzoRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + callCount++ + if (callCount == 1) { + val future = CompletableFuture() + future.completeExceptionally( + HanzoRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + private fun retryingHttpClientBuilder() = RetryingHttpClient.builder() .httpClient(httpClient) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeParamsTest.kt index 856c53eb..5a142b88 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ClientGetHomeParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ClientGetHomeParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeResponseTest.kt index 82a85b02..89da33b5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/ClientGetHomeResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ClientGetHomeResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val clientGetHomeResponse = ClientGetHomeResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParamsTest.kt index 7f4195b1..67981285 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.active -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ActiveListCallbacksParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ActiveListCallbacksParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt index 42ebf703..afeced9d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.active import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ActiveListCallbacksResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val activeListCallbacksResponse = ActiveListCallbacksResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParamsTest.kt index c8f332aa..524a91ac 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.add import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AddAddAllowedIpParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AddAddAllowedIpParams.builder().ipAddress(IpAddress.builder().ip("ip").build()).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt index 16bcaa0f..c4f1060d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.add import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AddAddAllowedIpResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val addAddAllowedIpResponse = AddAddAllowedIpResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt index aa130f20..17094931 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/add/IpAddressTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.add import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class IpAddressTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val ipAddress = IpAddress.builder().ip("ip").build() @@ -18,7 +16,6 @@ internal class IpAddressTest { assertThat(ipAddress.ip()).isEqualTo("ip") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParamsTest.kt index 19a3290f..01f0b654 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.anthropic import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AnthropicCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AnthropicCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt index 62f8306c..7961c1f2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val anthropicCreateResponse = AnthropicCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParamsTest.kt index e2ab7024..404d47e9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.anthropic import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AnthropicDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AnthropicDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt index e301e467..67ee1f68 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val anthropicDeleteResponse = AnthropicDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParamsTest.kt index 20b78ef1..3d0b72d2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.anthropic import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicModifyParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AnthropicModifyParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AnthropicModifyParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt index b26090b8..df98caa7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicModifyResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val anthropicModifyResponse = AnthropicModifyResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParamsTest.kt index b08e74ee..832bb77a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.anthropic import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AnthropicRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AnthropicRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt index 7566ec72..6aa410a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val anthropicRetrieveResponse = AnthropicRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParamsTest.kt index 362e16d0..416eb8d6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.anthropic import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AnthropicUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AnthropicUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt index ede46b08..773376aa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.anthropic import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AnthropicUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val anthropicUpdateResponse = AnthropicUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParamsTest.kt index c32014ae..d438c45d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.assemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssemblyaiCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AssemblyaiCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt index 7e66c463..8f8143ac 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assemblyaiCreateResponse = AssemblyaiCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParamsTest.kt index 3f31c2c4..3b7e248e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.assemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssemblyaiDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AssemblyaiDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt index e89584cc..c46ffc61 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assemblyaiDeleteResponse = AssemblyaiDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParamsTest.kt index ed844f80..4c302b4e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.assemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiPatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssemblyaiPatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AssemblyaiPatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt index c2043910..8f71554b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiPatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assemblyaiPatchResponse = AssemblyaiPatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParamsTest.kt index 0e89ede6..4126ef32 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.assemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssemblyaiRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AssemblyaiRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt index 5c54a76e..8a4065a0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assemblyaiRetrieveResponse = AssemblyaiRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParamsTest.kt index ec621e58..4e28990c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.assemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssemblyaiUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AssemblyaiUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt index c23c537b..9cb40027 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssemblyaiUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assemblyaiUpdateResponse = AssemblyaiUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParamsTest.kt index ecb1f3df..a7b5926e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.assistants -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssistantCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssistantCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt index afbac60f..d15edfea 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assistants import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssistantCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assistantCreateResponse = AssistantCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParamsTest.kt index f5b0bbb3..83770ddc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.assistants import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssistantDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssistantDeleteParams.builder().assistantId("assistant_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AssistantDeleteParams.builder().assistantId("assistant_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt index dbfa59fd..e767c1e8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assistants import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssistantDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assistantDeleteResponse = AssistantDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListParamsTest.kt index cd95303f..5c0c493e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.assistants -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssistantListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AssistantListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt index 779c4ff2..b6659e25 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/assistants/AssistantListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.assistants import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AssistantListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val assistantListResponse = AssistantListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParamsTest.kt index ef6be19b..6064f88c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.audio.speech -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpeechCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpeechCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt index 39b554c0..fcb7bd27 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.audio.speech import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpeechCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val speechCreateResponse = SpeechCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt index a9acdc4b..e02c35ed 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateParamsTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.audio.transcriptions import ai.hanzo.api.core.MultipartField import java.io.InputStream import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TranscriptionCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TranscriptionCreateParams.builder().file("some content".byteInputStream()).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt index 95ec0c93..8028b6f1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.audio.transcriptions import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TranscriptionCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val transcriptionCreateResponse = TranscriptionCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallParamsTest.kt index 7de0d560..c902d228 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.azure import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureCallParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AzureCallParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AzureCallParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt index 2618e945..ac84e8d0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCallResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureCallResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val azureCallResponse = AzureCallResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateParamsTest.kt index 26b2619c..b7cbe2ce 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.azure import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AzureCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AzureCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt index 36f1acbe..5c52d30b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val azureCreateResponse = AzureCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteParamsTest.kt index 2caa2e37..8047dae7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.azure import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AzureDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AzureDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt index 8dd48cc4..6da4db3a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val azureDeleteResponse = AzureDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchParamsTest.kt index fa42abbe..2d4823c0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.azure import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzurePatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AzurePatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AzurePatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt index b8572149..66bb8fc5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzurePatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzurePatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val azurePatchResponse = AzurePatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateParamsTest.kt index e430f759..f838433b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.azure import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { AzureUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = AzureUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt index 5ff8d738..b1f5f613 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.azure import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class AzureUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val azureUpdateResponse = AzureUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParamsTest.kt index b8c8650d..53a49d32 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.batches import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchCancelWithProviderParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchCancelWithProviderParams.builder().provider("provider").batchId("batch_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt index dd5691a5..5c6d3852 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchCancelWithProviderResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchCancelWithProviderResponse = BatchCancelWithProviderResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateParamsTest.kt index a456ecab..6e6e4914 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchCreateParams.builder().provider("provider").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BatchCreateParams.builder().provider("provider").build() @@ -25,7 +22,6 @@ internal class BatchCreateParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("provider", "provider").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BatchCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt index b1a818dc..227df5f3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchCreateResponse = BatchCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParamsTest.kt index 7226f33d..fadb2704 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.batches import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchCreateWithProviderParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchCreateWithProviderParams.builder().provider("provider").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BatchCreateWithProviderParams.builder().provider("provider").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt index cf443fe0..69621b66 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchCreateWithProviderResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchCreateWithProviderResponse = BatchCreateWithProviderResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListParamsTest.kt index b20cb26f..2a2f199b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchListParams.builder().after("after").limit(0L).provider("provider").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BatchListParams.builder().after("after").limit(0L).provider("provider").build() @@ -32,7 +29,6 @@ internal class BatchListParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BatchListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt index b51a6e80..dc8ef20d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchListResponse = BatchListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParamsTest.kt index 7e8a7484..bc38f343 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchListWithProviderParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchListWithProviderParams.builder().provider("provider").after("after").limit(0L).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BatchListWithProviderParams.builder().provider("provider").build() @@ -25,7 +22,6 @@ internal class BatchListWithProviderParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -41,7 +37,6 @@ internal class BatchListWithProviderParamsTest { .isEqualTo(QueryParams.builder().put("after", "after").put("limit", "0").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BatchListWithProviderParams.builder().provider("provider").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt index 3e4eac95..bd74aac4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchListWithProviderResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchListWithProviderResponse = BatchListWithProviderResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParamsTest.kt index 0f5b69c7..7b1737ca 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchRetrieveParams.builder().batchId("batch_id").provider("provider").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BatchRetrieveParams.builder().batchId("batch_id").build() @@ -25,7 +22,6 @@ internal class BatchRetrieveParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BatchRetrieveParams.builder().batchId("batch_id").provider("provider").build() @@ -35,7 +31,6 @@ internal class BatchRetrieveParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("provider", "provider").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BatchRetrieveParams.builder().batchId("batch_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt index 6e47e188..cdc098ef 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchRetrieveResponse = BatchRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParamsTest.kt index 50bd60ab..5a337252 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.batches import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchRetrieveWithProviderParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BatchRetrieveWithProviderParams.builder().provider("provider").batchId("batch_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt index 973a8c38..8b3f5cbe 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BatchRetrieveWithProviderResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val batchRetrieveWithProviderResponse = BatchRetrieveWithProviderResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParamsTest.kt index 69418ef5..ce56638d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.batches.cancel import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CancelCancelParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CancelCancelParams.builder().batchId("batch_id").provider("provider").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CancelCancelParams.builder().batchId("batch_id").build() @@ -25,7 +22,6 @@ internal class CancelCancelParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = CancelCancelParams.builder().batchId("batch_id").provider("provider").build() @@ -35,7 +31,6 @@ internal class CancelCancelParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("provider", "provider").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = CancelCancelParams.builder().batchId("batch_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt index 4b5cc4a4..6f2ad298 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.batches.cancel import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CancelCancelResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cancelCancelResponse = CancelCancelResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParamsTest.kt index 9e5fd73e..b43ef85c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.bedrock import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BedrockCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BedrockCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt index fc6c68e7..e6688d55 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val bedrockCreateResponse = BedrockCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParamsTest.kt index 98592270..92237927 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.bedrock import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BedrockDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BedrockDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt index 479b0e33..a5e7f508 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val bedrockDeleteResponse = BedrockDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParamsTest.kt index dced6772..45270e71 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.bedrock import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockPatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BedrockPatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BedrockPatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt index 7c168e1a..cdbc3567 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockPatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val bedrockPatchResponse = BedrockPatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParamsTest.kt index dd310971..bdf77eec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.bedrock import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BedrockRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BedrockRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt index 83670b3c..e29e77ec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val bedrockRetrieveResponse = BedrockRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParamsTest.kt index c7085a51..09babc10 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.bedrock import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BedrockUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = BedrockUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt index c3720ef7..0220a461 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.bedrock import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BedrockUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val bedrockUpdateResponse = BedrockUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateParamsTest.kt index 38773e77..ab5c7dcf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BudgetCreateParams.builder() @@ -42,7 +40,6 @@ internal class BudgetCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -106,7 +103,6 @@ internal class BudgetCreateParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = BudgetCreateParams.builder().budgetNew(BudgetNew.builder().build()).build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt index c46f36ac..5497bb48 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetCreateResponse = BudgetCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParamsTest.kt index 98f2e8ef..dd865cfb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.budget import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BudgetDeleteParams.builder().id("id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = BudgetDeleteParams.builder().id("id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt index f50f667e..1a77a6dd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetDeleteResponse = BudgetDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoParamsTest.kt index 55669b9e..d95075bd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.budget import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BudgetInfoParams.builder().addBudget("string").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = BudgetInfoParams.builder().addBudget("string").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt index 1b71fe07..9bb09ada 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetInfoResponse = BudgetInfoResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListParamsTest.kt index 54e80ec6..2b9d60fd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.budget -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BudgetListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt index 58eabbdd..152b4359 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetListResponse = BudgetListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt index a59c2b99..9fc4e397 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetNewTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetNewTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetNew = @@ -65,7 +63,6 @@ internal class BudgetNewTest { assertThat(budgetNew.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsParamsTest.kt index e4fb1ff7..c1972184 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetSettingsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BudgetSettingsParams.builder().budgetId("budget_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BudgetSettingsParams.builder().budgetId("budget_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt index a5e9ec98..647b1ca9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetSettingsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetSettingsResponse = BudgetSettingsResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParamsTest.kt index 1d66efc4..7384554d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BudgetUpdateParams.builder() @@ -42,7 +40,6 @@ internal class BudgetUpdateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -106,7 +103,6 @@ internal class BudgetUpdateParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = BudgetUpdateParams.builder().budgetNew(BudgetNew.builder().build()).build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt index 91c6e602..2ebec734 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.budget import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BudgetUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val budgetUpdateResponse = BudgetUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteParamsTest.kt index 5c8a332f..2277cfdd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.cache -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CacheDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CacheDeleteParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt index 24aae08d..d2cd2393 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cache import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CacheDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cacheDeleteResponse = CacheDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParamsTest.kt index c8d52412..2a93f115 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.cache -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CacheFlushAllParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CacheFlushAllParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt index 8bf8a6b8..701f14a3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cache import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CacheFlushAllResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cacheFlushAllResponse = CacheFlushAllResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingParamsTest.kt index 822cf18f..96cbc85e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.cache -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CachePingParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CachePingParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt index 97c8c1f6..04680b06 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/CachePingResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CachePingResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cachePingResponse = @@ -33,7 +31,6 @@ internal class CachePingResponseTest { assertThat(cachePingResponse.setCacheResponse()).contains("set_cache_response") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoParamsTest.kt index 234a7a35..778a0f19 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.cache.redis -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RediRetrieveInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { RediRetrieveInfoParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt index 5f96e196..33e22109 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cache.redis import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RediRetrieveInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val rediRetrieveInfoResponse = RediRetrieveInfoResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParamsTest.kt index eb7249c8..2e5f65ec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.chat.completions import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CompletionCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CompletionCreateParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = CompletionCreateParams.builder().model("model").build() @@ -25,7 +22,6 @@ internal class CompletionCreateParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("model", "model").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = CompletionCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt index 5b85e8c7..0a0ff693 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.chat.completions import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CompletionCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val completionCreateResponse = CompletionCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateParamsTest.kt index 1550c1bb..bf293e27 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.cohere import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CohereCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CohereCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt index 453d137d..321d7154 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cohereCreateResponse = CohereCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParamsTest.kt index 1debe846..c70be178 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.cohere import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CohereDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CohereDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt index 4f61df80..19502521 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cohereDeleteResponse = CohereDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyParamsTest.kt index f293ad4c..fa5d2f7a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.cohere import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereModifyParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CohereModifyParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CohereModifyParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt index ca4a579d..2a5e8836 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereModifyResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cohereModifyResponse = CohereModifyResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParamsTest.kt index 7dff966b..48f2912f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.cohere import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CohereRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CohereRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt index 744772f5..9a82be85 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cohereRetrieveResponse = CohereRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParamsTest.kt index 001a1576..45c997c5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.cohere import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CohereUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CohereUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt index 1431d318..f6decbeb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.cohere import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CohereUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cohereUpdateResponse = CohereUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateParamsTest.kt index 3fdda285..957fbc55 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.completions import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CompletionCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CompletionCreateParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = CompletionCreateParams.builder().model("model").build() @@ -25,7 +22,6 @@ internal class CompletionCreateParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("model", "model").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = CompletionCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt index 6b78081d..82c22783 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.completions import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CompletionCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val completionCreateResponse = CompletionCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParamsTest.kt index 2ebe438f..4c8a7c5a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { PassThroughEndpointCreateParams.builder() @@ -23,7 +21,6 @@ internal class PassThroughEndpointCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt index 7487f419..cce2afba 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val passThroughEndpointCreateResponse = PassThroughEndpointCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParamsTest.kt index 49351778..9a4f68b1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { PassThroughEndpointDeleteParams.builder().endpointId("endpoint_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = PassThroughEndpointDeleteParams.builder().endpointId("endpoint_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParamsTest.kt index 90445e1d..2b11fd8b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { PassThroughEndpointListParams.builder().endpointId("endpoint_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = PassThroughEndpointListParams.builder().endpointId("endpoint_id").build() @@ -26,7 +23,6 @@ internal class PassThroughEndpointListParamsTest { .isEqualTo(QueryParams.builder().put("endpoint_id", "endpoint_id").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = PassThroughEndpointListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt index 7578e3b2..ef0c51ad 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val passThroughEndpointResponse = @@ -35,7 +33,6 @@ internal class PassThroughEndpointResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParamsTest.kt index 1c785a10..7f2d6121 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.config.passthroughendpoint import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { PassThroughEndpointUpdateParams.builder().endpointId("endpoint_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = PassThroughEndpointUpdateParams.builder().endpointId("endpoint_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt index da1bdddd..6906cbd0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughEndpointUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val passThroughEndpointUpdateResponse = PassThroughEndpointUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt index 5dddd67e..aa501ddc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpointTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class PassThroughGenericEndpointTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val passThroughGenericEndpoint = @@ -27,7 +25,6 @@ internal class PassThroughGenericEndpointTest { assertThat(passThroughGenericEndpoint.target()).isEqualTo("target") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParamsTest.kt index f565ef52..2446a040 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.credentials import ai.hanzo.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CredentialCreateParams.builder() @@ -20,7 +18,6 @@ internal class CredentialCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -39,7 +36,6 @@ internal class CredentialCreateParamsTest { assertThat(body.modelId()).contains("model_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt index 17265439..590144e4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.credentials import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val credentialCreateResponse = CredentialCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParamsTest.kt index 607926d6..55569b57 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.credentials import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CredentialDeleteParams.builder().credentialName("credential_name").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CredentialDeleteParams.builder().credentialName("credential_name").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt index bed7a397..cbd117a2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.credentials import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val credentialDeleteResponse = CredentialDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt index c068778f..16c14d20 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialItemTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialItemTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val credentialItem = @@ -27,7 +25,6 @@ internal class CredentialItemTest { .isEqualTo(JsonValue.from(mapOf())) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListParamsTest.kt index 5aa1ef5b..2666c5ac 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.credentials -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CredentialListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt index 6556a577..ecd7c48a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/credentials/CredentialListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.credentials import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CredentialListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val credentialListResponse = CredentialListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt index 2359d2cb..a361ae38 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/BlockUsersTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BlockUsersTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val blockUsers = BlockUsers.builder().addUserId("string").build() @@ -18,7 +16,6 @@ internal class BlockUsersTest { assertThat(blockUsers.userIds()).containsExactly("string") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockParamsTest.kt index ac943c21..893f84e8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.customer import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerBlockParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerBlockParams.builder() @@ -16,7 +14,6 @@ internal class CustomerBlockParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt index 25d82bfc..013298d0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerBlockResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerBlockResponse = CustomerBlockResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateParamsTest.kt index e12c4dda..bb3eddec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerCreateParams.builder() @@ -43,7 +41,6 @@ internal class CustomerCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -109,7 +106,6 @@ internal class CustomerCreateParamsTest { assertThat(body.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = CustomerCreateParams.builder().userId("user_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt index 4f0f5c4f..8845879f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerCreateResponse = CustomerCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParamsTest.kt index 8cb5f9d2..a672e6ba 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.customer import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerDeleteParams.builder().addUserId("string").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = CustomerDeleteParams.builder().addUserId("string").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt index e5736ebe..384225dc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerDeleteResponse = CustomerDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListParamsTest.kt index 0c1c93df..1e046c11 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.customer -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt index 930395c1..00ea8497 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerListResponse = @@ -56,7 +54,6 @@ internal class CustomerListResponseTest { assertThat(customerListResponse.spend()).contains(0.0) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParamsTest.kt index 0dd05550..c0e3d2fc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerRetrieveInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerRetrieveInfoParams.builder().endUserId("end_user_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = CustomerRetrieveInfoParams.builder().endUserId("end_user_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt index ca139011..18e79463 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerRetrieveInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerRetrieveInfoResponse = @@ -56,7 +54,6 @@ internal class CustomerRetrieveInfoResponseTest { assertThat(customerRetrieveInfoResponse.spend()).contains(0.0) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParamsTest.kt index 5986a480..752f52ca 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.customer import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerUnblockParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerUnblockParams.builder() @@ -16,7 +14,6 @@ internal class CustomerUnblockParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt index 63c5ba75..8ee10c57 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerUnblockResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerUnblockResponse = CustomerUnblockResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParamsTest.kt index c5f99b26..cf5ab04b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.customer import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CustomerUpdateParams.builder() @@ -22,7 +20,6 @@ internal class CustomerUpdateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -47,7 +44,6 @@ internal class CustomerUpdateParamsTest { assertThat(body.maxBudget()).contains(0.0) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = CustomerUpdateParams.builder().userId("user_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt index 73e990c6..f673c9c6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.customer import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CustomerUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val customerUpdateResponse = CustomerUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParamsTest.kt index 11c242ab..156bbcc1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.delete import ai.hanzo.api.models.add.IpAddress import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class DeleteCreateAllowedIpParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { DeleteCreateAllowedIpParams.builder() @@ -17,7 +15,6 @@ internal class DeleteCreateAllowedIpParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt index e167e620..070b0881 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.delete import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class DeleteCreateAllowedIpResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val deleteCreateAllowedIpResponse = DeleteCreateAllowedIpResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParamsTest.kt index 8ddb8021..a29aeb8f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.embeddings import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EmbeddingCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EmbeddingCreateParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = EmbeddingCreateParams.builder().model("model").build() @@ -25,7 +22,6 @@ internal class EmbeddingCreateParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("model", "model").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = EmbeddingCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt index 95f874da..8f48914d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.embeddings import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EmbeddingCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val embeddingCreateResponse = EmbeddingCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteParamsTest.kt index 64bcf53e..19d808a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.engines import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EngineCompleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EngineCompleteParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EngineCompleteParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt index 2c6e2455..e94f21af 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.engines import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EngineCompleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val engineCompleteResponse = EngineCompleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedParamsTest.kt index 8332647c..3032b92d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.engines import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EngineEmbedParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EngineEmbedParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EngineEmbedParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt index 09c432a6..26187476 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.engines import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EngineEmbedResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val engineEmbedResponse = EngineEmbedResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParamsTest.kt index ba2bbf0d..c491f50c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.engines.chat import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ChatCompleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ChatCompleteParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = ChatCompleteParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt index 5ac02a2f..6e56d99e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.engines.chat import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ChatCompleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val chatCompleteResponse = ChatCompleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParamsTest.kt index d90ccde5..8dd1e301 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.euassemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EuAssemblyaiCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EuAssemblyaiCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt index 8583101d..6cd77cf4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val euAssemblyaiCreateResponse = EuAssemblyaiCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParamsTest.kt index 814f749d..a9a8b1d5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.euassemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EuAssemblyaiDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EuAssemblyaiDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt index a10f1ad7..a77c3873 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val euAssemblyaiDeleteResponse = EuAssemblyaiDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParamsTest.kt index 4f827518..ccc35eaa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.euassemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiPatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EuAssemblyaiPatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EuAssemblyaiPatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt index 1add8f8e..22f459e6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiPatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val euAssemblyaiPatchResponse = EuAssemblyaiPatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParamsTest.kt index caff8ae4..27883f39 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.euassemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EuAssemblyaiRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EuAssemblyaiRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt index d07eab1a..3568984f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val euAssemblyaiRetrieveResponse = EuAssemblyaiRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParamsTest.kt index 6ab448e2..0a6c57b6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.euassemblyai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { EuAssemblyaiUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = EuAssemblyaiUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt index 4a85e1c0..8c1ca065 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.euassemblyai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class EuAssemblyaiUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val euAssemblyaiUpdateResponse = EuAssemblyaiUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt index 4acf2c58..b8a2d27d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.MultipartField import java.io.InputStream import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { FileCreateParams.builder() @@ -21,7 +19,6 @@ internal class FileCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = @@ -36,7 +33,6 @@ internal class FileCreateParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -69,7 +65,6 @@ internal class FileCreateParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt index eac21237..832061c2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val fileCreateResponse = FileCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteParamsTest.kt index cf985d92..eec337fb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.files import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { FileDeleteParams.builder().provider("provider").fileId("file_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = FileDeleteParams.builder().provider("provider").fileId("file_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt index f366d8ed..c9785b37 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val fileDeleteResponse = FileDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListParamsTest.kt index 91463df8..40e85f27 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { FileListParams.builder().provider("provider").purpose("purpose").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = FileListParams.builder().provider("provider").build() @@ -25,7 +22,6 @@ internal class FileListParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = FileListParams.builder().provider("provider").purpose("purpose").build() @@ -35,7 +31,6 @@ internal class FileListParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("purpose", "purpose").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = FileListParams.builder().provider("provider").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt index 2095be7d..569a2224 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val fileListResponse = FileListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveParamsTest.kt index f7135758..35d35e57 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.files import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { FileRetrieveParams.builder().provider("provider").fileId("file_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = FileRetrieveParams.builder().provider("provider").fileId("file_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt index f6f533ec..211461d9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/FileRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.files import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FileRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val fileRetrieveResponse = FileRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParamsTest.kt index acae136a..f7243e51 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.files.content import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ContentRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ContentRetrieveParams.builder().provider("provider").fileId("file_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = ContentRetrieveParams.builder().provider("provider").fileId("file_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt index f29c0506..8d5c7522 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.files.content import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ContentRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val contentRetrieveResponse = ContentRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParamsTest.kt index 1cfc08e9..cb808935 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.finetuning.jobs import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class JobCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { JobCreateParams.builder() @@ -30,7 +28,6 @@ internal class JobCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -70,7 +67,6 @@ internal class JobCreateParamsTest { assertThat(body.validationFile()).contains("validation_file") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt index 8c038f40..e6731106 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class JobCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val jobCreateResponse = JobCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParamsTest.kt index d952e5b3..f088f0a8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class JobListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { JobListParams.builder() @@ -19,7 +17,6 @@ internal class JobListParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -41,7 +38,6 @@ internal class JobListParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt index 40d3af61..a096b8d3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class JobListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val jobListResponse = JobListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParamsTest.kt index 489f40e7..a492dc04 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class JobRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { JobRetrieveParams.builder() @@ -18,7 +16,6 @@ internal class JobRetrieveParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = @@ -32,7 +29,6 @@ internal class JobRetrieveParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt index 2abe86c9..5d6a2d2a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class JobRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val jobRetrieveResponse = JobRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParamsTest.kt index aea30795..9777472a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.finetuning.jobs.cancel import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CancelCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CancelCreateParams.builder().fineTuningJobId("fine_tuning_job_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CancelCreateParams.builder().fineTuningJobId("fine_tuning_job_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt index 6ee40c2b..b9c415e9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.finetuning.jobs.cancel import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CancelCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val cancelCreateResponse = CancelCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParamsTest.kt index d68373dc..84d86958 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.gemini import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GeminiCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = GeminiCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt index d82e1577..c423ad48 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val geminiCreateResponse = GeminiCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParamsTest.kt index bdf3cd12..a0d19319 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.gemini import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GeminiDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = GeminiDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt index 44d0cfc3..acc44c9e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val geminiDeleteResponse = GeminiDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParamsTest.kt index 481ec83b..68b1cab3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.gemini import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiPatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GeminiPatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = GeminiPatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt index 12b4bd6d..13ec84c4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiPatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val geminiPatchResponse = GeminiPatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParamsTest.kt index f47ffee1..2c07cdc2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.gemini import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GeminiRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = GeminiRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt index 65981f2b..cf8a3e65 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val geminiRetrieveResponse = GeminiRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParamsTest.kt index d17674af..d193b2e2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.gemini import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GeminiUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = GeminiUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt index 56521159..3ebde65c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.gemini import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GeminiUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val geminiUpdateResponse = GeminiUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParamsTest.kt index 1021d88a..d0beb6ee 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.global.spend import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendListTagsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpendListTagsParams.builder() @@ -19,7 +17,6 @@ internal class SpendListTagsParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -41,7 +38,6 @@ internal class SpendListTagsParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = SpendListTagsParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt index 709c684d..21d3213c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendListTagsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val spendListTagsResponse = @@ -64,7 +62,6 @@ internal class SpendListTagsResponseTest { assertThat(spendListTagsResponse.user()).contains("user") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetParamsTest.kt index dbfefab5..59bdbc29 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.global.spend -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendResetParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpendResetParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt index 48df02db..ed62c415 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.global.spend import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendResetResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val spendResetResponse = SpendResetResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportParamsTest.kt index 23762bac..5411be89 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.global.spend import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendRetrieveReportParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpendRetrieveReportParams.builder() @@ -23,7 +21,6 @@ internal class SpendRetrieveReportParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -53,7 +50,6 @@ internal class SpendRetrieveReportParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = SpendRetrieveReportParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt index bc9a1c26..f4c1adcb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendRetrieveReportResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val spendRetrieveReportResponse = @@ -65,7 +63,6 @@ internal class SpendRetrieveReportResponseTest { assertThat(spendRetrieveReportResponse.user()).contains("user") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParamsTest.kt index b179dfe6..f8263326 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.guardrails -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GuardrailListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GuardrailListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt index 4d024411..4996133e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GuardrailListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val guardrailListResponse = @@ -47,7 +45,6 @@ internal class GuardrailListResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllParamsTest.kt index 81aabd54..fe12f344 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckAllParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { HealthCheckAllParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = HealthCheckAllParams.builder().model("model").build() @@ -25,7 +22,6 @@ internal class HealthCheckAllParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("model", "model").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = HealthCheckAllParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt index d9b8f467..1fe9e003 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckAllResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val healthCheckAllResponse = HealthCheckAllResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessParamsTest.kt index 18709d12..47a86deb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.health -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckLivelinessParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { HealthCheckLivelinessParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt index 0a875711..79e59801 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckLivelinessResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val healthCheckLivelinessResponse = HealthCheckLivelinessResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessParamsTest.kt index dc910908..5d602f69 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.health -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckLivenessParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { HealthCheckLivenessParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt index c0edb38a..0864dce5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckLivenessResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val healthCheckLivenessResponse = HealthCheckLivenessResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessParamsTest.kt index 7957c41c..a4f5ca03 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.health -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckReadinessParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { HealthCheckReadinessParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt index 5e20b6eb..46fbc456 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckReadinessResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val healthCheckReadinessResponse = HealthCheckReadinessResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParamsTest.kt index e5aa76fd..9fec2f49 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckServicesParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { HealthCheckServicesParams.builder() @@ -17,7 +15,6 @@ internal class HealthCheckServicesParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt index ab1cf8d9..69406757 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.health import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class HealthCheckServicesResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val healthCheckServicesResponse = HealthCheckServicesResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParamsTest.kt index fbc9a9c3..312d397b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.images.generations -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GenerationCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { GenerationCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt index 7c3e77e6..11d49e20 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.images.generations import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GenerationCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val generationCreateResponse = GenerationCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt index 4bcd7116..753702cf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/BlockKeyRequestTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BlockKeyRequestTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val blockKeyRequest = BlockKeyRequest.builder().key("key").build() @@ -18,7 +16,6 @@ internal class BlockKeyRequestTest { assertThat(blockKeyRequest.key()).isEqualTo("key") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt index 9fedad3e..3d2688a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/GenerateKeyResponseTest.kt @@ -8,12 +8,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class GenerateKeyResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val generateKeyResponse = @@ -94,7 +92,6 @@ internal class GenerateKeyResponseTest { assertThat(generateKeyResponse.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockParamsTest.kt index 083f8065..711e26a0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.http.Headers import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyBlockParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyBlockParams.builder() @@ -18,7 +16,6 @@ internal class KeyBlockParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -33,7 +30,6 @@ internal class KeyBlockParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = @@ -46,7 +42,6 @@ internal class KeyBlockParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -60,7 +55,6 @@ internal class KeyBlockParamsTest { assertThat(body).isEqualTo(BlockKeyRequest.builder().key("key").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt index 680eb13e..9ebb806d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyBlockResponseTest.kt @@ -8,12 +8,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyBlockResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyBlockResponse = @@ -87,7 +85,6 @@ internal class KeyBlockResponseTest { assertThat(keyBlockResponse.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParamsTest.kt index 5adc2516..43c303a9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.key -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyCheckHealthParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyCheckHealthParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt index 961971ba..677b0d69 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponseTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyCheckHealthResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyCheckHealthResponse = @@ -36,7 +34,6 @@ internal class KeyCheckHealthResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteParamsTest.kt index d9784f9a..5377da6c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.http.Headers import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyDeleteParams.builder() @@ -20,7 +18,6 @@ internal class KeyDeleteParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -36,7 +33,6 @@ internal class KeyDeleteParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = KeyDeleteParams.builder().build() @@ -46,7 +42,6 @@ internal class KeyDeleteParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -62,7 +57,6 @@ internal class KeyDeleteParamsTest { assertThat(body.keys().getOrNull()).containsExactly("string") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = KeyDeleteParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt index cab85d86..da943e3a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyDeleteResponse = KeyDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyGenerateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyGenerateParamsTest.kt index ecae707b..d194705e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyGenerateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyGenerateParamsTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.http.Headers import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyGenerateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyGenerateParams.builder() @@ -46,7 +44,6 @@ internal class KeyGenerateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -87,7 +84,6 @@ internal class KeyGenerateParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = KeyGenerateParams.builder().build() @@ -97,7 +93,6 @@ internal class KeyGenerateParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -164,7 +159,6 @@ internal class KeyGenerateParamsTest { assertThat(body.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = KeyGenerateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListParamsTest.kt index 90ed7f4b..571d0265 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyListParams.builder() @@ -24,7 +22,6 @@ internal class KeyListParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -56,7 +53,6 @@ internal class KeyListParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = KeyListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt index daaa409f..e7ad1de2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyListResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyListResponse = @@ -29,7 +27,6 @@ internal class KeyListResponseTest { assertThat(keyListResponse.totalPages()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParamsTest.kt index ffc3f6a8..98abc66f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParamsTest.kt @@ -7,12 +7,10 @@ import ai.hanzo.api.core.http.Headers import ai.hanzo.api.models.key.regenerate.RegenerateKeyRequest import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyRegenerateByKeyParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyRegenerateByKeyParams.builder() @@ -53,7 +51,6 @@ internal class KeyRegenerateByKeyParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = KeyRegenerateByKeyParams.builder().pathKey("key").build() @@ -63,7 +60,6 @@ internal class KeyRegenerateByKeyParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -110,7 +106,6 @@ internal class KeyRegenerateByKeyParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = KeyRegenerateByKeyParams.builder().pathKey("key").build() @@ -120,7 +115,6 @@ internal class KeyRegenerateByKeyParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -198,7 +192,6 @@ internal class KeyRegenerateByKeyParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = KeyRegenerateByKeyParams.builder().pathKey("key").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParamsTest.kt index 79c5a880..066edd49 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyRetrieveInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyRetrieveInfoParams.builder().key("key").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = KeyRetrieveInfoParams.builder().key("key").build() @@ -25,7 +22,6 @@ internal class KeyRetrieveInfoParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("key", "key").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = KeyRetrieveInfoParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt index ecc2d2c1..e717771a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyRetrieveInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyRetrieveInfoResponse = KeyRetrieveInfoResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockParamsTest.kt index a390a2b5..7eb1575a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.http.Headers import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyUnblockParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyUnblockParams.builder() @@ -18,7 +16,6 @@ internal class KeyUnblockParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -33,7 +30,6 @@ internal class KeyUnblockParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = @@ -46,7 +42,6 @@ internal class KeyUnblockParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -60,7 +55,6 @@ internal class KeyUnblockParamsTest { assertThat(body).isEqualTo(BlockKeyRequest.builder().key("key").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt index f3ee87f0..9a78a71b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUnblockResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyUnblockResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyUnblockResponse = KeyUnblockResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateParamsTest.kt index 0f1acacb..a9fca4a6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateParamsTest.kt @@ -7,12 +7,10 @@ import ai.hanzo.api.core.http.Headers import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { KeyUpdateParams.builder() @@ -47,7 +45,6 @@ internal class KeyUpdateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -88,7 +85,6 @@ internal class KeyUpdateParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = KeyUpdateParams.builder().key("key").build() @@ -98,7 +94,6 @@ internal class KeyUpdateParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -166,7 +161,6 @@ internal class KeyUpdateParamsTest { assertThat(body.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = KeyUpdateParams.builder().key("key").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt index 33969235..3bb49ee9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/KeyUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class KeyUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val keyUpdateResponse = KeyUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt index 9ba8a4ff..b763b80c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequestTest.kt @@ -7,12 +7,10 @@ import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RegenerateKeyRequestTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val regenerateKeyRequest = @@ -83,7 +81,6 @@ internal class RegenerateKeyRequestTest { assertThat(regenerateKeyRequest.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParamsTest.kt index d21e5f72..cc86a768 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.langfuse import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { LangfuseCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = LangfuseCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt index 3e6565f6..68ba880b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val langfuseCreateResponse = LangfuseCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParamsTest.kt index fe5c9fd8..af3ddf7b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.langfuse import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { LangfuseDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = LangfuseDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt index aecd8456..db7bd5aa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val langfuseDeleteResponse = LangfuseDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParamsTest.kt index a59fb7b2..c9557d8f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.langfuse import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfusePatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { LangfusePatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = LangfusePatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt index 24ee1155..2642f4c0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfusePatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val langfusePatchResponse = LangfusePatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParamsTest.kt index de2a6195..47890e64 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.langfuse import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { LangfuseRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = LangfuseRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt index 092efec9..91390a55 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val langfuseRetrieveResponse = LangfuseRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParamsTest.kt index 48c50d05..0de3db0b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.langfuse import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { LangfuseUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = LangfuseUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt index c3e41c27..5755c8f1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.langfuse import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class LangfuseUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val langfuseUpdateResponse = LangfuseUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt index d1db4e0b..89787ca2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.model import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ConfigurableClientsideParamsCustomAuthTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val configurableClientsideParamsCustomAuth = @@ -19,7 +17,6 @@ internal class ConfigurableClientsideParamsCustomAuthTest { assertThat(configurableClientsideParamsCustomAuth.apiBase()).isEqualTo("api_base") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateParamsTest.kt index 6bcedc16..92759c14 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.model import ai.hanzo.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModelCreateParams.builder() @@ -67,7 +65,6 @@ internal class ModelCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -180,7 +177,6 @@ internal class ModelCreateParamsTest { assertThat(body.modelName()).isEqualTo("model_name") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt index 351ff857..f17273ec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.model import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelCreateResponse = ModelCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteParamsTest.kt index 31695731..37434a30 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.model import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModelDeleteParams.builder().id("id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = ModelDeleteParams.builder().id("id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt index d21c9883..e6e037c5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.model import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelDeleteResponse = ModelDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt index 2f6103a2..8a9d80af 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ModelInfoTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelInfoTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelInfo = @@ -40,7 +38,6 @@ internal class ModelInfoTest { assertThat(modelInfo.updatedBy()).contains("updated_by") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListParamsTest.kt index dafb756c..77260e47 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.model.info import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InfoListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { InfoListParams.builder().llmModelId("llm_model_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = InfoListParams.builder().llmModelId("llm_model_id").build() @@ -26,7 +23,6 @@ internal class InfoListParamsTest { .isEqualTo(QueryParams.builder().put("llm_model_id", "llm_model_id").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = InfoListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt index e369e16b..ae347476 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/info/InfoListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.model.info import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InfoListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val infoListResponse = InfoListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt index c809c123..31d271a6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateDeploymentTest.kt @@ -8,12 +8,10 @@ import ai.hanzo.api.models.model.ModelInfo import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UpdateDeploymentTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val updateDeployment = @@ -124,7 +122,6 @@ internal class UpdateDeploymentTest { assertThat(updateDeployment.modelName()).contains("model_name") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullParamsTest.kt index 19fab507..2123353c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullParamsTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.model.ModelInfo import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UpdateFullParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UpdateFullParams.builder() @@ -72,7 +70,6 @@ internal class UpdateFullParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -192,7 +189,6 @@ internal class UpdateFullParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt index b70915b7..b6e9641d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.model.update import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UpdateFullResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val updateFullResponse = UpdateFullResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParamsTest.kt index ed95365f..62afddce 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialParamsTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.model.ModelInfo import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UpdatePartialParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UpdatePartialParams.builder() @@ -73,7 +71,6 @@ internal class UpdatePartialParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = @@ -87,7 +84,6 @@ internal class UpdatePartialParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -208,7 +204,6 @@ internal class UpdatePartialParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt index 9d126c92..b9911e5a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.model.update import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UpdatePartialResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val updatePartialResponse = UpdatePartialResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParamsTest.kt index 55210cd4..78e2936b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.modelgroup import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelGroupRetrieveInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModelGroupRetrieveInfoParams.builder().modelGroup("model_group").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = ModelGroupRetrieveInfoParams.builder().modelGroup("model_group").build() @@ -26,7 +23,6 @@ internal class ModelGroupRetrieveInfoParamsTest { .isEqualTo(QueryParams.builder().put("model_group", "model_group").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = ModelGroupRetrieveInfoParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt index cf78d3a5..fb0a69ba 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.modelgroup import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelGroupRetrieveInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelGroupRetrieveInfoResponse = ModelGroupRetrieveInfoResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListParamsTest.kt index c9a86340..69d666ff 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.models import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModelListParams.builder().returnWildcardRoutes(true).teamId("team_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = ModelListParams.builder().returnWildcardRoutes(true).teamId("team_id").build() @@ -31,7 +28,6 @@ internal class ModelListParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = ModelListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt index d381598c..aa1cf5bf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/models/ModelListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.models import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelListResponse = ModelListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParamsTest.kt index 15385a02..69418194 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.moderations -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModerationCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModerationCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt index cdd7b8be..83ace888 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.moderations import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModerationCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val moderationCreateResponse = ModerationCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateParamsTest.kt index 6bb71a01..6156fe03 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAICreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OpenAICreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = OpenAICreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt index 7106750e..abf51514 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAICreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val openaiCreateResponse = OpenAICreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParamsTest.kt index 8b192629..4de6b0a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OpenAIDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = OpenAIDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt index 412085d2..b4cf4d9d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val openaiDeleteResponse = OpenAIDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParamsTest.kt index 45a42b43..a0015ec5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIPatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OpenAIPatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = OpenAIPatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt index 3f6b376f..dc36b1a8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIPatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val openaiPatchResponse = OpenAIPatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParamsTest.kt index c1e05691..329952ca 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OpenAIRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = OpenAIRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt index a0985d9c..1f1a80e4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val openaiRetrieveResponse = OpenAIRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParamsTest.kt index d670196c..9b3eb7a9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OpenAIUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = OpenAIUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt index f66ce933..e3918f7b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OpenAIUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val openaiUpdateResponse = OpenAIUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParamsTest.kt index bf7b9074..814b81c5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai.deployments import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class DeploymentCompleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { DeploymentCompleteParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = DeploymentCompleteParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt index be0a8b66..4f4d5ed9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai.deployments import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class DeploymentCompleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val deploymentCompleteResponse = DeploymentCompleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParamsTest.kt index f704943e..846b3a03 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai.deployments import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class DeploymentEmbedParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { DeploymentEmbedParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = DeploymentEmbedParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt index 21de9ab3..b8db0ef0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai.deployments import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class DeploymentEmbedResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val deploymentEmbedResponse = DeploymentEmbedResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParamsTest.kt index db9c3958..bcbf65b9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.openai.deployments.chat import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ChatCompleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ChatCompleteParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = ChatCompleteParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt index ef529d87..0d83920c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.openai.deployments.chat import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ChatCompleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val chatCompleteResponse = ChatCompleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt index ce92da23..9896013d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrgMemberTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrgMemberTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val orgMember = @@ -25,7 +23,6 @@ internal class OrgMemberTest { assertThat(orgMember.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParamsTest.kt index 6082bfff..4210026c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.organization import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationAddMemberParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationAddMemberParams.builder() @@ -26,7 +24,6 @@ internal class OrganizationAddMemberParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -62,7 +59,6 @@ internal class OrganizationAddMemberParamsTest { assertThat(body.maxBudgetInOrganization()).contains(0.0) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt index 8d9ce674..2f530dff 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponseTest.kt @@ -7,12 +7,10 @@ import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationAddMemberResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationAddMemberResponse = @@ -163,7 +161,6 @@ internal class OrganizationAddMemberResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParamsTest.kt index 4a153a80..2fd8ff94 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationCreateParams.builder() @@ -29,7 +27,6 @@ internal class OrganizationCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -64,7 +61,6 @@ internal class OrganizationCreateParamsTest { assertThat(body.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt index a75fc243..7b014670 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponseTest.kt @@ -7,12 +7,10 @@ import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationCreateResponse = @@ -44,7 +42,6 @@ internal class OrganizationCreateResponseTest { assertThat(organizationCreateResponse.spend()).contains(0.0) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParamsTest.kt index 47dff241..cb380e4e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.organization import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationDeleteMemberParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationDeleteMemberParams.builder() @@ -18,7 +16,6 @@ internal class OrganizationDeleteMemberParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -35,7 +32,6 @@ internal class OrganizationDeleteMemberParamsTest { assertThat(body.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt index 10f244f5..16a3c659 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationDeleteMemberResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationDeleteMemberResponse = OrganizationDeleteMemberResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParamsTest.kt index 1558c3f4..39bd0d99 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.organization import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationDeleteParams.builder().addOrganizationId("string").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = OrganizationDeleteParams.builder().addOrganizationId("string").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt index 1ad1eee2..7a216c8c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt @@ -9,12 +9,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationDeleteResponse = @@ -187,7 +185,6 @@ internal class OrganizationDeleteResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListParamsTest.kt index 2fd5511a..583dc5e4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.organization -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt index 081b0658..1dc7240f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt @@ -9,12 +9,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationListResponse = @@ -187,7 +185,6 @@ internal class OrganizationListResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParamsTest.kt index d3b41f74..4411987a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.organization import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationUpdateMemberParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationUpdateMemberParams.builder() @@ -20,7 +18,6 @@ internal class OrganizationUpdateMemberParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -41,7 +38,6 @@ internal class OrganizationUpdateMemberParamsTest { assertThat(body.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt index a1e38f65..bf833c85 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponseTest.kt @@ -7,12 +7,10 @@ import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationUpdateMemberResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationUpdateMemberResponse = @@ -63,7 +61,6 @@ internal class OrganizationUpdateMemberResponseTest { assertThat(organizationUpdateMemberResponse.userRole()).contains("user_role") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParamsTest.kt index 52d999a6..324b6dcc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.organization import ai.hanzo.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { OrganizationUpdateParams.builder() @@ -24,7 +22,6 @@ internal class OrganizationUpdateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -49,7 +46,6 @@ internal class OrganizationUpdateParamsTest { assertThat(body.updatedBy()).contains("updated_by") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = OrganizationUpdateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt index 0ddea4fa..396a7ff4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt @@ -9,12 +9,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class OrganizationUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val organizationUpdateResponse = @@ -187,7 +185,6 @@ internal class OrganizationUpdateResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParamsTest.kt index c8ed0c93..a0b07061 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.organization.info import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InfoDeprecatedParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { InfoDeprecatedParams.builder().addOrganization("string").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = InfoDeprecatedParams.builder().addOrganization("string").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt index db957b4b..83ec02dc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.organization.info import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InfoDeprecatedResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val infoDeprecatedResponse = InfoDeprecatedResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveParamsTest.kt index cab18ff1..daf34fcc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.organization.info import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InfoRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { InfoRetrieveParams.builder().organizationId("organization_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = InfoRetrieveParams.builder().organizationId("organization_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt index b94a39c0..5de919d5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt @@ -9,12 +9,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InfoRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val infoRetrieveResponse = @@ -186,7 +184,6 @@ internal class InfoRetrieveResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParamsTest.kt index 35cb4887..5383bf42 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.provider -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ProviderListBudgetsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ProviderListBudgetsParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt index 766b5c3c..6aafcfcf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ProviderListBudgetsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val providerListBudgetsResponse = @@ -51,7 +49,6 @@ internal class ProviderListBudgetsResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateParamsTest.kt index 4d36b5c6..eed179f4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.rerank -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RerankCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { RerankCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt index 6b2c5601..ad226780 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.rerank import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RerankCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val rerankCreateResponse = RerankCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ParamsTest.kt index 970a5278..5bbcf3e4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.rerank -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RerankCreateV1ParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { RerankCreateV1Params.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt index ef87fc15..b4ba98f7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1ResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.rerank import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RerankCreateV1ResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val rerankCreateV1Response = RerankCreateV1Response.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ParamsTest.kt index 94a205a2..28888dbf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.rerank -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RerankCreateV2ParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { RerankCreateV2Params.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt index a719b401..d553aa46 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2ResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.rerank import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RerankCreateV2ResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val rerankCreateV2Response = RerankCreateV2Response.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateParamsTest.kt index 7d3566b2..c2db1400 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.responses -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ResponseCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ResponseCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt index 47d67f7b..83bb8402 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.responses import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ResponseCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val responseCreateResponse = ResponseCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParamsTest.kt index 2ae648d5..d5fab129 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.responses import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ResponseDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ResponseDeleteParams.builder().responseId("response_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = ResponseDeleteParams.builder().responseId("response_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt index 55ac3be8..03e1465f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.responses import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ResponseDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val responseDeleteResponse = ResponseDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParamsTest.kt index 5e42754b..2364b14f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.responses import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ResponseRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ResponseRetrieveParams.builder().responseId("response_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = ResponseRetrieveParams.builder().responseId("response_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt index 0fd97b74..d316b55c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.responses import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ResponseRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val responseRetrieveResponse = ResponseRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParamsTest.kt index bd429d95..f6512b83 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.responses.inputitems import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InputItemListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { InputItemListParams.builder().responseId("response_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = InputItemListParams.builder().responseId("response_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt index ac662c11..b1207340 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.responses.inputitems import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class InputItemListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val inputItemListResponse = InputItemListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListParamsTest.kt index eecf0656..60e7efb7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.routes -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RouteListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { RouteListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt index 699f26f0..cd623fcf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/routes/RouteListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.routes import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RouteListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val routeListResponse = RouteListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveParamsTest.kt index 499a5424..7c62c2a7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.settings -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SettingRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SettingRetrieveParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt index a78d877b..76825035 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.settings import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SettingRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val settingRetrieveResponse = SettingRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParamsTest.kt index 88743c14..b69dba32 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.spend import ai.hanzo.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendCalculateSpendParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpendCalculateSpendParams.builder() @@ -20,7 +18,6 @@ internal class SpendCalculateSpendParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -38,7 +35,6 @@ internal class SpendCalculateSpendParamsTest { assertThat(body.model()).contains("model") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = SpendCalculateSpendParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt index a375ca83..915de553 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.spend import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendCalculateSpendResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val spendCalculateSpendResponse = SpendCalculateSpendResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsParamsTest.kt index 33b714e2..2362f26b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.spend import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendListLogsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpendListLogsParams.builder() @@ -21,7 +19,6 @@ internal class SpendListLogsParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -47,7 +44,6 @@ internal class SpendListLogsParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = SpendListLogsParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt index ce9441d4..75b74b77 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendListLogsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val spendListLogsResponse = @@ -64,7 +62,6 @@ internal class SpendListLogsResponseTest { assertThat(spendListLogsResponse.user()).contains("user") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsParamsTest.kt index 23d9563a..cd44e382 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.spend import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendListTagsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { SpendListTagsParams.builder().endDate("end_date").startDate("start_date").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -32,7 +29,6 @@ internal class SpendListTagsParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = SpendListTagsParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt index 05b2f238..806c5177 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class SpendListTagsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val spendListTagsResponse = @@ -64,7 +62,6 @@ internal class SpendListTagsResponseTest { assertThat(spendListTagsResponse.user()).contains("user") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt index f6acda31..02cdd315 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/BlockTeamRequestTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BlockTeamRequestTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val blockTeamRequest = BlockTeamRequest.builder().teamId("team_id").build() @@ -18,7 +16,6 @@ internal class BlockTeamRequestTest { assertThat(blockTeamRequest.teamId()).isEqualTo("team_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt index f3cd63e8..1190f8e4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/MemberTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class MemberTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val member = @@ -25,7 +23,6 @@ internal class MemberTest { assertThat(member.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberParamsTest.kt index 955a7617..18bd514f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.team import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamAddMemberParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamAddMemberParams.builder() @@ -26,7 +24,6 @@ internal class TeamAddMemberParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -62,7 +59,6 @@ internal class TeamAddMemberParamsTest { assertThat(body.maxBudgetInTeam()).contains(0.0) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt index 83160548..bb97cbf0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponseTest.kt @@ -8,12 +8,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamAddMemberResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamAddMemberResponse = @@ -218,7 +216,6 @@ internal class TeamAddMemberResponseTest { assertThat(teamAddMemberResponse.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockParamsTest.kt index e0415b2c..a787fdf3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.team import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamBlockParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamBlockParams.builder() @@ -16,7 +14,6 @@ internal class TeamBlockParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt index 6fef77a5..900b7782 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamBlockResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamBlockResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamBlockResponse = TeamBlockResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateParamsTest.kt index bbb05eda..df4620e8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateParamsTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.http.Headers import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamCreateParams.builder() @@ -41,7 +39,6 @@ internal class TeamCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -77,7 +74,6 @@ internal class TeamCreateParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = TeamCreateParams.builder().build() @@ -87,7 +83,6 @@ internal class TeamCreateParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -144,7 +139,6 @@ internal class TeamCreateParamsTest { assertThat(body.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = TeamCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt index 0ca83045..cfab4a64 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamCreateResponseTest.kt @@ -8,12 +8,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamCreateResponse = @@ -91,7 +89,6 @@ internal class TeamCreateResponseTest { assertThat(teamCreateResponse.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteParamsTest.kt index 44b12bc2..be6c9fce 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.http.Headers import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamDeleteParams.builder().llmChangedBy("llm-changed-by").addTeamId("string").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -27,7 +24,6 @@ internal class TeamDeleteParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = TeamDeleteParams.builder().addTeamId("string").build() @@ -37,7 +33,6 @@ internal class TeamDeleteParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -48,7 +43,6 @@ internal class TeamDeleteParamsTest { assertThat(body.teamIds()).containsExactly("string") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = TeamDeleteParams.builder().addTeamId("string").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt index de19c85c..8c8e4171 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamDeleteResponse = TeamDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParamsTest.kt index 0e918199..71dca50a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.team import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamDisableLoggingParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamDisableLoggingParams.builder().teamId("team_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = TeamDisableLoggingParams.builder().teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt index 906ac97f..985dc1e6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamDisableLoggingResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamDisableLoggingResponse = TeamDisableLoggingResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableParamsTest.kt index 7fcfb296..f04c557c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamListAvailableParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamListAvailableParams.builder() @@ -18,7 +16,6 @@ internal class TeamListAvailableParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -31,7 +28,6 @@ internal class TeamListAvailableParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = TeamListAvailableParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt index 456b5942..c3759d54 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamListAvailableResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamListAvailableResponse = TeamListAvailableResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListParamsTest.kt index d010361d..d7d8eb4b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamListParams.builder().organizationId("organization_id").userId("user_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -32,7 +29,6 @@ internal class TeamListParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = TeamListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt index a2aba8a0..90e3a78f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamListResponse = TeamListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParamsTest.kt index 4ee1cda4..0a843a12 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.team import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamRemoveMemberParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamRemoveMemberParams.builder() @@ -18,7 +16,6 @@ internal class TeamRemoveMemberParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -35,7 +32,6 @@ internal class TeamRemoveMemberParamsTest { assertThat(body.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = TeamRemoveMemberParams.builder().teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt index 7446376c..858ad4e9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamRemoveMemberResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamRemoveMemberResponse = TeamRemoveMemberResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoParamsTest.kt index 795cce57..ecece97a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamRetrieveInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamRetrieveInfoParams.builder().teamId("team_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = TeamRetrieveInfoParams.builder().teamId("team_id").build() @@ -25,7 +22,6 @@ internal class TeamRetrieveInfoParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("team_id", "team_id").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = TeamRetrieveInfoParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt index 73d33a46..0f199013 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamRetrieveInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamRetrieveInfoResponse = TeamRetrieveInfoResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockParamsTest.kt index 59beadf9..c5b7b7df 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.team import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamUnblockParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamUnblockParams.builder() @@ -16,7 +14,6 @@ internal class TeamUnblockParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt index 91964dfe..08a5a3e5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUnblockResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamUnblockResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamUnblockResponse = TeamUnblockResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParamsTest.kt index 90a75248..2245cb3d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParamsTest.kt @@ -3,12 +3,10 @@ package ai.hanzo.api.models.team import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamUpdateMemberParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamUpdateMemberParams.builder() @@ -20,7 +18,6 @@ internal class TeamUpdateMemberParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -41,7 +38,6 @@ internal class TeamUpdateMemberParamsTest { assertThat(body.userId()).contains("user_id") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = TeamUpdateMemberParams.builder().teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt index c795793a..3b03ef39 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponseTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamUpdateMemberResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamUpdateMemberResponse = @@ -27,7 +25,6 @@ internal class TeamUpdateMemberResponseTest { assertThat(teamUpdateMemberResponse.userEmail()).contains("user_email") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateParamsTest.kt index 78e21b3f..c97b6bc0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateParamsTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.http.Headers import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TeamUpdateParams.builder() @@ -32,7 +30,6 @@ internal class TeamUpdateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -59,7 +56,6 @@ internal class TeamUpdateParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = TeamUpdateParams.builder().teamId("team_id").build() @@ -69,7 +65,6 @@ internal class TeamUpdateParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -107,7 +102,6 @@ internal class TeamUpdateParamsTest { assertThat(body.tpmLimit()).contains(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = TeamUpdateParams.builder().teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt index c6029a44..4773758a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/TeamUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TeamUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val teamUpdateResponse = TeamUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParamsTest.kt index 782e5c57..5c9a42e9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.team.callback import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.http.Headers import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CallbackAddParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CallbackAddParams.builder() @@ -26,7 +24,6 @@ internal class CallbackAddParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = @@ -45,7 +42,6 @@ internal class CallbackAddParamsTest { assertThat(params._pathParam(1)).isEqualTo("") } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -67,7 +63,6 @@ internal class CallbackAddParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = @@ -86,7 +81,6 @@ internal class CallbackAddParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -114,7 +108,6 @@ internal class CallbackAddParamsTest { assertThat(body.callbackType()).contains(CallbackAddParams.CallbackType.SUCCESS) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt index f430cc63..edc30cc6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team.callback import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CallbackAddResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val callbackAddResponse = CallbackAddResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParamsTest.kt index 5b30ff16..e641f22e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.team.callback import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CallbackRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { CallbackRetrieveParams.builder().teamId("team_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = CallbackRetrieveParams.builder().teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt index cd2f6932..3d14b66b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team.callback import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class CallbackRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val callbackRetrieveResponse = CallbackRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddParamsTest.kt index 12a41cb9..403e32c3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.team.model import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelAddParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModelAddParams.builder().addModel("string").teamId("team_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = ModelAddParams.builder().addModel("string").teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt index 93b99c5e..c1ff5b1d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelAddResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team.model import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelAddResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelAddResponse = ModelAddResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParamsTest.kt index a7869584..ba26276c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.team.model import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelRemoveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ModelRemoveParams.builder().addModel("string").teamId("team_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = ModelRemoveParams.builder().addModel("string").teamId("team_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt index 3d6f3b40..73d24684 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.team.model import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ModelRemoveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val modelRemoveResponse = ModelRemoveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingParamsTest.kt index 744b0bff..0ae694f2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.test -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TestPingParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { TestPingParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt index 98dbd402..77772d9d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/test/TestPingResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.test import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class TestPingResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val testPingResponse = TestPingResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateParamsTest.kt index 6101ccb6..728247b1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateParamsTest.kt @@ -2,12 +2,10 @@ package ai.hanzo.api.models.threads -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ThreadCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ThreadCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt index f03dac73..9c4d8a89 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.threads import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ThreadCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val threadCreateResponse = ThreadCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParamsTest.kt index 4e0f5458..01feb786 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.threads import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ThreadRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { ThreadRetrieveParams.builder().threadId("thread_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = ThreadRetrieveParams.builder().threadId("thread_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt index c3cd9cf0..8c762b5e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.threads import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class ThreadRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val threadRetrieveResponse = ThreadRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParamsTest.kt index d60ed83a..224a02b0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.threads.messages import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class MessageCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { MessageCreateParams.builder().threadId("thread_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = MessageCreateParams.builder().threadId("thread_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt index cf972a08..f4047a4d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.threads.messages import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class MessageCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val messageCreateResponse = MessageCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListParamsTest.kt index c5ca6ec3..099a223b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.threads.messages import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class MessageListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { MessageListParams.builder().threadId("thread_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = MessageListParams.builder().threadId("thread_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt index cfd3a33c..6ad1ebe2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.threads.messages import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class MessageListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val messageListResponse = MessageListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParamsTest.kt index 33db7f2b..b0d2a442 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.threads.runs import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RunCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { RunCreateParams.builder().threadId("thread_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = RunCreateParams.builder().threadId("thread_id").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt index 25f45b17..2682070f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.threads.runs import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RunCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val runCreateResponse = RunCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateParamsTest.kt index 34bb4139..65263001 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UserCreateParams.builder() @@ -44,7 +42,6 @@ internal class UserCreateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -110,7 +107,6 @@ internal class UserCreateParamsTest { assertThat(body.userRole()).contains(UserCreateParams.UserRole.PROXY_ADMIN) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = UserCreateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt index 973b8791..e72a181f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserCreateResponseTest.kt @@ -8,12 +8,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val userCreateResponse = @@ -103,7 +101,6 @@ internal class UserCreateResponseTest { assertThat(userCreateResponse.userRole()).contains(UserCreateResponse.UserRole.PROXY_ADMIN) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteParamsTest.kt index 612b5803..b746d314 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.http.Headers import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UserDeleteParams.builder().llmChangedBy("llm-changed-by").addUserId("string").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun headers() { val params = @@ -27,7 +24,6 @@ internal class UserDeleteParamsTest { .isEqualTo(Headers.builder().put("llm-changed-by", "llm-changed-by").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun headersWithoutOptionalFields() { val params = UserDeleteParams.builder().addUserId("string").build() @@ -37,7 +33,6 @@ internal class UserDeleteParamsTest { assertThat(headers).isEqualTo(Headers.builder().build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -48,7 +43,6 @@ internal class UserDeleteParamsTest { assertThat(body.userIds()).containsExactly("string") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = UserDeleteParams.builder().addUserId("string").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt index 22ed12f7..6a4b3faa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val userDeleteResponse = UserDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListParamsTest.kt index 4e09ddd9..e3417162 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserListParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UserListParams.builder().page(1L).pageSize(1L).role("role").userIds("user_ids").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -34,7 +31,6 @@ internal class UserListParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = UserListParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt index c00be84f..f96c2c54 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserListResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val userListResponse = UserListResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoParamsTest.kt index 04c178c0..b59ce709 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserRetrieveInfoParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UserRetrieveInfoParams.builder().userId("user_id").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = UserRetrieveInfoParams.builder().userId("user_id").build() @@ -25,7 +22,6 @@ internal class UserRetrieveInfoParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().put("user_id", "user_id").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = UserRetrieveInfoParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt index f80f1a62..58ecbe55 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserRetrieveInfoResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val userRetrieveInfoResponse = UserRetrieveInfoResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateParamsTest.kt index 463a8dea..71f6c6d6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UserUpdateParams.builder() @@ -41,7 +39,6 @@ internal class UserUpdateParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -101,7 +98,6 @@ internal class UserUpdateParamsTest { assertThat(body.userRole()).contains(UserUpdateParams.UserRole.PROXY_ADMIN) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = UserUpdateParams.builder().build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt index c0591613..ac1ad724 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.user import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UserUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val userUpdateResponse = UserUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsParamsTest.kt index 4debbdac..755effaa 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsParamsTest.kt @@ -4,18 +4,15 @@ package ai.hanzo.api.models.utils import ai.hanzo.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UtilGetSupportedOpenAIParamsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UtilGetSupportedOpenAIParamsParams.builder().model("model").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = UtilGetSupportedOpenAIParamsParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt index 4a07fc41..a9f3923b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponseTest.kt @@ -5,19 +5,16 @@ package ai.hanzo.api.models.utils import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UtilGetSupportedOpenAIParamsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val utilGetSupportedOpenAIParamsResponse = UtilGetSupportedOpenAIParamsResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParamsTest.kt index aa619046..1b982d1e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParamsTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.utils import ai.hanzo.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UtilTokenCounterParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UtilTokenCounterParams.builder() @@ -20,7 +18,6 @@ internal class UtilTokenCounterParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -38,7 +35,6 @@ internal class UtilTokenCounterParamsTest { assertThat(body.prompt()).contains("prompt") } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = UtilTokenCounterParams.builder().model("model").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt index 40869aaa..7a57622e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponseTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.models.utils import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UtilTokenCounterResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val utilTokenCounterResponse = @@ -27,7 +25,6 @@ internal class UtilTokenCounterResponseTest { assertThat(utilTokenCounterResponse.totalTokens()).isEqualTo(0L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParamsTest.kt index af9754d4..9a166939 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParamsTest.kt @@ -4,12 +4,10 @@ package ai.hanzo.api.models.utils import ai.hanzo.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UtilTransformRequestParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { UtilTransformRequestParams.builder() @@ -18,7 +16,6 @@ internal class UtilTransformRequestParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt index 7fa174c8..7a57d82c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponseTest.kt @@ -6,12 +6,10 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class UtilTransformRequestResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val utilTransformRequestResponse = @@ -31,7 +29,6 @@ internal class UtilTransformRequestResponseTest { .isEqualTo(JsonValue.from(mapOf())) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParamsTest.kt index d6de9be4..45e52d63 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.vertexai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiCreateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { VertexAiCreateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = VertexAiCreateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt index c662a67d..05bd2860 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiCreateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val vertexAiCreateResponse = VertexAiCreateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParamsTest.kt index e0678ec7..0fcd32e7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.vertexai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiDeleteParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { VertexAiDeleteParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = VertexAiDeleteParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt index cf87e634..c5a0001c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiDeleteResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val vertexAiDeleteResponse = VertexAiDeleteResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParamsTest.kt index dfa8b2a4..d71942b2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.vertexai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiPatchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { VertexAiPatchParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = VertexAiPatchParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt index 9168b15f..f863d36e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiPatchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val vertexAiPatchResponse = VertexAiPatchResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParamsTest.kt index effa231b..89fe97a5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.vertexai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { VertexAiRetrieveParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = VertexAiRetrieveParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt index 352824d2..a92c9bc9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val vertexAiRetrieveResponse = VertexAiRetrieveResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParamsTest.kt index cff5990e..7787142e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateParamsTest.kt @@ -3,18 +3,15 @@ package ai.hanzo.api.models.vertexai import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiUpdateParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { VertexAiUpdateParams.builder().endpoint("endpoint").build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun pathParams() { val params = VertexAiUpdateParams.builder().endpoint("endpoint").build() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt index e94b83c6..0761115e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponseTest.kt @@ -5,18 +5,15 @@ package ai.hanzo.api.models.vertexai import ai.hanzo.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class VertexAiUpdateResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val vertexAiUpdateResponse = VertexAiUpdateResponse.builder().build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt index 5d64ae50..1801146a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ErrorHandlingTest.kt @@ -25,7 +25,6 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.parallel.ResourceLock @@ -58,7 +57,6 @@ internal class ErrorHandlingTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun clientGetHome400() { val hanzoClient = client @@ -76,7 +74,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome400WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome401() { val hanzoClient = client @@ -94,7 +108,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome401WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome403() { val hanzoClient = client @@ -112,7 +142,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome403WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome404() { val hanzoClient = client @@ -130,7 +176,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome404WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome422() { val hanzoClient = client @@ -148,7 +210,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome422WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome429() { val hanzoClient = client @@ -166,7 +244,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome429WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome500() { val hanzoClient = client @@ -184,7 +278,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome500WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHome999() { val hanzoClient = client @@ -202,7 +312,23 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") + @Test + fun clientGetHome999WithRawResponse() { + val hanzoClient = client.withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { hanzoClient.getHome() } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test fun clientGetHomeInvalidJsonBody() { val hanzoClient = client diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt index 832da4d1..c62c7054 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/ServiceParamsTest.kt @@ -34,7 +34,7 @@ internal class ServiceParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun getHome() { val hanzoClient = client diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncTest.kt index f8bb0adb..d0e1322a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ActiveServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ActiveServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listCallbacks() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt index 4a8786a1..524ed9b8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AddServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun addAllowedIp() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt index 6b1066e9..feeaca00 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AnthropicServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AnthropicServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class AnthropicServiceAsyncTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class AnthropicServiceAsyncTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class AnthropicServiceAsyncTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class AnthropicServiceAsyncTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun modify() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt index ebaeb075..0c46e884 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssemblyaiServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AssemblyaiServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class AssemblyaiServiceAsyncTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class AssemblyaiServiceAsyncTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class AssemblyaiServiceAsyncTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class AssemblyaiServiceAsyncTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt index afe1334c..030d7b89 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AssistantServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AssistantServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class AssistantServiceAsyncTest { assistant.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -43,7 +43,7 @@ internal class AssistantServiceAsyncTest { assistants.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt index 58613f1f..e55ceddd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AzureServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AzureServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class AzureServiceAsyncTest { azure.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -43,7 +43,7 @@ internal class AzureServiceAsyncTest { azure.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -59,7 +59,7 @@ internal class AzureServiceAsyncTest { azure.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun call() { val client = @@ -75,7 +75,7 @@ internal class AzureServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt index a4d875e2..4ddab244 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BatchServiceAsyncTest.kt @@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class BatchServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -34,7 +34,7 @@ internal class BatchServiceAsyncTest { batch.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -53,7 +53,7 @@ internal class BatchServiceAsyncTest { batch.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -72,7 +72,7 @@ internal class BatchServiceAsyncTest { batches.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun cancelWithProvider() { val client = @@ -94,7 +94,7 @@ internal class BatchServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createWithProvider() { val client = @@ -110,7 +110,7 @@ internal class BatchServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listWithProvider() { val client = @@ -133,7 +133,7 @@ internal class BatchServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveWithProvider() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt index d4ab0f1a..0b11119c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BedrockServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class BedrockServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class BedrockServiceAsyncTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class BedrockServiceAsyncTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class BedrockServiceAsyncTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class BedrockServiceAsyncTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt index 0a5f7848..c79fe28b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt @@ -18,7 +18,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class BudgetServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -64,7 +64,7 @@ internal class BudgetServiceAsyncTest { budget.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -110,7 +110,7 @@ internal class BudgetServiceAsyncTest { budget.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -126,7 +126,7 @@ internal class BudgetServiceAsyncTest { budgets.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -142,7 +142,7 @@ internal class BudgetServiceAsyncTest { budget.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun info() { val client = @@ -159,7 +159,7 @@ internal class BudgetServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun settings() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncTest.kt index 634ee289..06c36005 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CacheServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CacheServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -27,7 +27,7 @@ internal class CacheServiceAsyncTest { cache.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun flushAll() { val client = @@ -43,7 +43,7 @@ internal class CacheServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun ping() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt index edf1cf7e..aea7498d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CohereServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CohereServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class CohereServiceAsyncTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class CohereServiceAsyncTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class CohereServiceAsyncTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class CohereServiceAsyncTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun modify() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncTest.kt index d44ae201..f7dda9f8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CompletionServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CompletionServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt index ade95815..866575ce 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CredentialServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CredentialServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -37,7 +37,7 @@ internal class CredentialServiceAsyncTest { credential.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -53,7 +53,7 @@ internal class CredentialServiceAsyncTest { credentials.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt index 76e3cf70..4287cf50 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt @@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CustomerServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -66,7 +66,7 @@ internal class CustomerServiceAsyncTest { customer.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -93,7 +93,7 @@ internal class CustomerServiceAsyncTest { customer.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -109,7 +109,7 @@ internal class CustomerServiceAsyncTest { customers.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -126,7 +126,7 @@ internal class CustomerServiceAsyncTest { customer.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun block() { val client = @@ -147,7 +147,7 @@ internal class CustomerServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = @@ -166,7 +166,7 @@ internal class CustomerServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun unblock() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt index 59a94df5..682e7e1c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class DeleteServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createAllowedIp() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncTest.kt index e493c4ae..33965398 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EmbeddingServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EmbeddingServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt index a53640b0..e596bce7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EngineServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EngineServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = @@ -27,7 +27,7 @@ internal class EngineServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun embed() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt index 068672da..af297997 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/EuAssemblyaiServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EuAssemblyaiServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class EuAssemblyaiServiceAsyncTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class EuAssemblyaiServiceAsyncTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class EuAssemblyaiServiceAsyncTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class EuAssemblyaiServiceAsyncTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt index 56a33885..bdb33fbf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/FileServiceAsyncTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class FileServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -39,7 +39,7 @@ internal class FileServiceAsyncTest { file.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -58,7 +58,7 @@ internal class FileServiceAsyncTest { file.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -77,7 +77,7 @@ internal class FileServiceAsyncTest { files.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt index 86243cb0..50281a60 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GeminiServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class GeminiServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class GeminiServiceAsyncTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class GeminiServiceAsyncTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class GeminiServiceAsyncTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class GeminiServiceAsyncTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt index 886effd0..0501d3a9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class GuardrailServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncTest.kt index 13aff7f0..af8b5fa9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/HealthServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class HealthServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkAll() { val client = @@ -30,7 +30,7 @@ internal class HealthServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkLiveliness() { val client = @@ -46,7 +46,7 @@ internal class HealthServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkLiveness() { val client = @@ -62,7 +62,7 @@ internal class HealthServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkReadiness() { val client = @@ -78,7 +78,7 @@ internal class HealthServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkServices() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt index 202fb183..eb51ee87 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/KeyServiceAsyncTest.kt @@ -24,7 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class KeyServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -72,7 +72,7 @@ internal class KeyServiceAsyncTest { key.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -100,7 +100,7 @@ internal class KeyServiceAsyncTest { keys.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -123,7 +123,7 @@ internal class KeyServiceAsyncTest { key.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun block() { val client = @@ -146,7 +146,7 @@ internal class KeyServiceAsyncTest { unwrappedResponse?.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkHealth() { val client = @@ -162,7 +162,7 @@ internal class KeyServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun generate() { val client = @@ -210,7 +210,7 @@ internal class KeyServiceAsyncTest { generateKeyResponse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun regenerateByKey() { val client = @@ -265,7 +265,7 @@ internal class KeyServiceAsyncTest { unwrappedGenerateKeyResponse?.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = @@ -282,7 +282,7 @@ internal class KeyServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun unblock() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt index 953b2427..133b62f2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/LangfuseServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class LangfuseServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class LangfuseServiceAsyncTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class LangfuseServiceAsyncTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class LangfuseServiceAsyncTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class LangfuseServiceAsyncTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncTest.kt index 71f1364a..deee8145 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModelGroupServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncTest.kt index 28946e50..9513363d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModelServiceAsyncTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModelServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -86,7 +86,7 @@ internal class ModelServiceAsyncTest { model.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncTest.kt index afb358a7..9d95b402 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ModerationServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModerationServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt index 0d4b5d03..be538ada 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OpenAIServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class OpenAIServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class OpenAIServiceAsyncTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class OpenAIServiceAsyncTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class OpenAIServiceAsyncTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class OpenAIServiceAsyncTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncTest.kt index 66f20554..8be09fc2 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsyncTest.kt @@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class OrganizationServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -51,7 +51,7 @@ internal class OrganizationServiceAsyncTest { organization.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -78,7 +78,7 @@ internal class OrganizationServiceAsyncTest { organization.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -94,7 +94,7 @@ internal class OrganizationServiceAsyncTest { organizations.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -113,7 +113,7 @@ internal class OrganizationServiceAsyncTest { organizations.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun addMember() { val client = @@ -144,7 +144,7 @@ internal class OrganizationServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun deleteMember() { val client = @@ -167,7 +167,7 @@ internal class OrganizationServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun updateMember() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncTest.kt index 68b516ae..174e29e3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ProviderServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ProviderServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listBudgets() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncTest.kt index 8b286652..f5060672 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RerankServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RerankServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class RerankServiceAsyncTest { rerank.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createV1() { val client = @@ -43,7 +43,7 @@ internal class RerankServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createV2() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt index 81f0ea4f..dcbb55e0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ResponseServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ResponseServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class ResponseServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class ResponseServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt index 5612f100..e787ad49 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/RouteServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RouteServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncTest.kt index f78920b1..cb3eae2b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SettingServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SettingServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncTest.kt index bd0417e2..5c620845 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/SpendServiceAsyncTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SpendServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun calculateSpend() { val client = @@ -38,7 +38,7 @@ internal class SpendServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listLogs() { val client = @@ -63,7 +63,7 @@ internal class SpendServiceAsyncTest { response.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listTags() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt index ff05440b..db14ee9a 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt @@ -25,7 +25,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TeamServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -68,7 +68,7 @@ internal class TeamServiceAsyncTest { team.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -102,7 +102,7 @@ internal class TeamServiceAsyncTest { team.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -121,7 +121,7 @@ internal class TeamServiceAsyncTest { teams.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -143,7 +143,7 @@ internal class TeamServiceAsyncTest { team.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun addMember() { val client = @@ -174,7 +174,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun block() { val client = @@ -195,7 +195,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun disableLogging() { val client = @@ -211,7 +211,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listAvailable() { val client = @@ -232,7 +232,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun removeMember() { val client = @@ -255,7 +255,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = @@ -274,7 +274,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun unblock() { val client = @@ -295,7 +295,7 @@ internal class TeamServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun updateMember() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TestServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TestServiceAsyncTest.kt index c3b52868..9143c0a1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TestServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TestServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TestServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun ping() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt index f9080618..be20e904 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/ThreadServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ThreadServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class ThreadServiceAsyncTest { thread.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt index 76e3e3fe..e81dfd08 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UserServiceAsyncTest.kt @@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UserServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -64,7 +64,7 @@ internal class UserServiceAsyncTest { user.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -108,7 +108,7 @@ internal class UserServiceAsyncTest { user.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -132,7 +132,7 @@ internal class UserServiceAsyncTest { users.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -154,7 +154,7 @@ internal class UserServiceAsyncTest { user.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncTest.kt index 69c58614..75e3dc45 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/UtilServiceAsyncTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UtilServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun getSupportedOpenAIParams() { val client = @@ -34,7 +34,7 @@ internal class UtilServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun tokenCounter() { val client = @@ -57,7 +57,7 @@ internal class UtilServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun transformRequest() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt index 4b1800c5..49f10488 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/VertexAiServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class VertexAiServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class VertexAiServiceAsyncTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -43,7 +43,7 @@ internal class VertexAiServiceAsyncTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class VertexAiServiceAsyncTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -75,7 +75,7 @@ internal class VertexAiServiceAsyncTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncTest.kt index 8ed8cd1b..c105dbab 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/SpeechServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SpeechServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt index 4668c528..643edab4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/audio/TranscriptionServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TranscriptionServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncTest.kt index 1b473108..3125a11c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/batches/CancelServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CancelServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun cancel() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncTest.kt index 7268ac94..f0f6c830 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/cache/RediServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RediServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncTest.kt index 9a5f6ab1..b3aa5289 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/chat/CompletionServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CompletionServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt index 84ae6050..6f52f260 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class PassThroughEndpointServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -43,7 +43,7 @@ internal class PassThroughEndpointServiceAsyncTest { passThroughEndpoint.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -59,7 +59,7 @@ internal class PassThroughEndpointServiceAsyncTest { passThroughEndpoint.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -78,7 +78,7 @@ internal class PassThroughEndpointServiceAsyncTest { passThroughEndpointResponse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt index f32ed6e1..5f2d58c4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/engines/ChatServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ChatServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncTest.kt index 9db38e06..5e37645e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/files/ContentServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ContentServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt index 12c6dc59..e3c9c7ec 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/JobServiceAsyncTest.kt @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class JobServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -48,7 +48,7 @@ internal class JobServiceAsyncTest { job.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -70,7 +70,7 @@ internal class JobServiceAsyncTest { job.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt index 0707d0f8..185e081d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/finetuning/jobs/CancelServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CancelServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncTest.kt index 0c0149c7..c85bf11c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/global/SpendServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SpendServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listTags() { val client = @@ -36,7 +36,7 @@ internal class SpendServiceAsyncTest { response.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun reset() { val client = @@ -52,7 +52,7 @@ internal class SpendServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveReport() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncTest.kt index 755e59eb..5505ea42 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/images/GenerationServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class GenerationServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt index 0ad09f74..50c37789 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class InfoServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt index 04bd31cf..e8e9210e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt @@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UpdateServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun full() { val client = @@ -91,7 +91,7 @@ internal class UpdateServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun partial() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt index 81eea156..7e0a6f37 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/DeploymentServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class DeploymentServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = @@ -27,7 +27,7 @@ internal class DeploymentServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun embed() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt index d2fff48f..a54544f0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/openai/deployments/ChatServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ChatServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncTest.kt index 96591b9b..862e1583 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/organization/InfoServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class InfoServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -32,7 +32,7 @@ internal class InfoServiceAsyncTest { info.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun deprecated() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt index d4fb7455..426a57c5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/responses/InputItemServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class InputItemServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt index 3570864e..23ba7243 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/CallbackServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CallbackServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -29,7 +29,7 @@ internal class CallbackServiceAsyncTest { callback.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun add() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncTest.kt index 628962cc..de2c7086 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/team/ModelServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModelServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun add() { val client = @@ -32,7 +32,7 @@ internal class ModelServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun remove() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt index 30da7509..caf94c12 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/MessageServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class MessageServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -27,7 +27,7 @@ internal class MessageServiceAsyncTest { message.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt index 8c51a2f1..7156e252 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/threads/RunServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RunServiceAsyncTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ActiveServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ActiveServiceTest.kt index 261dad76..f4d5cc01 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ActiveServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ActiveServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ActiveServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listCallbacks() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt index ba84cc1c..f290352c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AddServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun addAllowedIp() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt index a2f0881d..13152504 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AnthropicServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AnthropicServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class AnthropicServiceTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class AnthropicServiceTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class AnthropicServiceTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class AnthropicServiceTest { anthropic.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun modify() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt index f3ee773e..5682d1cd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssemblyaiServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AssemblyaiServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class AssemblyaiServiceTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class AssemblyaiServiceTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class AssemblyaiServiceTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class AssemblyaiServiceTest { assemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt index a16b76a9..c5a43832 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AssistantServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AssistantServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class AssistantServiceTest { assistant.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -41,7 +41,7 @@ internal class AssistantServiceTest { assistants.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt index b02675ed..024f1bcf 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AzureServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AzureServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class AzureServiceTest { azure.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -41,7 +41,7 @@ internal class AzureServiceTest { azure.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -56,7 +56,7 @@ internal class AzureServiceTest { azure.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun call() { val client = @@ -71,7 +71,7 @@ internal class AzureServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt index 6e0a5bc2..8dc06ca6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BatchServiceTest.kt @@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class BatchServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -32,7 +32,7 @@ internal class BatchServiceTest { batch.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -50,7 +50,7 @@ internal class BatchServiceTest { batch.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -68,7 +68,7 @@ internal class BatchServiceTest { batches.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun cancelWithProvider() { val client = @@ -89,7 +89,7 @@ internal class BatchServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createWithProvider() { val client = @@ -104,7 +104,7 @@ internal class BatchServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listWithProvider() { val client = @@ -126,7 +126,7 @@ internal class BatchServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveWithProvider() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt index adb50b90..5900b8be 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BedrockServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class BedrockServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class BedrockServiceTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class BedrockServiceTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class BedrockServiceTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class BedrockServiceTest { bedrock.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt index 45aee1e2..25f94467 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt @@ -18,7 +18,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class BudgetServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -63,7 +63,7 @@ internal class BudgetServiceTest { budget.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -108,7 +108,7 @@ internal class BudgetServiceTest { budget.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -123,7 +123,7 @@ internal class BudgetServiceTest { budgets.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -138,7 +138,7 @@ internal class BudgetServiceTest { budget.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun info() { val client = @@ -153,7 +153,7 @@ internal class BudgetServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun settings() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CacheServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CacheServiceTest.kt index 848fcf5c..008c0eca 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CacheServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CacheServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CacheServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -26,7 +26,7 @@ internal class CacheServiceTest { cache.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun flushAll() { val client = @@ -41,7 +41,7 @@ internal class CacheServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun ping() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt index e866211f..9281ca0e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CohereServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CohereServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class CohereServiceTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class CohereServiceTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class CohereServiceTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class CohereServiceTest { cohere.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun modify() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CompletionServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CompletionServiceTest.kt index 6f3dcc3e..e28d49af 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CompletionServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CompletionServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CompletionServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt index 9fb7da90..0b38b57c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CredentialServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CredentialServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -36,7 +36,7 @@ internal class CredentialServiceTest { credential.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -51,7 +51,7 @@ internal class CredentialServiceTest { credentials.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt index ace3d271..acefc54c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt @@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CustomerServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -65,7 +65,7 @@ internal class CustomerServiceTest { customer.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -91,7 +91,7 @@ internal class CustomerServiceTest { customer.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -106,7 +106,7 @@ internal class CustomerServiceTest { customers.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -122,7 +122,7 @@ internal class CustomerServiceTest { customer.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun block() { val client = @@ -142,7 +142,7 @@ internal class CustomerServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = @@ -160,7 +160,7 @@ internal class CustomerServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun unblock() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt index 8055f954..7a49258f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class DeleteServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createAllowedIp() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceTest.kt index 7c28b74e..55605c8d 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EmbeddingServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EmbeddingServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt index 126fa03d..cba663c6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EngineServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EngineServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = @@ -26,7 +26,7 @@ internal class EngineServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun embed() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt index 917c4c10..57f9f5b3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/EuAssemblyaiServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EuAssemblyaiServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class EuAssemblyaiServiceTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class EuAssemblyaiServiceTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class EuAssemblyaiServiceTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class EuAssemblyaiServiceTest { euAssemblyai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt index 9d3e836c..1f7fe806 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/FileServiceTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class FileServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -38,7 +38,7 @@ internal class FileServiceTest { file.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -56,7 +56,7 @@ internal class FileServiceTest { file.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -74,7 +74,7 @@ internal class FileServiceTest { files.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt index bf2bbd32..97c9c97c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GeminiServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class GeminiServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class GeminiServiceTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class GeminiServiceTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class GeminiServiceTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class GeminiServiceTest { gemini.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt index 9ea0a3a3..07fd2788 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/GuardrailServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class GuardrailServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/HealthServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/HealthServiceTest.kt index def78035..cf9a94f5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/HealthServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/HealthServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class HealthServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkAll() { val client = @@ -28,7 +28,7 @@ internal class HealthServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkLiveliness() { val client = @@ -43,7 +43,7 @@ internal class HealthServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkLiveness() { val client = @@ -58,7 +58,7 @@ internal class HealthServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkReadiness() { val client = @@ -73,7 +73,7 @@ internal class HealthServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkServices() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt index 057af0da..c942bbce 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/KeyServiceTest.kt @@ -24,7 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class KeyServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -71,7 +71,7 @@ internal class KeyServiceTest { key.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -98,7 +98,7 @@ internal class KeyServiceTest { keys.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -120,7 +120,7 @@ internal class KeyServiceTest { key.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun block() { val client = @@ -142,7 +142,7 @@ internal class KeyServiceTest { unwrappedResponse?.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun checkHealth() { val client = @@ -157,7 +157,7 @@ internal class KeyServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun generate() { val client = @@ -204,7 +204,7 @@ internal class KeyServiceTest { generateKeyResponse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun regenerateByKey() { val client = @@ -258,7 +258,7 @@ internal class KeyServiceTest { unwrappedGenerateKeyResponse?.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = @@ -273,7 +273,7 @@ internal class KeyServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun unblock() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt index 910c1aa5..58893642 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/LangfuseServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class LangfuseServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class LangfuseServiceTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class LangfuseServiceTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class LangfuseServiceTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class LangfuseServiceTest { langfuse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceTest.kt index aabb40b3..cd621ed8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelGroupServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModelGroupServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelServiceTest.kt index 62fcb7ef..50248f37 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModelServiceTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModelServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -85,7 +85,7 @@ internal class ModelServiceTest { model.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModerationServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModerationServiceTest.kt index 9aee8863..80625dd6 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModerationServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ModerationServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModerationServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt index 15af4bbb..b90e6923 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OpenAIServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class OpenAIServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class OpenAIServiceTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class OpenAIServiceTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class OpenAIServiceTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class OpenAIServiceTest { openai.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceTest.kt index 57b60206..bfde5530 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/OrganizationServiceTest.kt @@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class OrganizationServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -50,7 +50,7 @@ internal class OrganizationServiceTest { organization.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -76,7 +76,7 @@ internal class OrganizationServiceTest { organization.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -91,7 +91,7 @@ internal class OrganizationServiceTest { organizations.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -109,7 +109,7 @@ internal class OrganizationServiceTest { organizations.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun addMember() { val client = @@ -139,7 +139,7 @@ internal class OrganizationServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun deleteMember() { val client = @@ -161,7 +161,7 @@ internal class OrganizationServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun updateMember() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ProviderServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ProviderServiceTest.kt index 119539a5..9c398f58 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ProviderServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ProviderServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ProviderServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listBudgets() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RerankServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RerankServiceTest.kt index 92848609..808cdab5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RerankServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RerankServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RerankServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class RerankServiceTest { rerank.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createV1() { val client = @@ -41,7 +41,7 @@ internal class RerankServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun createV2() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt index e43d407d..fea4cfbe 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ResponseServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ResponseServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class ResponseServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class ResponseServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt index b69fe357..cef03ac8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/RouteServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RouteServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SettingServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SettingServiceTest.kt index 1fe7ece8..69787b3f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SettingServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SettingServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SettingServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SpendServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SpendServiceTest.kt index 8d4f4170..cb978382 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SpendServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/SpendServiceTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SpendServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun calculateSpend() { val client = @@ -37,7 +37,7 @@ internal class SpendServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listLogs() { val client = @@ -61,7 +61,7 @@ internal class SpendServiceTest { response.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listTags() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt index eaf6e536..0b2a42ed 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt @@ -25,7 +25,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TeamServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -67,7 +67,7 @@ internal class TeamServiceTest { team.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -100,7 +100,7 @@ internal class TeamServiceTest { team.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -118,7 +118,7 @@ internal class TeamServiceTest { teams.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -139,7 +139,7 @@ internal class TeamServiceTest { team.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun addMember() { val client = @@ -169,7 +169,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun block() { val client = @@ -189,7 +189,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun disableLogging() { val client = @@ -204,7 +204,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listAvailable() { val client = @@ -224,7 +224,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun removeMember() { val client = @@ -246,7 +246,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = @@ -262,7 +262,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun unblock() { val client = @@ -282,7 +282,7 @@ internal class TeamServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun updateMember() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TestServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TestServiceTest.kt index 678da004..8f185dfc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TestServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TestServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TestServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun ping() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt index 415fe17e..4d3559c3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/ThreadServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ThreadServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class ThreadServiceTest { thread.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt index 9d31c8c6..a4218406 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UserServiceTest.kt @@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UserServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -63,7 +63,7 @@ internal class UserServiceTest { user.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -106,7 +106,7 @@ internal class UserServiceTest { user.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -129,7 +129,7 @@ internal class UserServiceTest { users.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -150,7 +150,7 @@ internal class UserServiceTest { user.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UtilServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UtilServiceTest.kt index e66b2cac..2c112453 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UtilServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/UtilServiceTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UtilServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun getSupportedOpenAIParams() { val client = @@ -33,7 +33,7 @@ internal class UtilServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun tokenCounter() { val client = @@ -55,7 +55,7 @@ internal class UtilServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun transformRequest() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt index 776cb3f3..72bed8ed 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/VertexAiServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class VertexAiServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class VertexAiServiceTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -41,7 +41,7 @@ internal class VertexAiServiceTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -56,7 +56,7 @@ internal class VertexAiServiceTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = @@ -71,7 +71,7 @@ internal class VertexAiServiceTest { vertexAi.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun patch() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceTest.kt index 3bfead86..3c30d8a0 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/SpeechServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SpeechServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt index 4bfcd79f..3bb4be43 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/audio/TranscriptionServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TranscriptionServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceTest.kt index c81a6af8..c34d1c59 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/batches/CancelServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CancelServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun cancel() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceTest.kt index 41fc84a2..8a24ff00 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/cache/RediServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RediServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveInfo() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceTest.kt index ca87583e..20e2b0c1 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/chat/CompletionServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CompletionServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt index a348d1d0..88e62808 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class PassThroughEndpointServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -42,7 +42,7 @@ internal class PassThroughEndpointServiceTest { passThroughEndpoint.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun update() { val client = @@ -57,7 +57,7 @@ internal class PassThroughEndpointServiceTest { passThroughEndpoint.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = @@ -75,7 +75,7 @@ internal class PassThroughEndpointServiceTest { passThroughEndpointResponse.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun delete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt index 5b6972b4..c5562b4e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/engines/ChatServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ChatServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceTest.kt index 568efccd..35dac0ac 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/files/ContentServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ContentServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt index 7daf2174..eb28eb9f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/JobServiceTest.kt @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class JobServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -47,7 +47,7 @@ internal class JobServiceTest { job.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -68,7 +68,7 @@ internal class JobServiceTest { job.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt index 09adb6ef..9b59392f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/finetuning/jobs/CancelServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CancelServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceTest.kt index cc9ad8a1..b4dd16dc 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/global/SpendServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SpendServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun listTags() { val client = @@ -35,7 +35,7 @@ internal class SpendServiceTest { response.forEach { it.validate() } } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun reset() { val client = @@ -50,7 +50,7 @@ internal class SpendServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieveReport() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceTest.kt index 0684530e..75b59cf5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/images/GenerationServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class GenerationServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt index b356114e..48d30a46 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/InfoServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class InfoServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt index d6b95fdf..47fb79d5 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt @@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UpdateServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun full() { val client = @@ -90,7 +90,7 @@ internal class UpdateServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun partial() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt index 28a39744..6d77e9b3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/DeploymentServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class DeploymentServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = @@ -26,7 +26,7 @@ internal class DeploymentServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun embed() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt index 29049246..5a4db7af 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/openai/deployments/ChatServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ChatServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun complete() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceTest.kt index 17bb0b5a..ad07e9f3 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/organization/InfoServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class InfoServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -31,7 +31,7 @@ internal class InfoServiceTest { info.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun deprecated() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt index b01fd296..0f522532 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/responses/InputItemServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class InputItemServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt index 33074793..76e316df 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/CallbackServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class CallbackServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun retrieve() { val client = @@ -28,7 +28,7 @@ internal class CallbackServiceTest { callback.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun add() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceTest.kt index 5deeb0ed..6f6a5726 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/team/ModelServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ModelServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun add() { val client = @@ -29,7 +29,7 @@ internal class ModelServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun remove() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt index b090729b..c66ccfd4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/MessageServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class MessageServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = @@ -26,7 +26,7 @@ internal class MessageServiceTest { message.validate() } - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun list() { val client = diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt index 05be8af2..d733e03f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/threads/RunServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class RunServiceTest { - @Disabled("skipped: tests are disabled for the time being") + @Disabled("Prism tests are disabled") @Test fun create() { val client = diff --git a/hanzo-java-example/build.gradle.kts b/hanzo-java-example/build.gradle.kts index e1e4a27d..90a65c3c 100644 --- a/hanzo-java-example/build.gradle.kts +++ b/hanzo-java-example/build.gradle.kts @@ -18,7 +18,7 @@ tasks.withType().configureEach { application { // Use `./gradlew :hanzo-java-example:run` to run `Main` - // Use `./gradlew :hanzo-java-example:run -Dexample=Something` to run `SomethingExample` + // Use `./gradlew :hanzo-java-example:run -Pexample=Something` to run `SomethingExample` mainClass = "ai.hanzo.api.example.${ if (project.hasProperty("example")) "${project.property("example")}Example" diff --git a/hanzo-java-proguard-test/build.gradle.kts b/hanzo-java-proguard-test/build.gradle.kts new file mode 100644 index 00000000..5999028b --- /dev/null +++ b/hanzo-java-proguard-test/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("hanzo.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + repositories { + google() + } + + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") + } +} + +dependencies { + testImplementation(project(":hanzo-java")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("ai.hanzo.api.proguard.ProGuardCompatibilityTest") + classpath = files(proguardJarPath) +} + +val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar" +val r8Jar by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.android.tools.r8.R8") + classpath = buildscript.configurations["classpath"] + + args = listOf( + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../hanzo-java-core/src/main/resources/META-INF/proguard/hanzo-java-core.pro", + "--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt", + tasks.shadowJar.get().archiveFile.get().asFile.absolutePath, + ) +} + +val testR8 by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(r8Jar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("ai.hanzo.api.proguard.ProGuardCompatibilityTest") + classpath = files(r8JarPath) +} + +tasks.test { + dependsOn(testProGuard) + dependsOn(testR8) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/hanzo-java-proguard-test/src/test/kotlin/ai/hanzo/api/proguard/ProGuardCompatibilityTest.kt b/hanzo-java-proguard-test/src/test/kotlin/ai/hanzo/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 00000000..e248a7c6 --- /dev/null +++ b/hanzo-java-proguard-test/src/test/kotlin/ai/hanzo/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.hanzo.api.proguard + +import ai.hanzo.api.client.okhttp.HanzoOkHttpClient +import ai.hanzo.api.core.jsonMapper +import ai.hanzo.api.models.utils.UtilTokenCounterResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.jvm.javaMethod +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @JvmStatic + fun main(args: Array) { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + + // We have to manually run the test methods instead of using the JUnit runner because it + // seems impossible to get working with R8. + val test = ProGuardCompatibilityTest() + test::class + .memberFunctions + .asSequence() + .filter { function -> + function.javaMethod?.isAnnotationPresent(Test::class.java) == true + } + .forEach { it.call(test) } + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream("META-INF/proguard/hanzo-java-core.pro") + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = HanzoOkHttpClient.builder().apiKey("My API Key").build() + + assertThat(client).isNotNull() + assertThat(client.models()).isNotNull() + assertThat(client.openai()).isNotNull() + assertThat(client.engines()).isNotNull() + assertThat(client.chat()).isNotNull() + assertThat(client.completions()).isNotNull() + assertThat(client.embeddings()).isNotNull() + assertThat(client.images()).isNotNull() + assertThat(client.audio()).isNotNull() + assertThat(client.assistants()).isNotNull() + assertThat(client.threads()).isNotNull() + assertThat(client.moderations()).isNotNull() + assertThat(client.utils()).isNotNull() + assertThat(client.model()).isNotNull() + assertThat(client.modelGroup()).isNotNull() + assertThat(client.routes()).isNotNull() + assertThat(client.responses()).isNotNull() + assertThat(client.batches()).isNotNull() + assertThat(client.rerank()).isNotNull() + assertThat(client.fineTuning()).isNotNull() + assertThat(client.credentials()).isNotNull() + assertThat(client.vertexAi()).isNotNull() + assertThat(client.gemini()).isNotNull() + assertThat(client.cohere()).isNotNull() + assertThat(client.anthropic()).isNotNull() + assertThat(client.bedrock()).isNotNull() + assertThat(client.euAssemblyai()).isNotNull() + assertThat(client.assemblyai()).isNotNull() + assertThat(client.azure()).isNotNull() + assertThat(client.langfuse()).isNotNull() + assertThat(client.config()).isNotNull() + assertThat(client.test()).isNotNull() + assertThat(client.health()).isNotNull() + assertThat(client.active()).isNotNull() + assertThat(client.settings()).isNotNull() + assertThat(client.key()).isNotNull() + assertThat(client.user()).isNotNull() + assertThat(client.team()).isNotNull() + assertThat(client.organization()).isNotNull() + assertThat(client.customer()).isNotNull() + assertThat(client.spend()).isNotNull() + assertThat(client.global()).isNotNull() + assertThat(client.provider()).isNotNull() + assertThat(client.cache()).isNotNull() + assertThat(client.guardrails()).isNotNull() + assertThat(client.add()).isNotNull() + assertThat(client.delete()).isNotNull() + assertThat(client.files()).isNotNull() + assertThat(client.budget()).isNotNull() + } + + @Test + fun utilTokenCounterResponseRoundtrip() { + val jsonMapper = jsonMapper() + val utilTokenCounterResponse = + UtilTokenCounterResponse.builder() + .modelUsed("model_used") + .requestModel("request_model") + .tokenizerType("tokenizer_type") + .totalTokens(0L) + .build() + + val roundtrippedUtilTokenCounterResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(utilTokenCounterResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUtilTokenCounterResponse).isEqualTo(utilTokenCounterResponse) + } +} diff --git a/hanzo-java-proguard-test/test.pro b/hanzo-java-proguard-test/test.pro new file mode 100644 index 00000000..606bc414 --- /dev/null +++ b/hanzo-java-proguard-test/test.pro @@ -0,0 +1,9 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class ai.hanzo.api.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } + +# Many warnings don't apply for our testing purposes. +-dontnote +-dontwarn \ No newline at end of file diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..f4063482 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/format b/scripts/format index 456a69db..65db1769 100755 --- a/scripts/format +++ b/scripts/format @@ -4,5 +4,18 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running spotlessApply" -./gradlew spotlessApply +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + ./scripts/kotlin-format +else + echo "==> Running gradlew formatKotlin" + ./gradlew formatKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Running palantir-java-format" + ./scripts/java-format +else + echo "==> Running gradlew formatJava" + ./gradlew formatJava +fi diff --git a/scripts/java-format b/scripts/java-format new file mode 100755 index 00000000..ad5febce --- /dev/null +++ b/scripts/java-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/kotlin-format b/scripts/kotlin-format new file mode 100755 index 00000000..3b8be9ea --- /dev/null +++ b/scripts/kotlin-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" diff --git a/scripts/lint b/scripts/lint index e3a5f5e2..dbc8f776 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,5 +4,20 @@ set -e cd "$(dirname "$0")/.." -echo "==> Build classes" -./gradlew build testClasses -x test +echo "==> Running lints" + +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/kotlin-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintKotlin" + ./gradlew lintKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Checking palantir-java-format" + ./scripts/java-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintJava" + ./gradlew lintJava +fi diff --git a/scripts/mock b/scripts/mock index d2814ae6..0b28f6ea 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index 6b750a74..047bc1db 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! prism_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the prism command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 @@ -53,4 +53,4 @@ else fi echo "==> Running tests" -./gradlew test +./gradlew test "$@" diff --git a/settings.gradle.kts b/settings.gradle.kts index d6ff433f..ddd2441a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,14 @@ rootProject.name = "hanzo-java-root" -include("hanzo-java") -include("hanzo-java-client-okhttp") -include("hanzo-java-core") -include("hanzo-java-example") +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("hanzo-java") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) } From d662f5a1d615d3394d845ffb4e80115f7f9d9d0a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 6 Sep 2025 13:36:29 +0000 Subject: [PATCH 35/75] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7c3c5481..c1c3aba6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-2d6e1036fb1eea7e95cafc281141ead9ef77796e43711b17edccaab67c5e791a.yml openapi_spec_hash: 12501774d0127be4ec1812d613a58e97 -config_hash: 5b61cc8c6c31c071a08578ad825b421d +config_hash: e927bafd76a1eace11894efc3517d245 From 5997aeb3a12a1dbb0e628c3ae2e2b73d6f5c0391 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:32:50 +0000 Subject: [PATCH 36/75] feat(api): api update --- .stats.yml | 4 +- .../kotlin/ai/hanzo/api/core/Properties.kt | 8 ++-- scripts/fast-format | 39 +++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100755 scripts/fast-format diff --git a/.stats.yml b/.stats.yml index c1c3aba6..310f6103 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 188 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-2d6e1036fb1eea7e95cafc281141ead9ef77796e43711b17edccaab67c5e791a.yml -openapi_spec_hash: 12501774d0127be4ec1812d613a58e97 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-10a8fe872c67396add3ebc3a10252df5bcd6d0f4e9a255d923875a806b2f1609.yml +openapi_spec_hash: 495ad4b04c4dd929e9566b6a099ff931 config_hash: e927bafd76a1eace11894efc3517d245 diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt index decba931..70e2d21a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Properties.kt @@ -2,7 +2,7 @@ package ai.hanzo.api.core -import java.util.Properties +import ai.hanzo.api.client.HanzoClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") @@ -16,7 +16,7 @@ fun getOsArch(): String { "x86_64" -> "x64" "arm" -> "arm" "aarch64" -> "arm64" - else -> "other:${osArch}" + else -> "other:$osArch" } } @@ -30,13 +30,13 @@ fun getOsName(): String { osName.startsWith("Linux") -> "Linux" osName.startsWith("Mac OS") -> "MacOS" osName.startsWith("Windows") -> "Windows" - else -> "Other:${osName}" + else -> "Other:$osName" } } fun getOsVersion(): String = System.getProperty("os.version", "unknown") fun getPackageVersion(): String = - Properties::class.java.`package`.implementationVersion ?: "unknown" + HanzoClient::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..e16bfc56 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "$0")/.." + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if ! command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') +echo "==> Found $(echo "$kt_files" | wc -l) Kotlin files:" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@" From f5151f714c25e8331f9da13e5f3cf0169d2c1bd5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 03:43:41 +0000 Subject: [PATCH 37/75] chore(internal): codegen related update --- .../api/client/okhttp/HanzoOkHttpClient.kt | 12 + .../client/okhttp/HanzoOkHttpClientAsync.kt | 12 + .../kotlin/ai/hanzo/api/core/ClientOptions.kt | 27 +++ .../ai/hanzo/api/core/DefaultSleeper.kt | 28 +++ .../hanzo/api/core/PhantomReachableSleeper.kt | 23 ++ .../main/kotlin/ai/hanzo/api/core/Sleeper.kt | 21 ++ .../hanzo/api/core/http/RetryingHttpClient.kt | 41 +--- .../hanzo/api/models/ClientGetHomeResponse.kt | 1 + .../active/ActiveListCallbacksResponse.kt | 1 + .../api/models/add/AddAddAllowedIpResponse.kt | 1 + .../ai/hanzo/api/models/add/IpAddress.kt | 1 + .../anthropic/AnthropicCreateResponse.kt | 1 + .../anthropic/AnthropicDeleteResponse.kt | 1 + .../anthropic/AnthropicModifyResponse.kt | 1 + .../anthropic/AnthropicRetrieveResponse.kt | 1 + .../anthropic/AnthropicUpdateResponse.kt | 1 + .../assemblyai/AssemblyaiCreateResponse.kt | 1 + .../assemblyai/AssemblyaiDeleteResponse.kt | 1 + .../assemblyai/AssemblyaiPatchResponse.kt | 1 + .../assemblyai/AssemblyaiRetrieveResponse.kt | 1 + .../assemblyai/AssemblyaiUpdateResponse.kt | 1 + .../assistants/AssistantCreateResponse.kt | 1 + .../assistants/AssistantDeleteResponse.kt | 1 + .../assistants/AssistantListResponse.kt | 1 + .../audio/speech/SpeechCreateResponse.kt | 1 + .../TranscriptionCreateResponse.kt | 1 + .../api/models/azure/AzureCallResponse.kt | 1 + .../api/models/azure/AzureCreateResponse.kt | 1 + .../api/models/azure/AzureDeleteResponse.kt | 1 + .../api/models/azure/AzurePatchResponse.kt | 1 + .../api/models/azure/AzureUpdateResponse.kt | 1 + .../BatchCancelWithProviderResponse.kt | 1 + .../api/models/batches/BatchCreateResponse.kt | 1 + .../BatchCreateWithProviderResponse.kt | 1 + .../api/models/batches/BatchListResponse.kt | 1 + .../batches/BatchListWithProviderResponse.kt | 1 + .../models/batches/BatchRetrieveResponse.kt | 1 + .../BatchRetrieveWithProviderResponse.kt | 1 + .../batches/cancel/CancelCancelResponse.kt | 1 + .../models/bedrock/BedrockCreateResponse.kt | 1 + .../models/bedrock/BedrockDeleteResponse.kt | 1 + .../models/bedrock/BedrockPatchResponse.kt | 1 + .../models/bedrock/BedrockRetrieveResponse.kt | 1 + .../models/bedrock/BedrockUpdateResponse.kt | 1 + .../api/models/budget/BudgetCreateResponse.kt | 1 + .../api/models/budget/BudgetDeleteParams.kt | 1 + .../api/models/budget/BudgetDeleteResponse.kt | 1 + .../api/models/budget/BudgetInfoParams.kt | 1 + .../api/models/budget/BudgetInfoResponse.kt | 1 + .../api/models/budget/BudgetListResponse.kt | 1 + .../ai/hanzo/api/models/budget/BudgetNew.kt | 1 + .../models/budget/BudgetSettingsResponse.kt | 1 + .../api/models/budget/BudgetUpdateResponse.kt | 1 + .../api/models/cache/CacheDeleteParams.kt | 2 +- .../api/models/cache/CacheDeleteResponse.kt | 1 + .../api/models/cache/CacheFlushAllResponse.kt | 1 + .../api/models/cache/CachePingResponse.kt | 1 + .../cache/redis/RediRetrieveInfoResponse.kt | 1 + .../completions/CompletionCreateResponse.kt | 1 + .../api/models/cohere/CohereCreateResponse.kt | 1 + .../api/models/cohere/CohereDeleteResponse.kt | 1 + .../api/models/cohere/CohereModifyResponse.kt | 1 + .../models/cohere/CohereRetrieveResponse.kt | 1 + .../api/models/cohere/CohereUpdateResponse.kt | 1 + .../completions/CompletionCreateResponse.kt | 1 + .../PassThroughEndpointCreateResponse.kt | 1 + .../PassThroughEndpointResponse.kt | 1 + .../PassThroughEndpointUpdateResponse.kt | 1 + .../PassThroughGenericEndpoint.kt | 1 + .../credentials/CredentialCreateParams.kt | 1 + .../credentials/CredentialCreateResponse.kt | 1 + .../credentials/CredentialDeleteResponse.kt | 1 + .../api/models/credentials/CredentialItem.kt | 1 + .../credentials/CredentialListResponse.kt | 1 + .../hanzo/api/models/customer/BlockUsers.kt | 1 + .../models/customer/CustomerBlockResponse.kt | 1 + .../models/customer/CustomerCreateParams.kt | 1 + .../models/customer/CustomerCreateResponse.kt | 1 + .../models/customer/CustomerDeleteParams.kt | 1 + .../models/customer/CustomerDeleteResponse.kt | 1 + .../models/customer/CustomerListResponse.kt | 2 + .../customer/CustomerRetrieveInfoResponse.kt | 2 + .../customer/CustomerUnblockResponse.kt | 1 + .../models/customer/CustomerUpdateParams.kt | 1 + .../models/customer/CustomerUpdateResponse.kt | 1 + .../delete/DeleteCreateAllowedIpResponse.kt | 1 + .../embeddings/EmbeddingCreateResponse.kt | 1 + .../models/engines/EngineCompleteResponse.kt | 1 + .../api/models/engines/EngineEmbedResponse.kt | 1 + .../engines/chat/ChatCompleteResponse.kt | 1 + .../EuAssemblyaiCreateResponse.kt | 1 + .../EuAssemblyaiDeleteResponse.kt | 1 + .../euassemblyai/EuAssemblyaiPatchResponse.kt | 1 + .../EuAssemblyaiRetrieveResponse.kt | 1 + .../EuAssemblyaiUpdateResponse.kt | 1 + .../api/models/files/FileCreateResponse.kt | 1 + .../api/models/files/FileDeleteResponse.kt | 1 + .../api/models/files/FileListResponse.kt | 1 + .../api/models/files/FileRetrieveResponse.kt | 1 + .../files/content/ContentRetrieveResponse.kt | 1 + .../models/finetuning/jobs/JobCreateParams.kt | 2 + .../finetuning/jobs/JobCreateResponse.kt | 1 + .../models/finetuning/jobs/JobListResponse.kt | 1 + .../finetuning/jobs/JobRetrieveResponse.kt | 1 + .../jobs/cancel/CancelCreateResponse.kt | 1 + .../api/models/gemini/GeminiCreateResponse.kt | 1 + .../api/models/gemini/GeminiDeleteResponse.kt | 1 + .../api/models/gemini/GeminiPatchResponse.kt | 1 + .../models/gemini/GeminiRetrieveResponse.kt | 1 + .../api/models/gemini/GeminiUpdateResponse.kt | 1 + .../global/spend/SpendListTagsResponse.kt | 1 + .../models/global/spend/SpendResetResponse.kt | 1 + .../spend/SpendRetrieveReportResponse.kt | 1 + .../models/guardrails/GuardrailListParams.kt | 36 +-- .../guardrails/GuardrailListResponse.kt | 3 + .../models/health/HealthCheckAllResponse.kt | 1 + .../health/HealthCheckLivelinessResponse.kt | 1 + .../health/HealthCheckLivenessResponse.kt | 1 + .../health/HealthCheckReadinessResponse.kt | 1 + .../health/HealthCheckServicesResponse.kt | 1 + .../generations/GenerationCreateResponse.kt | 1 + .../hanzo/api/models/key/BlockKeyRequest.kt | 1 + .../api/models/key/GenerateKeyResponse.kt | 1 + .../hanzo/api/models/key/KeyBlockResponse.kt | 1 + .../api/models/key/KeyCheckHealthParams.kt | 8 +- .../api/models/key/KeyCheckHealthResponse.kt | 2 + .../hanzo/api/models/key/KeyDeleteParams.kt | 1 + .../hanzo/api/models/key/KeyDeleteResponse.kt | 1 + .../hanzo/api/models/key/KeyGenerateParams.kt | 1 + .../hanzo/api/models/key/KeyListResponse.kt | 2 + .../api/models/key/KeyRetrieveInfoResponse.kt | 1 + .../api/models/key/KeyUnblockResponse.kt | 1 + .../hanzo/api/models/key/KeyUpdateParams.kt | 1 + .../hanzo/api/models/key/KeyUpdateResponse.kt | 1 + .../key/regenerate/RegenerateKeyRequest.kt | 1 + .../models/langfuse/LangfuseCreateResponse.kt | 1 + .../models/langfuse/LangfuseDeleteResponse.kt | 1 + .../models/langfuse/LangfusePatchResponse.kt | 1 + .../langfuse/LangfuseRetrieveResponse.kt | 1 + .../models/langfuse/LangfuseUpdateResponse.kt | 1 + .../ConfigurableClientsideParamsCustomAuth.kt | 1 + .../api/models/model/ModelCreateParams.kt | 2 + .../api/models/model/ModelCreateResponse.kt | 1 + .../api/models/model/ModelDeleteParams.kt | 1 + .../api/models/model/ModelDeleteResponse.kt | 1 + .../ai/hanzo/api/models/model/ModelInfo.kt | 1 + .../api/models/model/info/InfoListParams.kt | 27 +-- .../api/models/model/info/InfoListResponse.kt | 1 + .../models/model/update/UpdateDeployment.kt | 2 + .../models/model/update/UpdateFullResponse.kt | 1 + .../model/update/UpdatePartialResponse.kt | 1 + .../ModelGroupRetrieveInfoParams.kt | 216 +++++++++--------- .../ModelGroupRetrieveInfoResponse.kt | 1 + .../api/models/models/ModelListResponse.kt | 1 + .../moderations/ModerationCreateResponse.kt | 1 + .../api/models/openai/OpenAICreateResponse.kt | 1 + .../api/models/openai/OpenAIDeleteResponse.kt | 1 + .../api/models/openai/OpenAIPatchResponse.kt | 1 + .../models/openai/OpenAIRetrieveResponse.kt | 1 + .../api/models/openai/OpenAIUpdateResponse.kt | 1 + .../deployments/DeploymentCompleteResponse.kt | 1 + .../deployments/DeploymentEmbedResponse.kt | 1 + .../deployments/chat/ChatCompleteResponse.kt | 1 + .../api/models/organization/OrgMember.kt | 1 + .../OrganizationAddMemberParams.kt | 1 + .../OrganizationAddMemberResponse.kt | 6 + .../organization/OrganizationCreateParams.kt | 31 +-- .../OrganizationCreateResponse.kt | 1 + .../OrganizationDeleteMemberParams.kt | 1 + .../OrganizationDeleteMemberResponse.kt | 1 + .../organization/OrganizationDeleteParams.kt | 1 + .../OrganizationDeleteResponse.kt | 6 + .../organization/OrganizationListResponse.kt | 6 + .../OrganizationUpdateMemberParams.kt | 1 + .../OrganizationUpdateMemberResponse.kt | 2 + .../organization/OrganizationUpdateParams.kt | 1 + .../OrganizationUpdateResponse.kt | 6 + .../organization/info/InfoDeprecatedParams.kt | 1 + .../info/InfoDeprecatedResponse.kt | 1 + .../organization/info/InfoRetrieveResponse.kt | 6 + .../provider/ProviderListBudgetsParams.kt | 50 ++-- .../provider/ProviderListBudgetsResponse.kt | 1 + .../api/models/rerank/RerankCreateResponse.kt | 1 + .../models/rerank/RerankCreateV1Response.kt | 1 + .../models/rerank/RerankCreateV2Response.kt | 1 + .../responses/ResponseCreateResponse.kt | 1 + .../responses/ResponseDeleteResponse.kt | 1 + .../responses/ResponseRetrieveResponse.kt | 1 + .../inputitems/InputItemListResponse.kt | 1 + .../api/models/routes/RouteListResponse.kt | 1 + .../settings/SettingRetrieveResponse.kt | 1 + .../models/spend/SpendCalculateSpendParams.kt | 1 + .../spend/SpendCalculateSpendResponse.kt | 1 + .../api/models/spend/SpendListLogsResponse.kt | 1 + .../api/models/spend/SpendListTagsResponse.kt | 1 + .../hanzo/api/models/team/BlockTeamRequest.kt | 1 + .../kotlin/ai/hanzo/api/models/team/Member.kt | 1 + .../api/models/team/TeamAddMemberParams.kt | 1 + .../api/models/team/TeamAddMemberResponse.kt | 7 + .../api/models/team/TeamBlockResponse.kt | 1 + .../hanzo/api/models/team/TeamCreateParams.kt | 13 +- .../api/models/team/TeamCreateResponse.kt | 2 + .../hanzo/api/models/team/TeamDeleteParams.kt | 1 + .../api/models/team/TeamDeleteResponse.kt | 1 + .../models/team/TeamDisableLoggingResponse.kt | 1 + .../models/team/TeamListAvailableResponse.kt | 1 + .../hanzo/api/models/team/TeamListResponse.kt | 1 + .../api/models/team/TeamRemoveMemberParams.kt | 1 + .../models/team/TeamRemoveMemberResponse.kt | 1 + .../models/team/TeamRetrieveInfoResponse.kt | 1 + .../api/models/team/TeamUnblockResponse.kt | 1 + .../api/models/team/TeamUpdateMemberParams.kt | 1 + .../models/team/TeamUpdateMemberResponse.kt | 1 + .../hanzo/api/models/team/TeamUpdateParams.kt | 1 + .../api/models/team/TeamUpdateResponse.kt | 1 + .../models/team/callback/CallbackAddParams.kt | 1 + .../team/callback/CallbackAddResponse.kt | 1 + .../team/callback/CallbackRetrieveResponse.kt | 1 + .../api/models/team/model/ModelAddParams.kt | 1 + .../api/models/team/model/ModelAddResponse.kt | 1 + .../models/team/model/ModelRemoveParams.kt | 1 + .../models/team/model/ModelRemoveResponse.kt | 1 + .../hanzo/api/models/test/TestPingResponse.kt | 1 + .../models/threads/ThreadCreateResponse.kt | 1 + .../models/threads/ThreadRetrieveResponse.kt | 1 + .../threads/messages/MessageCreateResponse.kt | 1 + .../threads/messages/MessageListResponse.kt | 1 + .../models/threads/runs/RunCreateResponse.kt | 1 + .../hanzo/api/models/user/UserCreateParams.kt | 1 + .../api/models/user/UserCreateResponse.kt | 1 + .../hanzo/api/models/user/UserDeleteParams.kt | 1 + .../api/models/user/UserDeleteResponse.kt | 1 + .../hanzo/api/models/user/UserListParams.kt | 11 +- .../hanzo/api/models/user/UserListResponse.kt | 1 + .../models/user/UserRetrieveInfoResponse.kt | 1 + .../hanzo/api/models/user/UserUpdateParams.kt | 87 ++++--- .../api/models/user/UserUpdateResponse.kt | 1 + .../UtilGetSupportedOpenAIParamsResponse.kt | 1 + .../models/utils/UtilTokenCounterParams.kt | 1 + .../models/utils/UtilTokenCounterResponse.kt | 1 + .../utils/UtilTransformRequestParams.kt | 1 + .../utils/UtilTransformRequestResponse.kt | 1 + .../models/vertexai/VertexAiCreateResponse.kt | 1 + .../models/vertexai/VertexAiDeleteResponse.kt | 1 + .../models/vertexai/VertexAiPatchResponse.kt | 1 + .../vertexai/VertexAiRetrieveResponse.kt | 1 + .../models/vertexai/VertexAiUpdateResponse.kt | 1 + .../api/services/async/AddServiceAsync.kt | 28 +++ .../api/services/async/BudgetServiceAsync.kt | 45 ++++ .../api/services/async/CacheServiceAsync.kt | 2 +- .../services/async/CustomerServiceAsync.kt | 49 ++++ .../api/services/async/DeleteServiceAsync.kt | 31 +++ .../services/async/GuardrailServiceAsync.kt | 36 +-- .../api/services/async/KeyServiceAsync.kt | 60 ++++- .../services/async/ModelGroupServiceAsync.kt | 216 +++++++++--------- .../async/OrganizationServiceAsync.kt | 30 +-- .../services/async/ProviderServiceAsync.kt | 50 ++-- .../api/services/async/TeamServiceAsync.kt | 70 +++++- .../api/services/async/UserServiceAsync.kt | 99 ++++---- .../config/PassThroughEndpointServiceAsync.kt | 37 +++ .../services/async/model/InfoServiceAsync.kt | 27 +-- .../async/model/UpdateServiceAsync.kt | 28 +++ .../hanzo/api/services/blocking/AddService.kt | 28 +++ .../api/services/blocking/BudgetService.kt | 49 ++++ .../api/services/blocking/CacheService.kt | 2 +- .../api/services/blocking/CustomerService.kt | 49 ++++ .../api/services/blocking/DeleteService.kt | 31 +++ .../api/services/blocking/GuardrailService.kt | 36 +-- .../hanzo/api/services/blocking/KeyService.kt | 60 ++++- .../services/blocking/ModelGroupService.kt | 216 +++++++++--------- .../services/blocking/OrganizationService.kt | 30 +-- .../api/services/blocking/ProviderService.kt | 50 ++-- .../api/services/blocking/TeamService.kt | 70 +++++- .../api/services/blocking/UserService.kt | 99 ++++---- .../config/PassThroughEndpointService.kt | 38 +++ .../services/blocking/model/InfoService.kt | 27 +-- .../services/blocking/model/UpdateService.kt | 28 +++ .../api/core/http/RetryingHttpClientTest.kt | 9 +- .../api/services/async/AddServiceAsyncTest.kt | 8 +- .../services/async/BudgetServiceAsyncTest.kt | 86 +++---- .../async/CustomerServiceAsyncTest.kt | 14 +- .../services/async/DeleteServiceAsyncTest.kt | 7 +- .../services/async/TeamServiceAsyncTest.kt | 14 +- .../PassThroughEndpointServiceAsyncTest.kt | 13 +- .../async/model/UpdateServiceAsyncTest.kt | 103 ++++----- .../api/services/blocking/AddServiceTest.kt | 8 +- .../services/blocking/BudgetServiceTest.kt | 86 +++---- .../services/blocking/CustomerServiceTest.kt | 16 +- .../services/blocking/DeleteServiceTest.kt | 8 +- .../api/services/blocking/TeamServiceTest.kt | 16 +- .../config/PassThroughEndpointServiceTest.kt | 13 +- .../blocking/model/UpdateServiceTest.kt | 103 ++++----- scripts/fast-format | 13 +- 293 files changed, 2034 insertions(+), 1021 deletions(-) create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/DefaultSleeper.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableSleeper.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Sleeper.kt diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt index 055cf4ab..778c7e40 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.client.okhttp import ai.hanzo.api.client.HanzoClient import ai.hanzo.api.client.HanzoClientImpl import ai.hanzo.api.core.ClientOptions +import ai.hanzo.api.core.Sleeper import ai.hanzo.api.core.Timeout import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.HttpClient @@ -120,6 +121,17 @@ class HanzoOkHttpClient private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt index f97cf2b3..3a965e58 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.client.okhttp import ai.hanzo.api.client.HanzoClientAsync import ai.hanzo.api.client.HanzoClientAsyncImpl import ai.hanzo.api.core.ClientOptions +import ai.hanzo.api.core.Sleeper import ai.hanzo.api.core.Timeout import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.HttpClient @@ -120,6 +121,17 @@ class HanzoOkHttpClientAsync private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt index 666c1e66..19851417 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt @@ -40,6 +40,16 @@ private constructor( * needs to be overridden. */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, /** * The clock to use for operations that require timing, like retries. * @@ -136,6 +146,7 @@ private constructor( private var httpClient: HttpClient? = null private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() @@ -150,6 +161,7 @@ private constructor( httpClient = clientOptions.originalHttpClient checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper + sleeper = clientOptions.sleeper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() @@ -190,6 +202,17 @@ private constructor( */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * @@ -380,6 +403,7 @@ private constructor( */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) val apiKey = checkRequired("apiKey", apiKey) val headers = Headers.builder() @@ -403,11 +427,13 @@ private constructor( httpClient, RetryingHttpClient.builder() .httpClient(httpClient) + .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) .build(), checkJacksonVersionCompatibility, jsonMapper, + sleeper, clock, baseUrl, headers.build(), @@ -432,5 +458,6 @@ private constructor( */ fun close() { httpClient.close() + sleeper.close() } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/DefaultSleeper.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/DefaultSleeper.kt new file mode 100644 index 00000000..6b15ec7e --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package ai.hanzo.api.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + + override fun close() = timer.cancel() +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableSleeper.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableSleeper.kt new file mode 100644 index 00000000..5effc26d --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package ai.hanzo.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Sleeper.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Sleeper.kt new file mode 100644 index 00000000..e08c7205 --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/Sleeper.kt @@ -0,0 +1,21 @@ +package ai.hanzo.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt index 94e25251..9e807198 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,8 @@ package ai.hanzo.api.core.http +import ai.hanzo.api.core.DefaultSleeper import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.Sleeper import ai.hanzo.api.core.checkRequired import ai.hanzo.api.errors.HanzoIoException import ai.hanzo.api.errors.HanzoRetryableException @@ -11,8 +13,6 @@ import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException import java.time.temporal.ChronoUnit -import java.util.Timer -import java.util.TimerTask import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.ThreadLocalRandom @@ -130,7 +130,10 @@ private constructor( return executeWithRetries(modifiedRequest, requestOptions) } - override fun close() = httpClient.close() + override fun close() { + httpClient.close() + sleeper.close() + } private fun isRetryable(request: HttpRequest): Boolean = // Some requests, such as when a request body is being streamed, cannot be retried because @@ -235,33 +238,14 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null - private var sleeper: Sleeper = - object : Sleeper { - - private val timer = Timer("RetryingHttpClient", true) - - override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) - - override fun sleepAsync(duration: Duration): CompletableFuture { - val future = CompletableFuture() - timer.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - duration.toMillis(), - ) - return future - } - } + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } - @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } fun clock(clock: Clock) = apply { this.clock = clock } @@ -272,17 +256,10 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), - sleeper, + sleeper ?: DefaultSleeper(), clock, maxRetries, idempotencyHeader, ) } - - internal interface Sleeper { - - fun sleep(duration: Duration) - - fun sleepAsync(duration: Duration): CompletableFuture - } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt index 6277927d..558b592e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/ClientGetHomeResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ClientGetHomeResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponse.kt index 6c11b003..17a9643e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ActiveListCallbacksResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt index 1af19043..8ebd313b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/AddAddAllowedIpResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AddAddAllowedIpResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/IpAddress.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/IpAddress.kt index 742b7173..082ac99d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/IpAddress.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/add/IpAddress.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class IpAddress +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val ip: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt index 87982a4b..a0d79f17 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AnthropicCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt index cf32cc9e..0f26ba7d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AnthropicDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt index 8698a80a..a3e6e48f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AnthropicModifyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt index 68965318..2e469e2a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AnthropicRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt index 313fd3ac..6ae9883f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AnthropicUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt index b9b025bd..1bc70c35 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssemblyaiCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt index 6ce87bb3..fd1fc9f7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssemblyaiDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt index af025b96..dd0a2b2b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiPatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssemblyaiPatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt index b91a66c2..0f74b199 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssemblyaiRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt index 6a9dcce0..9f670742 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assemblyai/AssemblyaiUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssemblyaiUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt index 81a48b36..1bca8a8d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssistantCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt index dec47c6d..b2712591 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssistantDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantListResponse.kt index 1e3187ed..5f8e0d7f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/assistants/AssistantListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AssistantListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt index dec5703f..463c5776 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/speech/SpeechCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class SpeechCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt index 28ec798e..224698c6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/audio/transcriptions/TranscriptionCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TranscriptionCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt index 83306012..c09a388b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AzureCallResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt index 95e22457..b790db61 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AzureCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt index 46fd0416..fc429a8c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AzureDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt index 95df70ed..abd70a20 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AzurePatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt index 67d94884..1eb7ecdc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class AzureUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt index fb013579..5611e674 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCancelWithProviderResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchCancelWithProviderResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt index 1022f081..c8334335 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt index 7fd0faa0..b3af961d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchCreateWithProviderResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchCreateWithProviderResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt index 7efca222..495f4a5b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt index 0a898998..163a8fe4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchListWithProviderResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt index 4957afcf..21af2aa0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt index 6f66fd13..92ad1347 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchRetrieveWithProviderResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BatchRetrieveWithProviderResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt index 62e780a0..e06c82c0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/cancel/CancelCancelResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CancelCancelResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt index 34ccbe81..39d0b75d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BedrockCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt index 3d37e3e2..fae52989 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BedrockDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt index 3e7dd8b6..6f4065d3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BedrockPatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt index cd0f70c5..98ed529b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BedrockRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt index 91389aba..a948a745 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BedrockUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt index 8b15401a..453ffc4c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BudgetCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt index 10cdf68b..69a9354b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteParams.kt @@ -244,6 +244,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt index 52fe4c11..e8581a83 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BudgetDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt index 6dc83127..22adeb96 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoParams.kt @@ -251,6 +251,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgets: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt index 2db389d7..42bc9993 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetInfoResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BudgetInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetListResponse.kt index c86a11fd..4115757c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BudgetListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt index f3046b04..50994fa8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BudgetNew +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val budgetId: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt index d482ccf0..30cb8c67 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetSettingsResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BudgetSettingsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt index e384628f..4e1d52ab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class BudgetUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt index 18ecfbad..17253ed3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt @@ -15,7 +15,7 @@ import java.util.Optional * in the headers * * Parameters: - * - **keys**: _Optional[List[str]]_ - A list of keys to delete from the cache. Example {"keys": + * - **keys**: *Optional[List[str]]* - A list of keys to delete from the cache. Example {"keys": * ["key1", "key2"]} * * ```shell diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt index d261d171..68eaa853 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CacheDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt index 27ef8e73..e32ef1a7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheFlushAllResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CacheFlushAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt index 16d0ee1d..0cc0d933 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CachePingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cacheType: JsonField, private val status: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponse.kt index 455f1f29..27c0ab55 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/redis/RediRetrieveInfoResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class RediRetrieveInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt index e906230c..5d3dcfd9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CompletionCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt index 03828d25..f4d86092 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CohereCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt index 3be17d7b..884dd022 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CohereDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt index 4fa7a92d..76d736cb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CohereModifyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt index 8be1c2c9..8c3b95c5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CohereRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt index 2fced519..e6ec5d81 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CohereUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt index fa0ebb4e..359d2f60 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/completions/CompletionCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CompletionCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt index 939646a8..8beeb0e9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class PassThroughEndpointCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt index 166367b3..b2199f79 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PassThroughEndpointResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endpoints: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt index a45f0251..5cc0608d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class PassThroughEndpointUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt index fbaefa12..12cea4fb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class PassThroughGenericEndpoint +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val headers: JsonValue, private val path: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt index 6f66cadf..9f168c35 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt @@ -290,6 +290,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val credentialInfo: JsonValue, private val credentialName: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt index 35904cd5..5ac081d0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CredentialCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt index 158ce984..00597f9e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CredentialDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt index 3ed9d102..8dd9f0a8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class CredentialItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val credentialInfo: JsonValue, private val credentialName: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialListResponse.kt index 1ddf7fd9..355918ae 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CredentialListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/BlockUsers.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/BlockUsers.kt index 013759a7..dd73992c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/BlockUsers.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/BlockUsers.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class BlockUsers +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt index d1ecd5ab..2bfca88a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerBlockResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CustomerBlockResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt index 5696d4f5..ba8a227f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt @@ -699,6 +699,7 @@ private constructor( /** Create a new customer, allocate a budget to them */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userId: JsonField, private val alias: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt index ba38f348..ef61c92a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CustomerCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt index 316ff8a5..59f3fa99 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt @@ -265,6 +265,7 @@ private constructor( /** Delete multiple Customers */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt index 5fa87808..8ff72e29 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CustomerDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt index 232f25ad..2e1acc5a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val blocked: JsonField, private val userId: JsonField, @@ -521,6 +522,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt index 6c37f2a1..087fdb73 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerRetrieveInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val blocked: JsonField, private val userId: JsonField, @@ -521,6 +522,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt index d3cb4676..667b720a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUnblockResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CustomerUnblockResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt index c1229aeb..03eba673 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt @@ -444,6 +444,7 @@ private constructor( /** Update a Customer, use this to update customer budgets etc */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userId: JsonField, private val alias: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt index dd29bfdb..5c14d9b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CustomerUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt index 5319d639..529987de 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/delete/DeleteCreateAllowedIpResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class DeleteCreateAllowedIpResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt index 44f6322a..f56be174 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EmbeddingCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt index 6deec33c..ae652209 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineCompleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EngineCompleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt index b36e5362..aa81ac76 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EngineEmbedResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt index f792e9e5..416aa2b6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ChatCompleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt index b640a32c..58a5472e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EuAssemblyaiCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt index 06392ead..ad8c6bc5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EuAssemblyaiDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt index cd83fcf3..9c185a6d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiPatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EuAssemblyaiPatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt index ac3c6450..9fb8720c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EuAssemblyaiRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt index 889599e6..9b0d2b12 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/euassemblyai/EuAssemblyaiUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class EuAssemblyaiUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt index 34515f3d..3c498779 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FileCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt index d80f8800..ab61eaa0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FileDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt index a50a3255..085865ad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FileListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt index ea252d34..6f96ec9f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FileRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt index 0a6cc944..ad1c935f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/content/ContentRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ContentRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt index afb27629..43ef4b36 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt @@ -489,6 +489,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val customLlmProvider: JsonField, private val model: JsonField, @@ -1108,6 +1109,7 @@ private constructor( } class Hyperparameters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val batchSize: JsonField, private val learningRateMultiplier: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt index 0d29be44..a871e0e1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class JobCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt index 21d303e8..1f342201 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class JobListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponse.kt index a181baa4..1d55a28a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class JobRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt index d48f9c1f..b213b641 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CancelCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt index 00eda08f..9dd4505c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class GeminiCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt index d6ffe9f2..19c1d282 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class GeminiDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt index 9755e577..7d9187a5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class GeminiPatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt index 9101df4d..e7b9398d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class GeminiRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt index 7e570314..e7f40d7f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class GeminiUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt index 30816906..8df5a212 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SpendListTagsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apiKey: JsonField, private val callType: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt index 7ebe12b8..34aad01c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class SpendResetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt index 9afa82da..e5db44d4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SpendRetrieveReportResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apiKey: JsonField, private val callType: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt index a0a4ffe7..394f3b10 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt @@ -20,24 +20,24 @@ import java.util.Objects * Example Response: * ```json * { - * "guardrails": [ - * { - * "guardrail_name": "bedrock-pre-guard", - * "guardrail_info": { - * "params": [ - * { - * "name": "toxicity_score", - * "type": "float", - * "description": "Score between 0-1 indicating content toxicity level" - * }, - * { - * "name": "pii_detection", - * "type": "boolean" - * } - * ] - * } - * } - * ] + * "guardrails": [ + * { + * "guardrail_name": "bedrock-pre-guard", + * "guardrail_info": { + * "params": [ + * { + * "name": "toxicity_score", + * "type": "float", + * "description": "Score between 0-1 indicating content toxicity level" + * }, + * { + * "name": "pii_detection", + * "type": "boolean" + * } + * ] + * } + * } + * ] * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt index f9844f7f..8eaf8624 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class GuardrailListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val guardrails: JsonField>, private val additionalProperties: MutableMap, @@ -187,6 +188,7 @@ private constructor( (guardrails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) class Guardrail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val guardrailInfo: JsonValue, private val guardrailName: JsonField, @@ -391,6 +393,7 @@ private constructor( /** The returned LLM Params object for /guardrails/list */ class LlmParams + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val guardrail: JsonField, private val mode: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt index 65f27ad1..0b813d63 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class HealthCheckAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponse.kt index 8c527f3f..2643b491 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivelinessResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class HealthCheckLivelinessResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponse.kt index 020e3200..51f31d81 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckLivenessResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class HealthCheckLivenessResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponse.kt index 92d27e60..f9b888ee 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckReadinessResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class HealthCheckReadinessResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponse.kt index e69cb757..56c714a0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class HealthCheckServicesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponse.kt index a51d8d72..468cd202 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class GenerationCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/BlockKeyRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/BlockKeyRequest.kt index b787037d..2fade0fa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/BlockKeyRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/BlockKeyRequest.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class BlockKeyRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val key: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt index 4682385d..1f7a9433 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class GenerateKeyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val expires: JsonField, private val key: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt index 6578dac2..b829c05d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class KeyBlockResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, private val aliases: JsonValue, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt index 87ca9388..d6049fb8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthParams.kt @@ -29,7 +29,9 @@ import java.util.Optional * { * "key": "healthy", * "logging_callbacks": { - * "callbacks": ["gcs_bucket"], + * "callbacks": [ + * "gcs_bucket" + * ], * "status": "healthy", * "details": "No logger exceptions triggered, system is healthy. Manually check if logs were sent to ['gcs_bucket']" * } @@ -41,7 +43,9 @@ import java.util.Optional * { * "key": "unhealthy", * "logging_callbacks": { - * "callbacks": ["gcs_bucket"], + * "callbacks": [ + * "gcs_bucket" + * ], * "status": "unhealthy", * "details": "Logger exceptions triggered, system is unhealthy: Failed to load vertex credentials. Check to see if credentials containing partial/invalid information." * } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt index c06e3ef5..16f0b3d5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyCheckHealthResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class KeyCheckHealthResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val key: JsonField, private val loggingCallbacks: JsonField, @@ -307,6 +308,7 @@ private constructor( } class LoggingCallbacks + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val callbacks: JsonField>, private val details: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt index 36601de8..bd1b8eca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt @@ -322,6 +322,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val keyAliases: JsonField>, private val keys: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt index 34ff8cdd..76abac82 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class KeyDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt index 2c0f9aef..30666b92 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt @@ -989,6 +989,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aliases: JsonValue, private val allowedCacheControls: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt index 29426e6e..b3b7fbe2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt @@ -33,6 +33,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class KeyListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currentPage: JsonField, private val keys: JsonField>, @@ -471,6 +472,7 @@ private constructor( /** Return the row in the db */ class UserApiKeyAuth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, private val aliases: JsonValue, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt index a4c8b682..3550ba6e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class KeyRetrieveInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockResponse.kt index 871a31d2..97bba5b7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class KeyUnblockResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt index 1b096496..8b8e82b6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt @@ -988,6 +988,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val key: JsonField, private val aliases: JsonValue, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateResponse.kt index d12d163a..ea9b9d46 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class KeyUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt index 140159b7..6a2bc94d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class RegenerateKeyRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aliases: JsonValue, private val allowedCacheControls: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponse.kt index cf0c598e..3b90081e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class LangfuseCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponse.kt index 6c09dad5..eda7d242 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class LangfuseDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponse.kt index e90dfa98..3734310e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class LangfusePatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponse.kt index 78c4c87e..be1aca28 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class LangfuseRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponse.kt index 6caaae1a..0c45c4ad 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class LangfuseUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt index 095b7ead..5ae85912 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class ConfigurableClientsideParamsCustomAuth +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apiBase: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt index 369cb274..07b6b3bb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt @@ -312,6 +312,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val llmParams: JsonField, private val modelInfo: JsonField, @@ -553,6 +554,7 @@ private constructor( /** LLM Params with 'model' requirement - used for completions */ class LlmParams + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val model: JsonField, private val apiBase: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt index 6ab5aa95..2323ae38 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModelCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt index 1ad3fcef..29b1731f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteParams.kt @@ -239,6 +239,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteResponse.kt index dae039c3..6731f0f9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModelDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt index 061398dc..edd4319c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelInfo.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class ModelInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val baseModel: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListParams.kt index c4178dd6..8a5fe157 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListParams.kt @@ -24,20 +24,21 @@ import kotlin.jvm.optionals.getOrNull * Example Response: * ```json * { - * "data": [ - * { - * "model_name": "fake-openai-endpoint", - * "llm_params": { - * "api_base": "https://exampleopenaiendpoint-production.up.railway.app/", - * "model": "openai/fake" - * }, - * "model_info": { - * "id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af", - * "db_model": false - * } - * } - * ] + * "data": [ + * { + * "model_name": "fake-openai-endpoint", + * "llm_params": { + * "api_base": "https://exampleopenaiendpoint-production.up.railway.app/", + * "model": "openai/fake" + * }, + * "model_info": { + * "id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af", + * "db_model": false + * } + * } + * ] * } + * * ``` */ class InfoListParams diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt index 20c817e5..93c29cf6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/info/InfoListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class InfoListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt index e65917bf..90d9477b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateDeployment.kt @@ -32,6 +32,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class UpdateDeployment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val llmParams: JsonField, private val modelInfo: JsonField, @@ -226,6 +227,7 @@ private constructor( (if (modelName.asKnown().isPresent) 1 else 0) class LlmParams + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apiBase: JsonField, private val apiKey: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt index c770fee8..48533443 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdateFullResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UpdateFullResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponse.kt index 3181050e..dff84819 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/update/UpdatePartialResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UpdatePartialResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParams.kt index 533881a5..b832828c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoParams.kt @@ -38,112 +38,118 @@ import kotlin.jvm.optionals.getOrNull * * Example Response: * ```json - * { - * "data": [ * { - * "model_group": "rerank-english-v3.0", - * "providers": ["cohere"], - * "max_input_tokens": null, - * "max_output_tokens": null, - * "input_cost_per_token": 0.0, - * "output_cost_per_token": 0.0, - * "mode": null, - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": false, - * "supports_function_calling": false, - * "supported_openai_params": [ - * "stream", - * "temperature", - * "max_tokens", - * "logit_bias", - * "top_p", - * "frequency_penalty", - * "presence_penalty", - * "stop", - * "n", - * "extra_headers" - * ] - * }, - * { - * "model_group": "gpt-3.5-turbo", - * "providers": ["openai"], - * "max_input_tokens": 16385.0, - * "max_output_tokens": 4096.0, - * "input_cost_per_token": 1.5e-6, - * "output_cost_per_token": 2e-6, - * "mode": "chat", - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": false, - * "supports_function_calling": true, - * "supported_openai_params": [ - * "frequency_penalty", - * "logit_bias", - * "logprobs", - * "top_logprobs", - * "max_tokens", - * "max_completion_tokens", - * "n", - * "presence_penalty", - * "seed", - * "stop", - * "stream", - * "stream_options", - * "temperature", - * "top_p", - * "tools", - * "tool_choice", - * "function_call", - * "functions", - * "max_retries", - * "extra_headers", - * "parallel_tool_calls", - * "response_format" - * ] - * }, - * { - * "model_group": "llava-hf", - * "providers": ["openai"], - * "max_input_tokens": null, - * "max_output_tokens": null, - * "input_cost_per_token": 0.0, - * "output_cost_per_token": 0.0, - * "mode": null, - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": true, - * "supports_function_calling": false, - * "supported_openai_params": [ - * "frequency_penalty", - * "logit_bias", - * "logprobs", - * "top_logprobs", - * "max_tokens", - * "max_completion_tokens", - * "n", - * "presence_penalty", - * "seed", - * "stop", - * "stream", - * "stream_options", - * "temperature", - * "top_p", - * "tools", - * "tool_choice", - * "function_call", - * "functions", - * "max_retries", - * "extra_headers", - * "parallel_tool_calls", - * "response_format" - * ] - * } - * ] - * } + * "data": [ + * { + * "model_group": "rerank-english-v3.0", + * "providers": [ + * "cohere" + * ], + * "max_input_tokens": null, + * "max_output_tokens": null, + * "input_cost_per_token": 0.0, + * "output_cost_per_token": 0.0, + * "mode": null, + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": false, + * "supports_function_calling": false, + * "supported_openai_params": [ + * "stream", + * "temperature", + * "max_tokens", + * "logit_bias", + * "top_p", + * "frequency_penalty", + * "presence_penalty", + * "stop", + * "n", + * "extra_headers" + * ] + * }, + * { + * "model_group": "gpt-3.5-turbo", + * "providers": [ + * "openai" + * ], + * "max_input_tokens": 16385.0, + * "max_output_tokens": 4096.0, + * "input_cost_per_token": 1.5e-06, + * "output_cost_per_token": 2e-06, + * "mode": "chat", + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": false, + * "supports_function_calling": true, + * "supported_openai_params": [ + * "frequency_penalty", + * "logit_bias", + * "logprobs", + * "top_logprobs", + * "max_tokens", + * "max_completion_tokens", + * "n", + * "presence_penalty", + * "seed", + * "stop", + * "stream", + * "stream_options", + * "temperature", + * "top_p", + * "tools", + * "tool_choice", + * "function_call", + * "functions", + * "max_retries", + * "extra_headers", + * "parallel_tool_calls", + * "response_format" + * ] + * }, + * { + * "model_group": "llava-hf", + * "providers": [ + * "openai" + * ], + * "max_input_tokens": null, + * "max_output_tokens": null, + * "input_cost_per_token": 0.0, + * "output_cost_per_token": 0.0, + * "mode": null, + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": true, + * "supports_function_calling": false, + * "supported_openai_params": [ + * "frequency_penalty", + * "logit_bias", + * "logprobs", + * "top_logprobs", + * "max_tokens", + * "max_completion_tokens", + * "n", + * "presence_penalty", + * "seed", + * "stop", + * "stream", + * "stream_options", + * "temperature", + * "top_p", + * "tools", + * "tool_choice", + * "function_call", + * "functions", + * "max_retries", + * "extra_headers", + * "parallel_tool_calls", + * "response_format" + * ] + * } + * ] + * } * ``` */ class ModelGroupRetrieveInfoParams diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponse.kt index 16a3af71..5ad8004e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/modelgroup/ModelGroupRetrieveInfoResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModelGroupRetrieveInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/models/ModelListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/models/ModelListResponse.kt index 7f0a9756..3137b047 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/models/ModelListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/models/ModelListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModelListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponse.kt index c609450f..78b198be 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/moderations/ModerationCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModerationCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponse.kt index 74dd8434..ee12c4ec 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAICreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class OpenAICreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponse.kt index a6746603..8f81e28f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class OpenAIDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponse.kt index d24c944e..bb237d6f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIPatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class OpenAIPatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponse.kt index 22e09744..cfb4bb19 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class OpenAIRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponse.kt index 5f533162..1c4abd3c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/OpenAIUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class OpenAIUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponse.kt index c51d2725..5d8e34ee 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentCompleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class DeploymentCompleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponse.kt index 2890ea6c..cfb59461 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/DeploymentEmbedResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class DeploymentEmbedResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponse.kt index d573103f..ea42731e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/openai/deployments/chat/ChatCompleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ChatCompleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt index 39b50671..8d2a58e6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrgMember.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OrgMember +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val role: JsonField, private val userEmail: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt index 23b138bf..b93abdfa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberParams.kt @@ -369,6 +369,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val member: JsonField, private val organizationId: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt index e80619be..341802a8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationAddMemberResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OrganizationAddMemberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val organizationId: JsonField, private val updatedOrganizationMemberships: JsonField>, @@ -291,6 +292,7 @@ private constructor( * organization */ class UpdatedOrganizationMembership + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -723,6 +725,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1200,6 +1203,7 @@ private constructor( } class UpdatedUser + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userId: JsonField, private val budgetDuration: JsonField, @@ -1904,6 +1908,7 @@ private constructor( * the organization */ class OrganizationMembership + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -2350,6 +2355,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt index c03f5500..fe6caaf4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateParams.kt @@ -30,27 +30,27 @@ import kotlin.jvm.optionals.getOrNull * Only admins can create orgs. * * # Parameters - * - organization_alias: _str_ - The name of the organization. - * - models: _List_ - The models the organization has access to. - * - budget_id: _Optional[str]_ - The id for a budget (tpm/rpm/max budget) for the organization. + * - organization_alias: *str* - The name of the organization. + * - models: *List* - The models the organization has access to. + * - budget_id: *Optional[str]* - The id for a budget (tpm/rpm/max budget) for the organization. * - * ### IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS - * - max_budget: _Optional[float]_ - Max budget for org - * - tpm_limit: _Optional[int]_ - Max tpm limit for org - * - rpm_limit: _Optional[int]_ - Max rpm limit for org - * - max_parallel_requests: _Optional[int]_ - [Not Implemented Yet] Max parallel requests for org - * - soft_budget: _Optional[float]_ - [Not Implemented Yet] Get a slack alert when this soft budget + * ### IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS ### + * - max_budget: *Optional[float]* - Max budget for org + * - tpm_limit: *Optional[int]* - Max tpm limit for org + * - rpm_limit: *Optional[int]* - Max rpm limit for org + * - max_parallel_requests: *Optional[int]* - [Not Implemented Yet] Max parallel requests for org + * - soft_budget: *Optional[float]* - [Not Implemented Yet] Get a slack alert when this soft budget * is reached. Don't block requests. - * - model_max_budget: _Optional[dict]_ - Max budget for a specific model - * - budget_duration: _Optional[str]_ - Frequency of reseting org budget - * - metadata: _Optional[dict]_ - Metadata for organization, store information for organization. + * - model_max_budget: *Optional[dict]* - Max budget for a specific model + * - budget_duration: *Optional[str]* - Frequency of reseting org budget + * - metadata: *Optional[dict]* - Metadata for organization, store information for organization. * Example metadata - {"extra_info": "some info"} - * - blocked: _bool_ - Flag indicating if the org is blocked or not - will stop all calls from keys + * - blocked: *bool* - Flag indicating if the org is blocked or not - will stop all calls from keys * with this org_id. - * - tags: _Optional[List[str]]_ - Tags for + * - tags: *Optional[List[str]]* - Tags for * [tracking spend](https://llm.vercel.app/docs/proxy/enterprise#tracking-spend-for-custom-tags) * and/or doing [tag-based routing](https://llm.vercel.app/docs/proxy/tag_routing). - * - organization_id: _Optional[str]_ - The organization id of the team. Default is None. Create via + * - organization_id: *Optional[str]* - The organization id of the team. Default is None. Create via * `/organization/new`. * - model_aliases: Optional[dict] - Model aliases for the team. * [Docs](https://docs.hanzo.ai/docs/proxy/team_based_routing#create-team-with-model-alias) @@ -618,6 +618,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val organizationAlias: JsonField, private val budgetDuration: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt index 2f131609..4a32e2db 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationCreateResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OrganizationCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val createdAt: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt index b5ad651f..a7336195 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberParams.kt @@ -300,6 +300,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val organizationId: JsonField, private val userEmail: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt index b4c74e15..ae15ca5b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteMemberResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class OrganizationDeleteMemberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt index ec43b367..b075f422 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteParams.kt @@ -261,6 +261,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val organizationIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt index 873e0117..9b7f72ac 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt @@ -34,6 +34,7 @@ import kotlin.jvm.optionals.getOrNull /** Returned by the /organization/info endpoint and /organization/list endpoint */ class OrganizationDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val createdAt: JsonField, @@ -633,6 +634,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1058,6 +1060,7 @@ private constructor( * organization */ class Member + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -1487,6 +1490,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1964,6 +1968,7 @@ private constructor( } class Team + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val admins: JsonField>, @@ -2869,6 +2874,7 @@ private constructor( (if (tpmLimit.asKnown().isPresent) 1 else 0) class LlmModelTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdBy: JsonField, private val updatedBy: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt index 80909592..3ac6d955 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt @@ -34,6 +34,7 @@ import kotlin.jvm.optionals.getOrNull /** Returned by the /organization/info endpoint and /organization/list endpoint */ class OrganizationListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val createdAt: JsonField, @@ -633,6 +634,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1058,6 +1060,7 @@ private constructor( * organization */ class Member + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -1487,6 +1490,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1964,6 +1968,7 @@ private constructor( } class Team + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val admins: JsonField>, @@ -2869,6 +2874,7 @@ private constructor( (if (tpmLimit.asKnown().isPresent) 1 else 0) class LlmModelTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdBy: JsonField, private val updatedBy: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt index 95ad9358..f83afd89 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberParams.kt @@ -397,6 +397,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val organizationId: JsonField, private val maxBudgetInOrganization: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt index c64c3ace..3605a1a0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt @@ -23,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull * organization */ class OrganizationUpdateMemberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -438,6 +439,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt index b471b003..2954c181 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateParams.kt @@ -400,6 +400,7 @@ private constructor( /** Represents user-controllable params for a LLM_OrganizationTable record */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val metadata: JsonValue, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt index f223daf3..419f3ff1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt @@ -34,6 +34,7 @@ import kotlin.jvm.optionals.getOrNull /** Returned by the /organization/info endpoint and /organization/list endpoint */ class OrganizationUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val createdAt: JsonField, @@ -633,6 +634,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1058,6 +1060,7 @@ private constructor( * organization */ class Member + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -1487,6 +1490,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1964,6 +1968,7 @@ private constructor( } class Team + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val admins: JsonField>, @@ -2869,6 +2874,7 @@ private constructor( (if (tpmLimit.asKnown().isPresent) 1 else 0) class LlmModelTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdBy: JsonField, private val updatedBy: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt index 806c882b..fb644f71 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedParams.kt @@ -252,6 +252,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val organizations: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt index 0aab3a56..801bb455 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoDeprecatedResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class InfoDeprecatedResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt index f09edec8..f33b1f53 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt @@ -34,6 +34,7 @@ import kotlin.jvm.optionals.getOrNull /** Returned by the /organization/info endpoint and /organization/list endpoint */ class InfoRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val createdAt: JsonField, @@ -633,6 +634,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1058,6 +1060,7 @@ private constructor( * organization */ class Member + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -1487,6 +1490,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1964,6 +1968,7 @@ private constructor( } class Team + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val admins: JsonField>, @@ -2869,6 +2874,7 @@ private constructor( (if (tpmLimit.asKnown().isPresent) 1 else 0) class LlmModelTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdBy: JsonField, private val updatedBy: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParams.kt index 0fb6979d..c9a2f357 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsParams.kt @@ -23,32 +23,32 @@ import java.util.Objects * * ```json * { - * "providers": { - * "openai": { - * "budget_limit": 1e-12, - * "time_period": "1d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "azure": { - * "budget_limit": 100.0, - * "time_period": "1d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "anthropic": { - * "budget_limit": 100.0, - * "time_period": "10d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "vertex_ai": { - * "budget_limit": 100.0, - * "time_period": "12d", - * "spend": 0.0, - * "budget_reset_at": null + * "providers": { + * "openai": { + * "budget_limit": 1e-12, + * "time_period": "1d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "azure": { + * "budget_limit": 100.0, + * "time_period": "1d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "anthropic": { + * "budget_limit": 100.0, + * "time_period": "10d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "vertex_ai": { + * "budget_limit": 100.0, + * "time_period": "12d", + * "spend": 0.0, + * "budget_reset_at": null + * } * } - * } * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt index 17d4a48c..7f948c75 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/provider/ProviderListBudgetsResponse.kt @@ -21,6 +21,7 @@ import kotlin.jvm.optionals.getOrNull * Complete provider budget configuration and status. Maps provider names to their budget configs. */ class ProviderListBudgetsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providers: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt index 348863f6..19066589 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class RerankCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Response.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Response.kt index 0c38eb51..8b159d62 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Response.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV1Response.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class RerankCreateV1Response +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Response.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Response.kt index 147b447a..4734cd36 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Response.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/rerank/RerankCreateV2Response.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class RerankCreateV2Response +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponse.kt index 5e378a70..87582e29 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ResponseCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponse.kt index ac7d1d14..241c75c4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ResponseDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponse.kt index 3d264a57..f8e1e296 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/ResponseRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ResponseRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponse.kt index 6bb8a297..4217f704 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/responses/inputitems/InputItemListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class InputItemListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/routes/RouteListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/routes/RouteListResponse.kt index e667c0c5..c72184dd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/routes/RouteListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/routes/RouteListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class RouteListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponse.kt index 21c85835..55b0ec9a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/settings/SettingRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class SettingRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt index d6842ad2..31584d3d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendParams.kt @@ -324,6 +324,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val completionResponse: JsonValue, private val messages: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponse.kt index b95d4f4d..6e7985cf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendCalculateSpendResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class SpendCalculateSpendResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt index 9ef959a2..1e25ad68 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListLogsResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SpendListLogsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apiKey: JsonField, private val callType: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt index 152edbc9..044b2b02 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/spend/SpendListTagsResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SpendListTagsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apiKey: JsonField, private val callType: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt index a62c253e..565b6b46 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/BlockTeamRequest.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class BlockTeamRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt index 581339dd..c049fb53 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/Member.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Member +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val role: JsonField, private val userEmail: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt index 01553a23..27af3077 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberParams.kt @@ -339,6 +339,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val member: JsonField, private val teamId: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt index 2a79cf12..67df9489 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamAddMemberResponse.kt @@ -32,6 +32,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TeamAddMemberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val updatedTeamMemberships: JsonField>, @@ -1028,6 +1029,7 @@ private constructor( (if (tpmLimit.asKnown().isPresent) 1 else 0) class UpdatedTeamMembership + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetId: JsonField, private val llmBudgetTable: JsonField, @@ -1285,6 +1287,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -1746,6 +1749,7 @@ private constructor( } class UpdatedUser + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userId: JsonField, private val budgetDuration: JsonField, @@ -2450,6 +2454,7 @@ private constructor( * the organization */ class OrganizationMembership + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val organizationId: JsonField, @@ -2896,6 +2901,7 @@ private constructor( /** Represents user-controllable params for a LLM_BudgetTable record */ class LlmBudgetTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val budgetDuration: JsonField, private val maxBudget: JsonField, @@ -3438,6 +3444,7 @@ private constructor( } class LlmModelTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdBy: JsonField, private val updatedBy: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt index decbf4ab..914355d4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamBlockResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamBlockResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt index fd5b1d6e..ff602392 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateParams.kt @@ -58,7 +58,7 @@ import kotlin.jvm.optionals.getOrNull * [Docs](https://docs.hanzo.ai/docs/proxy/guardrails) Returns: * - team_id: (str) Unique team id - used for tracking spend across multiple keys for same team id. * - * \_deprecated_params: + * _deprecated_params: * - admins: list - A list of user_id's for the admin role * - users: list - A list of user_id's for the user role * @@ -71,12 +71,12 @@ import kotlin.jvm.optionals.getOrNull * }' * * ``` - * ``` + * ``` * curl --location 'http://0.0.0.0:4000/team/new' --header 'Authorization: Bearer sk-1234' --header 'Content-Type: application/json' --data '{ - * "team_alias": "QA Prod Bot", - * "max_budget": 0.000000001, - * "budget_duration": "1d" - * }' + * "team_alias": "QA Prod Bot", + * "max_budget": 0.000000001, + * "budget_duration": "1d" + * }' * ``` */ class TeamCreateParams @@ -737,6 +737,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val admins: JsonField>, private val blocked: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt index 45219e0f..4c6fff57 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamCreateResponse.kt @@ -32,6 +32,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TeamCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val admins: JsonField>, @@ -917,6 +918,7 @@ private constructor( (if (tpmLimit.asKnown().isPresent) 1 else 0) class LlmModelTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdBy: JsonField, private val updatedBy: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt index 622e3a25..30222059 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteParams.kt @@ -287,6 +287,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt index 014228e5..e2973fb8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponse.kt index f1e8b32e..1e402eea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamDisableLoggingResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamDisableLoggingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponse.kt index c8c191b5..be56890c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListAvailableResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamListAvailableResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt index de4aca74..79cf2b73 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt index 9d4b4533..10241e8b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberParams.kt @@ -312,6 +312,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val userEmail: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt index 8322bfea..c690ef71 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRemoveMemberResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamRemoveMemberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt index 417a6003..d32f2c12 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamRetrieveInfoResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamRetrieveInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt index 5ac3ccef..ed2bca08 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUnblockResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamUnblockResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt index bb2e1ea5..975c7bcd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberParams.kt @@ -369,6 +369,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val maxBudgetInTeam: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt index e826a737..ac162ac9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateMemberResponse.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TeamUpdateMemberResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val userId: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt index a8809648..226df879 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateParams.kt @@ -658,6 +658,7 @@ private constructor( * None budget_duration: Optional[str] = None guardrails: Optional[List[str]] = None */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val teamId: JsonField, private val blocked: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt index 07ec4724..a0f96f74 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/TeamUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TeamUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt index 6c4576f9..eb4cc825 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddParams.kt @@ -385,6 +385,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val callbackName: JsonField, private val callbackVars: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt index cc755bc1..49eb3bcd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackAddResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CallbackAddResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt index 0d172325..cd606a6e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/callback/CallbackRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CallbackRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt index a4cf951c..f241c5b5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddParams.kt @@ -287,6 +287,7 @@ private constructor( /** Request to add models to a team */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val models: JsonField>, private val teamId: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt index 706e38b5..f43701d3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelAddResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModelAddResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt index bea5af0a..01911006 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveParams.kt @@ -291,6 +291,7 @@ private constructor( /** Request to delete models from a team */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val models: JsonField>, private val teamId: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt index 672aff99..7d3ad8be 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/team/model/ModelRemoveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ModelRemoveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/test/TestPingResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/test/TestPingResponse.kt index b5bd94d6..6c9ab0e4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/test/TestPingResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/test/TestPingResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class TestPingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt index 109f589e..098bf218 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ThreadCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt index 1385ce9f..0f0725b0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/ThreadRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class ThreadRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt index 1daecb2c..e4919e8a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class MessageCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt index 66804f66..ce54cc5d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/messages/MessageListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class MessageListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt index 131b26a9..da78f378 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/threads/runs/RunCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class RunCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt index 52d0d00a..f8a138b6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateParams.kt @@ -945,6 +945,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aliases: JsonValue, private val allowedCacheControls: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt index aaaa8b49..e699e2b6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserCreateResponse.kt @@ -22,6 +22,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class UserCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val expires: JsonField, private val key: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt index a2ed8ca6..2ba95889 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteParams.kt @@ -290,6 +290,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val userIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt index 21520ce7..46092451 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UserDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListParams.kt index b4299083..2374da1b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListParams.kt @@ -14,10 +14,13 @@ import kotlin.jvm.optionals.getOrNull * * Used by the UI to populate the user lists. * - * Parameters: role: Optional[str] Filter users by role. Can be one of: - proxy_admin - - * proxy_admin_viewer - internal_user - internal_user_viewer user_ids: Optional[str] Get list of - * users by user_ids. Comma separated list of user_ids. page: int The page number to return - * page_size: int The number of items per page + * Parameters: role: Optional[str] Filter users by role. Can be one of: + * - proxy_admin + * - proxy_admin_viewer + * - internal_user + * - internal_user_viewer user_ids: Optional[str] Get list of users by user_ids. Comma separated + * list of user_ids. page: int The page number to return page_size: int The number of items per + * page * * Currently - admin-only endpoint. * diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt index 6a31c0f8..f8755a32 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UserListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt index 65f09955..3765c834 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserRetrieveInfoResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UserRetrieveInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt index fe5444d1..3efb9245 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateParams.kt @@ -32,44 +32,54 @@ import kotlin.jvm.optionals.getOrNull * }' * ``` * - * Parameters: - user_id: Optional[str] - Specify a user id. If not set, a unique id will be - * generated. - user_email: Optional[str] - Specify a user email. - password: Optional[str] - - * Specify a user password. - user_alias: Optional[str] - A descriptive name for you to know who - * this user id refers to. - teams: Optional[list] - specify a list of team id's a user belongs - * to. - send_invite_email: Optional[bool] - Specify if an invite email should be sent. - user_role: - * Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", "internal_user", - * "internal_user_viewer", "team", "customer". Info about each role here: - * `https://github.com/hanzoai/llm/llm/proxy/_types.py#L20` - max_budget: Optional[float] - Specify - * max budget for a given user. - budget_duration: Optional[str] - Budget is reset at the end of - * specified duration. If not set, budget is never reset. You can set duration as seconds ("30s"), - * minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo"). - models: Optional[list] - - * Model_name's a user is allowed to call. (if empty, key is allowed to call all models) - - * tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per minute) - rpm_limit: - * Optional[int] - Specify rpm limit for a given user (Requests per minute) - auto_create_key: - * bool - Default=True. Flag used for returning a key as part of the /user/new response - aliases: - * Optional[dict] - Model aliases for the - * user - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) - config: - * Optional[dict] - [DEPRECATED PARAM] User-specific config. - allowed_cache_controls: - * Optional[list] - List of allowed cache control values. Example - ["no-cache", "no-store"]. See - * all values - https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request- - - * blocked: Optional[bool] - [Not Implemented Yet] Whether the user is blocked. - guardrails: - * Optional[List[str]] - [Not Implemented Yet] List of active guardrails for the user - permissions: - * Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning off pii masking. - - * metadata: Optional[dict] - Metadata for user, store information for user. Example metadata = - * {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } - max_parallel_requests: - * Optional[int] - Rate limit a user based on the number of parallel requests. Raises 429 error, if - * user's parallel requests > x. - soft_budget: Optional[float] - Get alerts when user crosses given - * budget, doesn't block requests. - model_max_budget: Optional[dict] - Model-specific max budget - * for user. [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-budgets-to-keys) - - * model_rpm_limit: Optional[float] - Model-specific rpm limit for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) - - * model_tpm_limit: Optional[float] - Model-specific tpm limit for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) - spend: - * Optional[float] - Amount spent by user. Default is 0. Will be updated by proxy whenever user is - * used. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), - * months ("1mo"). - team_id: Optional[str] - [DEPRECATED PARAM] The team id of the user. Default is - * None. - duration: Optional[str] - [NOT IMPLEMENTED]. - key_alias: - * Optional[str] - [NOT IMPLEMENTED]. + * Parameters: + * - user_id: Optional[str] - Specify a user id. If not set, a unique id will be generated. + * - user_email: Optional[str] - Specify a user email. + * - password: Optional[str] - Specify a user password. + * - user_alias: Optional[str] - A descriptive name for you to know who this user id refers to. + * - teams: Optional[list] - specify a list of team id's a user belongs to. + * - send_invite_email: Optional[bool] - Specify if an invite email should be sent. + * - user_role: Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", + * "internal_user", "internal_user_viewer", "team", "customer". Info about each role here: + * `https://github.com/hanzoai/llm/llm/proxy/_types.py#L20` + * - max_budget: Optional[float] - Specify max budget for a given user. + * - budget_duration: Optional[str] - Budget is reset at the end of specified duration. If not set, + * budget is never reset. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), + * days ("30d"), months ("1mo"). + * - models: Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed to + * call all models) + * - tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per minute) + * - rpm_limit: Optional[int] - Specify rpm limit for a given user (Requests per minute) + * - auto_create_key: bool - Default=True. Flag used for returning a key as part of the /user/new + * response + * - aliases: Optional[dict] - Model aliases for the + * user - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) + * - config: Optional[dict] - [DEPRECATED PARAM] User-specific config. + * - allowed_cache_controls: Optional[list] - List of allowed cache control values. + * Example - ["no-cache", "no-store"]. See all values - + * https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request- + * - blocked: Optional[bool] - [Not Implemented Yet] Whether the user is blocked. + * - guardrails: Optional[List[str]] - [Not Implemented Yet] List of active guardrails for the user + * - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning off + * pii masking. + * - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata = + * {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } + * - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel + * requests. Raises 429 error, if user's parallel requests > x. + * - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block + * requests. + * - model_max_budget: Optional[dict] - Model-specific max budget for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-budgets-to-keys) + * - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) + * - model_tpm_limit: Optional[float] - Model-specific tpm limit for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) + * - spend: Optional[float] - Amount spent by user. Default is 0. Will be updated by proxy whenever + * user is used. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days + * ("30d"), months ("1mo"). + * - team_id: Optional[str] - [DEPRECATED PARAM] The team id of the user. Default is None. + * - duration: Optional[str] - [NOT IMPLEMENTED]. + * - key_alias: Optional[str] - [NOT IMPLEMENTED]. */ class UserUpdateParams private constructor( @@ -823,6 +833,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aliases: JsonValue, private val allowedCacheControls: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt index 1a7c0198..aa8cc8a6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UserUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponse.kt index a1ca4e92..1cbb9c7a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilGetSupportedOpenAIParamsResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class UtilGetSupportedOpenAIParamsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt index 1ab95284..3a738bf7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterParams.kt @@ -305,6 +305,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val model: JsonField, private val messages: JsonField>, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt index 9cd27828..8dad02ef 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTokenCounterResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class UtilTokenCounterResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val modelUsed: JsonField, private val requestModel: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt index 8d96a926..f0e2b71e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestParams.kt @@ -249,6 +249,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val callType: JsonField, private val requestBody: JsonValue, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt index 55ec014f..67b61a4e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/utils/UtilTransformRequestResponse.kt @@ -17,6 +17,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class UtilTransformRequestResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val error: JsonField, private val rawRequestApiBase: JsonField, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt index 90bb2389..97cf36e0 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class VertexAiCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt index dd5b4008..67130afd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class VertexAiDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt index 5fc17274..e8fdd2c1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiPatchResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class VertexAiPatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt index 91c25f08..8d312fed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiRetrieveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class VertexAiRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt index eafc33d2..b339921e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/vertexai/VertexAiUpdateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class VertexAiUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt index e959c52d..0e7e38fb 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/AddServiceAsync.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.AddAddAllowedIpResponse +import ai.hanzo.api.models.add.IpAddress import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -34,6 +35,17 @@ interface AddServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see addAllowedIp */ + fun addAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addAllowedIp(AddAddAllowedIpParams.builder().ipAddress(ipAddress).build(), requestOptions) + + /** @see addAllowedIp */ + fun addAllowedIp(ipAddress: IpAddress): CompletableFuture = + addAllowedIp(ipAddress, RequestOptions.none()) + /** A view of [AddServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -58,5 +70,21 @@ interface AddServiceAsync { params: AddAddAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see addAllowedIp */ + fun addAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + addAllowedIp( + AddAddAllowedIpParams.builder().ipAddress(ipAddress).build(), + requestOptions, + ) + + /** @see addAllowedIp */ + fun addAllowedIp( + ipAddress: IpAddress + ): CompletableFuture> = + addAllowedIp(ipAddress, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt index 7a0fca76..2435a06e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/BudgetServiceAsync.kt @@ -13,6 +13,7 @@ import ai.hanzo.api.models.budget.BudgetInfoParams import ai.hanzo.api.models.budget.BudgetInfoResponse import ai.hanzo.api.models.budget.BudgetListParams import ai.hanzo.api.models.budget.BudgetListResponse +import ai.hanzo.api.models.budget.BudgetNew import ai.hanzo.api.models.budget.BudgetSettingsParams import ai.hanzo.api.models.budget.BudgetSettingsResponse import ai.hanzo.api.models.budget.BudgetUpdateParams @@ -59,6 +60,17 @@ interface BudgetServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see create */ + fun create( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(BudgetCreateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see create */ + fun create(budgetNew: BudgetNew): CompletableFuture = + create(budgetNew, RequestOptions.none()) + /** * Update an existing budget object. * @@ -84,6 +96,17 @@ interface BudgetServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see update */ + fun update( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(BudgetUpdateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see update */ + fun update(budgetNew: BudgetNew): CompletableFuture = + update(budgetNew, RequestOptions.none()) + /** List all the created budgets in proxy db. Used on Admin UI. */ fun list(): CompletableFuture = list(BudgetListParams.none()) @@ -178,6 +201,17 @@ interface BudgetServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see create */ + fun create( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(BudgetCreateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see create */ + fun create(budgetNew: BudgetNew): CompletableFuture> = + create(budgetNew, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /budget/update`, but is otherwise the same as * [BudgetServiceAsync.update]. @@ -193,6 +227,17 @@ interface BudgetServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see update */ + fun update( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(BudgetUpdateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see update */ + fun update(budgetNew: BudgetNew): CompletableFuture> = + update(budgetNew, RequestOptions.none()) + /** * Returns a raw HTTP response for `get /budget/list`, but is otherwise the same as * [BudgetServiceAsync.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt index 5b943fc1..bd2e05c3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CacheServiceAsync.kt @@ -36,7 +36,7 @@ interface CacheServiceAsync { * `x-llm-cache-key` in the headers * * Parameters: - * - **keys**: _Optional[List[str]]_ - A list of keys to delete from the cache. Example {"keys": + * - **keys**: *Optional[List[str]]* - A list of keys to delete from the cache. Example {"keys": * ["key1", "key2"]} * * ```shell diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt index 0957d328..d3b73932 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/CustomerServiceAsync.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.customer.BlockUsers import ai.hanzo.api.models.customer.CustomerBlockParams import ai.hanzo.api.models.customer.CustomerBlockResponse import ai.hanzo.api.models.customer.CustomerCreateParams @@ -195,6 +196,17 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see block */ + fun block( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + block(CustomerBlockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see block */ + fun block(blockUsers: BlockUsers): CompletableFuture = + block(blockUsers, RequestOptions.none()) + /** * Get information about an end-user. An `end_user` is a customer (external user) of the proxy. * @@ -238,6 +250,17 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see unblock */ + fun unblock( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unblock(CustomerUnblockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see unblock */ + fun unblock(blockUsers: BlockUsers): CompletableFuture = + unblock(blockUsers, RequestOptions.none()) + /** * A view of [CustomerServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -337,6 +360,19 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see block */ + fun block( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + block(CustomerBlockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see block */ + fun block( + blockUsers: BlockUsers + ): CompletableFuture> = + block(blockUsers, RequestOptions.none()) + /** * Returns a raw HTTP response for `get /customer/info`, but is otherwise the same as * [CustomerServiceAsync.retrieveInfo]. @@ -366,5 +402,18 @@ interface CustomerServiceAsync { params: CustomerUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see unblock */ + fun unblock( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + unblock(CustomerUnblockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see unblock */ + fun unblock( + blockUsers: BlockUsers + ): CompletableFuture> = + unblock(blockUsers, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt index 9c997f12..9f999873 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/DeleteServiceAsync.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.add.IpAddress import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import ai.hanzo.api.models.delete.DeleteCreateAllowedIpResponse import java.util.concurrent.CompletableFuture @@ -36,6 +37,20 @@ interface DeleteServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see createAllowedIp */ + fun createAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createAllowedIp( + DeleteCreateAllowedIpParams.builder().ipAddress(ipAddress).build(), + requestOptions, + ) + + /** @see createAllowedIp */ + fun createAllowedIp(ipAddress: IpAddress): CompletableFuture = + createAllowedIp(ipAddress, RequestOptions.none()) + /** * A view of [DeleteServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -64,5 +79,21 @@ interface DeleteServiceAsync { params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see createAllowedIp */ + fun createAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createAllowedIp( + DeleteCreateAllowedIpParams.builder().ipAddress(ipAddress).build(), + requestOptions, + ) + + /** @see createAllowedIp */ + fun createAllowedIp( + ipAddress: IpAddress + ): CompletableFuture> = + createAllowedIp(ipAddress, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt index f6a81ae0..0e665d9a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/GuardrailServiceAsync.kt @@ -37,24 +37,24 @@ interface GuardrailServiceAsync { * Example Response: * ```json * { - * "guardrails": [ - * { - * "guardrail_name": "bedrock-pre-guard", - * "guardrail_info": { - * "params": [ - * { - * "name": "toxicity_score", - * "type": "float", - * "description": "Score between 0-1 indicating content toxicity level" - * }, - * { - * "name": "pii_detection", - * "type": "boolean" - * } - * ] - * } - * } - * ] + * "guardrails": [ + * { + * "guardrail_name": "bedrock-pre-guard", + * "guardrail_info": { + * "params": [ + * { + * "name": "toxicity_score", + * "type": "float", + * "description": "Score between 0-1 indicating content toxicity level" + * }, + * { + * "name": "pii_detection", + * "type": "boolean" + * } + * ] + * } + * } + * ] * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt index 9f032875..929d2fa8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/KeyServiceAsync.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.key.BlockKeyRequest import ai.hanzo.api.models.key.GenerateKeyResponse import ai.hanzo.api.models.key.KeyBlockParams import ai.hanzo.api.models.key.KeyBlockResponse @@ -194,6 +195,17 @@ interface KeyServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see block */ + fun block( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + block(KeyBlockParams.builder().blockKeyRequest(blockKeyRequest).build(), requestOptions) + + /** @see block */ + fun block(blockKeyRequest: BlockKeyRequest): CompletableFuture> = + block(blockKeyRequest, RequestOptions.none()) + /** * Check the health of the key * @@ -213,7 +225,9 @@ interface KeyServiceAsync { * { * "key": "healthy", * "logging_callbacks": { - * "callbacks": ["gcs_bucket"], + * "callbacks": [ + * "gcs_bucket" + * ], * "status": "healthy", * "details": "No logger exceptions triggered, system is healthy. Manually check if logs were sent to ['gcs_bucket']" * } @@ -225,7 +239,9 @@ interface KeyServiceAsync { * { * "key": "unhealthy", * "logging_callbacks": { - * "callbacks": ["gcs_bucket"], + * "callbacks": [ + * "gcs_bucket" + * ], * "status": "unhealthy", * "details": "Logger exceptions triggered, system is unhealthy: Failed to load vertex credentials. Check to see if credentials containing partial/invalid information." * } @@ -487,6 +503,17 @@ interface KeyServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see unblock */ + fun unblock( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unblock(KeyUnblockParams.builder().blockKeyRequest(blockKeyRequest).build(), requestOptions) + + /** @see unblock */ + fun unblock(blockKeyRequest: BlockKeyRequest): CompletableFuture = + unblock(blockKeyRequest, RequestOptions.none()) + /** A view of [KeyServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -575,6 +602,19 @@ interface KeyServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> + /** @see block */ + fun block( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> = + block(KeyBlockParams.builder().blockKeyRequest(blockKeyRequest).build(), requestOptions) + + /** @see block */ + fun block( + blockKeyRequest: BlockKeyRequest + ): CompletableFuture>> = + block(blockKeyRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /key/health`, but is otherwise the same as * [KeyServiceAsync.checkHealth]. @@ -707,5 +747,21 @@ interface KeyServiceAsync { params: KeyUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see unblock */ + fun unblock( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + unblock( + KeyUnblockParams.builder().blockKeyRequest(blockKeyRequest).build(), + requestOptions, + ) + + /** @see unblock */ + fun unblock( + blockKeyRequest: BlockKeyRequest + ): CompletableFuture> = + unblock(blockKeyRequest, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt index 14cd230a..3f244d6e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ModelGroupServiceAsync.kt @@ -54,112 +54,118 @@ interface ModelGroupServiceAsync { * * Example Response: * ```json - * { - * "data": [ * { - * "model_group": "rerank-english-v3.0", - * "providers": ["cohere"], - * "max_input_tokens": null, - * "max_output_tokens": null, - * "input_cost_per_token": 0.0, - * "output_cost_per_token": 0.0, - * "mode": null, - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": false, - * "supports_function_calling": false, - * "supported_openai_params": [ - * "stream", - * "temperature", - * "max_tokens", - * "logit_bias", - * "top_p", - * "frequency_penalty", - * "presence_penalty", - * "stop", - * "n", - * "extra_headers" - * ] - * }, - * { - * "model_group": "gpt-3.5-turbo", - * "providers": ["openai"], - * "max_input_tokens": 16385.0, - * "max_output_tokens": 4096.0, - * "input_cost_per_token": 1.5e-6, - * "output_cost_per_token": 2e-6, - * "mode": "chat", - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": false, - * "supports_function_calling": true, - * "supported_openai_params": [ - * "frequency_penalty", - * "logit_bias", - * "logprobs", - * "top_logprobs", - * "max_tokens", - * "max_completion_tokens", - * "n", - * "presence_penalty", - * "seed", - * "stop", - * "stream", - * "stream_options", - * "temperature", - * "top_p", - * "tools", - * "tool_choice", - * "function_call", - * "functions", - * "max_retries", - * "extra_headers", - * "parallel_tool_calls", - * "response_format" - * ] - * }, - * { - * "model_group": "llava-hf", - * "providers": ["openai"], - * "max_input_tokens": null, - * "max_output_tokens": null, - * "input_cost_per_token": 0.0, - * "output_cost_per_token": 0.0, - * "mode": null, - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": true, - * "supports_function_calling": false, - * "supported_openai_params": [ - * "frequency_penalty", - * "logit_bias", - * "logprobs", - * "top_logprobs", - * "max_tokens", - * "max_completion_tokens", - * "n", - * "presence_penalty", - * "seed", - * "stop", - * "stream", - * "stream_options", - * "temperature", - * "top_p", - * "tools", - * "tool_choice", - * "function_call", - * "functions", - * "max_retries", - * "extra_headers", - * "parallel_tool_calls", - * "response_format" - * ] - * } - * ] - * } + * "data": [ + * { + * "model_group": "rerank-english-v3.0", + * "providers": [ + * "cohere" + * ], + * "max_input_tokens": null, + * "max_output_tokens": null, + * "input_cost_per_token": 0.0, + * "output_cost_per_token": 0.0, + * "mode": null, + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": false, + * "supports_function_calling": false, + * "supported_openai_params": [ + * "stream", + * "temperature", + * "max_tokens", + * "logit_bias", + * "top_p", + * "frequency_penalty", + * "presence_penalty", + * "stop", + * "n", + * "extra_headers" + * ] + * }, + * { + * "model_group": "gpt-3.5-turbo", + * "providers": [ + * "openai" + * ], + * "max_input_tokens": 16385.0, + * "max_output_tokens": 4096.0, + * "input_cost_per_token": 1.5e-06, + * "output_cost_per_token": 2e-06, + * "mode": "chat", + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": false, + * "supports_function_calling": true, + * "supported_openai_params": [ + * "frequency_penalty", + * "logit_bias", + * "logprobs", + * "top_logprobs", + * "max_tokens", + * "max_completion_tokens", + * "n", + * "presence_penalty", + * "seed", + * "stop", + * "stream", + * "stream_options", + * "temperature", + * "top_p", + * "tools", + * "tool_choice", + * "function_call", + * "functions", + * "max_retries", + * "extra_headers", + * "parallel_tool_calls", + * "response_format" + * ] + * }, + * { + * "model_group": "llava-hf", + * "providers": [ + * "openai" + * ], + * "max_input_tokens": null, + * "max_output_tokens": null, + * "input_cost_per_token": 0.0, + * "output_cost_per_token": 0.0, + * "mode": null, + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": true, + * "supports_function_calling": false, + * "supported_openai_params": [ + * "frequency_penalty", + * "logit_bias", + * "logprobs", + * "top_logprobs", + * "max_tokens", + * "max_completion_tokens", + * "n", + * "presence_penalty", + * "seed", + * "stop", + * "stream", + * "stream_options", + * "temperature", + * "top_p", + * "tools", + * "tool_choice", + * "function_call", + * "functions", + * "max_retries", + * "extra_headers", + * "parallel_tool_calls", + * "response_format" + * ] + * } + * ] + * } * ``` */ fun retrieveInfo(): CompletableFuture = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt index 35df5069..fc1cf340 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/OrganizationServiceAsync.kt @@ -47,28 +47,28 @@ interface OrganizationServiceAsync { * Only admins can create orgs. * * # Parameters - * - organization_alias: _str_ - The name of the organization. - * - models: _List_ - The models the organization has access to. - * - budget_id: _Optional[str]_ - The id for a budget (tpm/rpm/max budget) for the organization. + * - organization_alias: *str* - The name of the organization. + * - models: *List* - The models the organization has access to. + * - budget_id: *Optional[str]* - The id for a budget (tpm/rpm/max budget) for the organization. * - * ### IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS - * - max_budget: _Optional[float]_ - Max budget for org - * - tpm_limit: _Optional[int]_ - Max tpm limit for org - * - rpm_limit: _Optional[int]_ - Max rpm limit for org - * - max_parallel_requests: _Optional[int]_ - [Not Implemented Yet] Max parallel requests for + * ### IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS ### + * - max_budget: *Optional[float]* - Max budget for org + * - tpm_limit: *Optional[int]* - Max tpm limit for org + * - rpm_limit: *Optional[int]* - Max rpm limit for org + * - max_parallel_requests: *Optional[int]* - [Not Implemented Yet] Max parallel requests for * org - * - soft_budget: _Optional[float]_ - [Not Implemented Yet] Get a slack alert when this soft + * - soft_budget: *Optional[float]* - [Not Implemented Yet] Get a slack alert when this soft * budget is reached. Don't block requests. - * - model_max_budget: _Optional[dict]_ - Max budget for a specific model - * - budget_duration: _Optional[str]_ - Frequency of reseting org budget - * - metadata: _Optional[dict]_ - Metadata for organization, store information for organization. + * - model_max_budget: *Optional[dict]* - Max budget for a specific model + * - budget_duration: *Optional[str]* - Frequency of reseting org budget + * - metadata: *Optional[dict]* - Metadata for organization, store information for organization. * Example metadata - {"extra_info": "some info"} - * - blocked: _bool_ - Flag indicating if the org is blocked or not - will stop all calls from + * - blocked: *bool* - Flag indicating if the org is blocked or not - will stop all calls from * keys with this org_id. - * - tags: _Optional[List[str]]_ - Tags for + * - tags: *Optional[List[str]]* - Tags for * [tracking spend](https://llm.vercel.app/docs/proxy/enterprise#tracking-spend-for-custom-tags) * and/or doing [tag-based routing](https://llm.vercel.app/docs/proxy/tag_routing). - * - organization_id: _Optional[str]_ - The organization id of the team. Default is None. Create + * - organization_id: *Optional[str]* - The organization id of the team. Default is None. Create * via `/organization/new`. * - model_aliases: Optional[dict] - Model aliases for the team. * [Docs](https://docs.hanzo.ai/docs/proxy/team_based_routing#create-team-with-model-alias) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt index bb364c0e..f5698abd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/ProviderServiceAsync.kt @@ -40,32 +40,32 @@ interface ProviderServiceAsync { * * ```json * { - * "providers": { - * "openai": { - * "budget_limit": 1e-12, - * "time_period": "1d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "azure": { - * "budget_limit": 100.0, - * "time_period": "1d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "anthropic": { - * "budget_limit": 100.0, - * "time_period": "10d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "vertex_ai": { - * "budget_limit": 100.0, - * "time_period": "12d", - * "spend": 0.0, - * "budget_reset_at": null + * "providers": { + * "openai": { + * "budget_limit": 1e-12, + * "time_period": "1d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "azure": { + * "budget_limit": 100.0, + * "time_period": "1d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "anthropic": { + * "budget_limit": 100.0, + * "time_period": "10d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "vertex_ai": { + * "budget_limit": 100.0, + * "time_period": "12d", + * "spend": 0.0, + * "budget_reset_at": null + * } * } - * } * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt index 0285e2c2..749c306e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/TeamServiceAsync.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.team.BlockTeamRequest import ai.hanzo.api.models.team.TeamAddMemberParams import ai.hanzo.api.models.team.TeamAddMemberResponse import ai.hanzo.api.models.team.TeamBlockParams @@ -90,7 +91,7 @@ interface TeamServiceAsync { * - team_id: (str) Unique team id - used for tracking spend across multiple keys for same team * id. * - * \_deprecated_params: + * _deprecated_params: * - admins: list - A list of user_id's for the admin role * - users: list - A list of user_id's for the user role * @@ -103,12 +104,12 @@ interface TeamServiceAsync { * }' * * ``` - * ``` + * ``` * curl --location 'http://0.0.0.0:4000/team/new' --header 'Authorization: Bearer sk-1234' --header 'Content-Type: application/json' --data '{ - * "team_alias": "QA Prod Bot", - * "max_budget": 0.000000001, - * "budget_duration": "1d" - * }' + * "team_alias": "QA Prod Bot", + * "max_budget": 0.000000001, + * "budget_duration": "1d" + * }' * ``` */ fun create(): CompletableFuture = create(TeamCreateParams.none()) @@ -282,6 +283,17 @@ interface TeamServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see block */ + fun block( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + block(TeamBlockParams.builder().blockTeamRequest(blockTeamRequest).build(), requestOptions) + + /** @see block */ + fun block(blockTeamRequest: BlockTeamRequest): CompletableFuture = + block(blockTeamRequest, RequestOptions.none()) + /** * Disable all logging callbacks for a team * @@ -426,6 +438,20 @@ interface TeamServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see unblock */ + fun unblock( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unblock( + TeamUnblockParams.builder().blockTeamRequest(blockTeamRequest).build(), + requestOptions, + ) + + /** @see unblock */ + fun unblock(blockTeamRequest: BlockTeamRequest): CompletableFuture = + unblock(blockTeamRequest, RequestOptions.none()) + /** * [BETA] * @@ -562,6 +588,22 @@ interface TeamServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see block */ + fun block( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + block( + TeamBlockParams.builder().blockTeamRequest(blockTeamRequest).build(), + requestOptions, + ) + + /** @see block */ + fun block( + blockTeamRequest: BlockTeamRequest + ): CompletableFuture> = + block(blockTeamRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /team/{team_id}/disable_logging`, but is otherwise * the same as [TeamServiceAsync.disableLogging]. @@ -685,6 +727,22 @@ interface TeamServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see unblock */ + fun unblock( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + unblock( + TeamUnblockParams.builder().blockTeamRequest(blockTeamRequest).build(), + requestOptions, + ) + + /** @see unblock */ + fun unblock( + blockTeamRequest: BlockTeamRequest + ): CompletableFuture> = + unblock(blockTeamRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /team/member_update`, but is otherwise the same as * [TeamServiceAsync.updateMember]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt index 6b594ca7..4016626c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/UserServiceAsync.kt @@ -133,45 +133,55 @@ interface UserServiceAsync { * }' * ``` * - * Parameters: - user_id: Optional[str] - Specify a user id. If not set, a unique id will be - * generated. - user_email: Optional[str] - Specify a user email. - password: Optional[str] - - * Specify a user password. - user_alias: Optional[str] - A descriptive name for you to know who - * this user id refers to. - teams: Optional[list] - specify a list of team id's a user belongs - * to. - send_invite_email: Optional[bool] - Specify if an invite email should be sent. - - * user_role: Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", - * "internal_user", "internal_user_viewer", "team", "customer". Info about each role here: - * `https://github.com/hanzoai/llm/llm/proxy/_types.py#L20` - max_budget: Optional[float] - - * Specify max budget for a given user. - budget_duration: Optional[str] - Budget is reset at - * the end of specified duration. If not set, budget is never reset. You can set duration as - * seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo"). - models: - * Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed to call - * all models) - tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per - * minute) - rpm_limit: Optional[int] - Specify rpm limit for a given user (Requests per - * minute) - auto_create_key: bool - Default=True. Flag used for returning a key as part of the - * /user/new response - aliases: Optional[dict] - Model aliases for the - * user - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) - config: - * Optional[dict] - [DEPRECATED PARAM] User-specific config. - allowed_cache_controls: - * Optional[list] - List of allowed cache control values. Example - ["no-cache", "no-store"]. - * See all values - https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request- - - * blocked: Optional[bool] - [Not Implemented Yet] Whether the user is blocked. - guardrails: - * Optional[List[str]] - [Not Implemented Yet] List of active guardrails for the user - - * permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning - * off pii masking. - metadata: Optional[dict] - Metadata for user, store information for user. - * Example metadata = {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } - - * max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel - * requests. Raises 429 error, if user's parallel requests > x. - soft_budget: Optional[float] - - * Get alerts when user crosses given budget, doesn't block requests. - model_max_budget: - * Optional[dict] - Model-specific max budget for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-budgets-to-keys) - - * model_rpm_limit: Optional[float] - Model-specific rpm limit for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) - - * model_tpm_limit: Optional[float] - Model-specific tpm limit for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) - spend: - * Optional[float] - Amount spent by user. Default is 0. Will be updated by proxy whenever user - * is used. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days - * ("30d"), months ("1mo"). - team_id: Optional[str] - [DEPRECATED PARAM] The team id of the - * user. Default is None. - duration: Optional[str] - [NOT IMPLEMENTED]. - key_alias: - * Optional[str] - [NOT IMPLEMENTED]. + * Parameters: + * - user_id: Optional[str] - Specify a user id. If not set, a unique id will be generated. + * - user_email: Optional[str] - Specify a user email. + * - password: Optional[str] - Specify a user password. + * - user_alias: Optional[str] - A descriptive name for you to know who this user id refers to. + * - teams: Optional[list] - specify a list of team id's a user belongs to. + * - send_invite_email: Optional[bool] - Specify if an invite email should be sent. + * - user_role: Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", + * "internal_user", "internal_user_viewer", "team", "customer". Info about each role here: + * `https://github.com/hanzoai/llm/llm/proxy/_types.py#L20` + * - max_budget: Optional[float] - Specify max budget for a given user. + * - budget_duration: Optional[str] - Budget is reset at the end of specified duration. If not + * set, budget is never reset. You can set duration as seconds ("30s"), minutes ("30m"), hours + * ("30h"), days ("30d"), months ("1mo"). + * - models: Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed + * to call all models) + * - tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per minute) + * - rpm_limit: Optional[int] - Specify rpm limit for a given user (Requests per minute) + * - auto_create_key: bool - Default=True. Flag used for returning a key as part of the + * /user/new response + * - aliases: Optional[dict] - Model aliases for the + * user - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) + * - config: Optional[dict] - [DEPRECATED PARAM] User-specific config. + * - allowed_cache_controls: Optional[list] - List of allowed cache control values. + * Example - ["no-cache", "no-store"]. See all values - + * https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request- + * - blocked: Optional[bool] - [Not Implemented Yet] Whether the user is blocked. + * - guardrails: Optional[List[str]] - [Not Implemented Yet] List of active guardrails for the + * user + * - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning + * off pii masking. + * - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata + * = {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } + * - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel + * requests. Raises 429 error, if user's parallel requests > x. + * - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block + * requests. + * - model_max_budget: Optional[dict] - Model-specific max budget for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-budgets-to-keys) + * - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) + * - model_tpm_limit: Optional[float] - Model-specific tpm limit for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) + * - spend: Optional[float] - Amount spent by user. Default is 0. Will be updated by proxy + * whenever user is used. You can set duration as seconds ("30s"), minutes ("30m"), hours + * ("30h"), days ("30d"), months ("1mo"). + * - team_id: Optional[str] - [DEPRECATED PARAM] The team id of the user. Default is None. + * - duration: Optional[str] - [NOT IMPLEMENTED]. + * - key_alias: Optional[str] - [NOT IMPLEMENTED]. */ fun update(): CompletableFuture = update(UserUpdateParams.none()) @@ -195,10 +205,13 @@ interface UserServiceAsync { * * Used by the UI to populate the user lists. * - * Parameters: role: Optional[str] Filter users by role. Can be one of: - proxy_admin - - * proxy_admin_viewer - internal_user - internal_user_viewer user_ids: Optional[str] Get list of - * users by user_ids. Comma separated list of user_ids. page: int The page number to return - * page_size: int The number of items per page + * Parameters: role: Optional[str] Filter users by role. Can be one of: + * - proxy_admin + * - proxy_admin_viewer + * - internal_user + * - internal_user_viewer user_ids: Optional[str] Get list of users by user_ids. Comma separated + * list of user_ids. page: int The page number to return page_size: int The number of items + * per page * * Currently - admin-only endpoint. * diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt index 013b2449..4330bfce 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsync.kt @@ -12,6 +12,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListPar import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointResponse import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse +import ai.hanzo.api.models.config.passthroughendpoint.PassThroughGenericEndpoint import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -40,6 +41,24 @@ interface PassThroughEndpointServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see create */ + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PassThroughEndpointCreateParams.builder() + .passThroughGenericEndpoint(passThroughGenericEndpoint) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint + ): CompletableFuture = + create(passThroughGenericEndpoint, RequestOptions.none()) + /** Update a pass-through endpoint */ fun update(endpointId: String): CompletableFuture = update(endpointId, PassThroughEndpointUpdateParams.none()) @@ -145,6 +164,24 @@ interface PassThroughEndpointServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see create */ + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PassThroughEndpointCreateParams.builder() + .passThroughGenericEndpoint(passThroughGenericEndpoint) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint + ): CompletableFuture> = + create(passThroughGenericEndpoint, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /config/pass_through_endpoint/{endpoint_id}`, but * is otherwise the same as [PassThroughEndpointServiceAsync.update]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt index dbbd231a..b1da62b2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/InfoServiceAsync.kt @@ -39,20 +39,21 @@ interface InfoServiceAsync { * Example Response: * ```json * { - * "data": [ - * { - * "model_name": "fake-openai-endpoint", - * "llm_params": { - * "api_base": "https://exampleopenaiendpoint-production.up.railway.app/", - * "model": "openai/fake" - * }, - * "model_info": { - * "id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af", - * "db_model": false - * } - * } - * ] + * "data": [ + * { + * "model_name": "fake-openai-endpoint", + * "llm_params": { + * "api_base": "https://exampleopenaiendpoint-production.up.railway.app/", + * "model": "openai/fake" + * }, + * "model_info": { + * "id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af", + * "db_model": false + * } + * } + * ] * } + * * ``` */ fun list(): CompletableFuture = list(InfoListParams.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt index d30970dd..8d943c15 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsync.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.async.model import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.model.update.UpdateDeployment import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams @@ -36,6 +37,17 @@ interface UpdateServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see full */ + fun full( + updateDeployment: UpdateDeployment, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + full(UpdateFullParams.builder().updateDeployment(updateDeployment).build(), requestOptions) + + /** @see full */ + fun full(updateDeployment: UpdateDeployment): CompletableFuture = + full(updateDeployment, RequestOptions.none()) + /** * PATCH Endpoint for partial model updates. * @@ -100,6 +112,22 @@ interface UpdateServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see full */ + fun full( + updateDeployment: UpdateDeployment, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + full( + UpdateFullParams.builder().updateDeployment(updateDeployment).build(), + requestOptions, + ) + + /** @see full */ + fun full( + updateDeployment: UpdateDeployment + ): CompletableFuture> = + full(updateDeployment, RequestOptions.none()) + /** * Returns a raw HTTP response for `patch /model/{model_id}/update`, but is otherwise the * same as [UpdateServiceAsync.partial]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt index 7368d9b7..79c85f0b 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/AddService.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.AddAddAllowedIpResponse +import ai.hanzo.api.models.add.IpAddress import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -34,6 +35,17 @@ interface AddService { requestOptions: RequestOptions = RequestOptions.none(), ): AddAddAllowedIpResponse + /** @see addAllowedIp */ + fun addAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): AddAddAllowedIpResponse = + addAllowedIp(AddAddAllowedIpParams.builder().ipAddress(ipAddress).build(), requestOptions) + + /** @see addAllowedIp */ + fun addAllowedIp(ipAddress: IpAddress): AddAddAllowedIpResponse = + addAllowedIp(ipAddress, RequestOptions.none()) + /** A view of [AddService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -58,5 +70,21 @@ interface AddService { params: AddAddAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see addAllowedIp */ + @MustBeClosed + fun addAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + addAllowedIp( + AddAddAllowedIpParams.builder().ipAddress(ipAddress).build(), + requestOptions, + ) + + /** @see addAllowedIp */ + @MustBeClosed + fun addAllowedIp(ipAddress: IpAddress): HttpResponseFor = + addAllowedIp(ipAddress, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt index cc682589..76766eb9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/BudgetService.kt @@ -13,6 +13,7 @@ import ai.hanzo.api.models.budget.BudgetInfoParams import ai.hanzo.api.models.budget.BudgetInfoResponse import ai.hanzo.api.models.budget.BudgetListParams import ai.hanzo.api.models.budget.BudgetListResponse +import ai.hanzo.api.models.budget.BudgetNew import ai.hanzo.api.models.budget.BudgetSettingsParams import ai.hanzo.api.models.budget.BudgetSettingsResponse import ai.hanzo.api.models.budget.BudgetUpdateParams @@ -59,6 +60,17 @@ interface BudgetService { requestOptions: RequestOptions = RequestOptions.none(), ): BudgetCreateResponse + /** @see create */ + fun create( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): BudgetCreateResponse = + create(BudgetCreateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see create */ + fun create(budgetNew: BudgetNew): BudgetCreateResponse = + create(budgetNew, RequestOptions.none()) + /** * Update an existing budget object. * @@ -84,6 +96,17 @@ interface BudgetService { requestOptions: RequestOptions = RequestOptions.none(), ): BudgetUpdateResponse + /** @see update */ + fun update( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): BudgetUpdateResponse = + update(BudgetUpdateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see update */ + fun update(budgetNew: BudgetNew): BudgetUpdateResponse = + update(budgetNew, RequestOptions.none()) + /** List all the created budgets in proxy db. Used on Admin UI. */ fun list(): BudgetListResponse = list(BudgetListParams.none()) @@ -172,6 +195,19 @@ interface BudgetService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(BudgetCreateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(budgetNew: BudgetNew): HttpResponseFor = + create(budgetNew, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /budget/update`, but is otherwise the same as * [BudgetService.update]. @@ -187,6 +223,19 @@ interface BudgetService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see update */ + @MustBeClosed + fun update( + budgetNew: BudgetNew, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(BudgetUpdateParams.builder().budgetNew(budgetNew).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(budgetNew: BudgetNew): HttpResponseFor = + update(budgetNew, RequestOptions.none()) + /** * Returns a raw HTTP response for `get /budget/list`, but is otherwise the same as * [BudgetService.list]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt index 03557ded..b7aa8bc2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CacheService.kt @@ -36,7 +36,7 @@ interface CacheService { * `x-llm-cache-key` in the headers * * Parameters: - * - **keys**: _Optional[List[str]]_ - A list of keys to delete from the cache. Example {"keys": + * - **keys**: *Optional[List[str]]* - A list of keys to delete from the cache. Example {"keys": * ["key1", "key2"]} * * ```shell diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt index 9bbe1eed..8698e7e6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/CustomerService.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.customer.BlockUsers import ai.hanzo.api.models.customer.CustomerBlockParams import ai.hanzo.api.models.customer.CustomerBlockResponse import ai.hanzo.api.models.customer.CustomerCreateParams @@ -194,6 +195,17 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerBlockResponse + /** @see block */ + fun block( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerBlockResponse = + block(CustomerBlockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see block */ + fun block(blockUsers: BlockUsers): CustomerBlockResponse = + block(blockUsers, RequestOptions.none()) + /** * Get information about an end-user. An `end_user` is a customer (external user) of the proxy. * @@ -236,6 +248,17 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerUnblockResponse + /** @see unblock */ + fun unblock( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerUnblockResponse = + unblock(CustomerUnblockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see unblock */ + fun unblock(blockUsers: BlockUsers): CustomerUnblockResponse = + unblock(blockUsers, RequestOptions.none()) + /** A view of [CustomerService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -331,6 +354,19 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see block */ + @MustBeClosed + fun block( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + block(CustomerBlockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see block */ + @MustBeClosed + fun block(blockUsers: BlockUsers): HttpResponseFor = + block(blockUsers, RequestOptions.none()) + /** * Returns a raw HTTP response for `get /customer/info`, but is otherwise the same as * [CustomerService.retrieveInfo]. @@ -362,5 +398,18 @@ interface CustomerService { params: CustomerUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see unblock */ + @MustBeClosed + fun unblock( + blockUsers: BlockUsers, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unblock(CustomerUnblockParams.builder().blockUsers(blockUsers).build(), requestOptions) + + /** @see unblock */ + @MustBeClosed + fun unblock(blockUsers: BlockUsers): HttpResponseFor = + unblock(blockUsers, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt index b9c5b89e..807e1bd1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/DeleteService.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.add.IpAddress import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import ai.hanzo.api.models.delete.DeleteCreateAllowedIpResponse import com.google.errorprone.annotations.MustBeClosed @@ -34,6 +35,20 @@ interface DeleteService { requestOptions: RequestOptions = RequestOptions.none(), ): DeleteCreateAllowedIpResponse + /** @see createAllowedIp */ + fun createAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): DeleteCreateAllowedIpResponse = + createAllowedIp( + DeleteCreateAllowedIpParams.builder().ipAddress(ipAddress).build(), + requestOptions, + ) + + /** @see createAllowedIp */ + fun createAllowedIp(ipAddress: IpAddress): DeleteCreateAllowedIpResponse = + createAllowedIp(ipAddress, RequestOptions.none()) + /** A view of [DeleteService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -60,5 +75,21 @@ interface DeleteService { params: DeleteCreateAllowedIpParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see createAllowedIp */ + @MustBeClosed + fun createAllowedIp( + ipAddress: IpAddress, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createAllowedIp( + DeleteCreateAllowedIpParams.builder().ipAddress(ipAddress).build(), + requestOptions, + ) + + /** @see createAllowedIp */ + @MustBeClosed + fun createAllowedIp(ipAddress: IpAddress): HttpResponseFor = + createAllowedIp(ipAddress, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt index 033c3624..3ce0bcd5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/GuardrailService.kt @@ -37,24 +37,24 @@ interface GuardrailService { * Example Response: * ```json * { - * "guardrails": [ - * { - * "guardrail_name": "bedrock-pre-guard", - * "guardrail_info": { - * "params": [ - * { - * "name": "toxicity_score", - * "type": "float", - * "description": "Score between 0-1 indicating content toxicity level" - * }, - * { - * "name": "pii_detection", - * "type": "boolean" - * } - * ] - * } - * } - * ] + * "guardrails": [ + * { + * "guardrail_name": "bedrock-pre-guard", + * "guardrail_info": { + * "params": [ + * { + * "name": "toxicity_score", + * "type": "float", + * "description": "Score between 0-1 indicating content toxicity level" + * }, + * { + * "name": "pii_detection", + * "type": "boolean" + * } + * ] + * } + * } + * ] * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt index 3e2252f0..5cd48196 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/KeyService.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.key.BlockKeyRequest import ai.hanzo.api.models.key.GenerateKeyResponse import ai.hanzo.api.models.key.KeyBlockParams import ai.hanzo.api.models.key.KeyBlockResponse @@ -192,6 +193,17 @@ interface KeyService { requestOptions: RequestOptions = RequestOptions.none(), ): Optional + /** @see block */ + fun block( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional = + block(KeyBlockParams.builder().blockKeyRequest(blockKeyRequest).build(), requestOptions) + + /** @see block */ + fun block(blockKeyRequest: BlockKeyRequest): Optional = + block(blockKeyRequest, RequestOptions.none()) + /** * Check the health of the key * @@ -211,7 +223,9 @@ interface KeyService { * { * "key": "healthy", * "logging_callbacks": { - * "callbacks": ["gcs_bucket"], + * "callbacks": [ + * "gcs_bucket" + * ], * "status": "healthy", * "details": "No logger exceptions triggered, system is healthy. Manually check if logs were sent to ['gcs_bucket']" * } @@ -223,7 +237,9 @@ interface KeyService { * { * "key": "unhealthy", * "logging_callbacks": { - * "callbacks": ["gcs_bucket"], + * "callbacks": [ + * "gcs_bucket" + * ], * "status": "unhealthy", * "details": "Logger exceptions triggered, system is unhealthy: Failed to load vertex credentials. Check to see if credentials containing partial/invalid information." * } @@ -479,6 +495,17 @@ interface KeyService { requestOptions: RequestOptions = RequestOptions.none(), ): KeyUnblockResponse + /** @see unblock */ + fun unblock( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): KeyUnblockResponse = + unblock(KeyUnblockParams.builder().blockKeyRequest(blockKeyRequest).build(), requestOptions) + + /** @see unblock */ + fun unblock(blockKeyRequest: BlockKeyRequest): KeyUnblockResponse = + unblock(blockKeyRequest, RequestOptions.none()) + /** A view of [KeyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -569,6 +596,19 @@ interface KeyService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor> + /** @see block */ + @MustBeClosed + fun block( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> = + block(KeyBlockParams.builder().blockKeyRequest(blockKeyRequest).build(), requestOptions) + + /** @see block */ + @MustBeClosed + fun block(blockKeyRequest: BlockKeyRequest): HttpResponseFor> = + block(blockKeyRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /key/health`, but is otherwise the same as * [KeyService.checkHealth]. @@ -707,5 +747,21 @@ interface KeyService { params: KeyUnblockParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see unblock */ + @MustBeClosed + fun unblock( + blockKeyRequest: BlockKeyRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unblock( + KeyUnblockParams.builder().blockKeyRequest(blockKeyRequest).build(), + requestOptions, + ) + + /** @see unblock */ + @MustBeClosed + fun unblock(blockKeyRequest: BlockKeyRequest): HttpResponseFor = + unblock(blockKeyRequest, RequestOptions.none()) } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt index 5da6b861..9b69f819 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ModelGroupService.kt @@ -54,112 +54,118 @@ interface ModelGroupService { * * Example Response: * ```json - * { - * "data": [ * { - * "model_group": "rerank-english-v3.0", - * "providers": ["cohere"], - * "max_input_tokens": null, - * "max_output_tokens": null, - * "input_cost_per_token": 0.0, - * "output_cost_per_token": 0.0, - * "mode": null, - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": false, - * "supports_function_calling": false, - * "supported_openai_params": [ - * "stream", - * "temperature", - * "max_tokens", - * "logit_bias", - * "top_p", - * "frequency_penalty", - * "presence_penalty", - * "stop", - * "n", - * "extra_headers" - * ] - * }, - * { - * "model_group": "gpt-3.5-turbo", - * "providers": ["openai"], - * "max_input_tokens": 16385.0, - * "max_output_tokens": 4096.0, - * "input_cost_per_token": 1.5e-6, - * "output_cost_per_token": 2e-6, - * "mode": "chat", - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": false, - * "supports_function_calling": true, - * "supported_openai_params": [ - * "frequency_penalty", - * "logit_bias", - * "logprobs", - * "top_logprobs", - * "max_tokens", - * "max_completion_tokens", - * "n", - * "presence_penalty", - * "seed", - * "stop", - * "stream", - * "stream_options", - * "temperature", - * "top_p", - * "tools", - * "tool_choice", - * "function_call", - * "functions", - * "max_retries", - * "extra_headers", - * "parallel_tool_calls", - * "response_format" - * ] - * }, - * { - * "model_group": "llava-hf", - * "providers": ["openai"], - * "max_input_tokens": null, - * "max_output_tokens": null, - * "input_cost_per_token": 0.0, - * "output_cost_per_token": 0.0, - * "mode": null, - * "tpm": null, - * "rpm": null, - * "supports_parallel_function_calling": false, - * "supports_vision": true, - * "supports_function_calling": false, - * "supported_openai_params": [ - * "frequency_penalty", - * "logit_bias", - * "logprobs", - * "top_logprobs", - * "max_tokens", - * "max_completion_tokens", - * "n", - * "presence_penalty", - * "seed", - * "stop", - * "stream", - * "stream_options", - * "temperature", - * "top_p", - * "tools", - * "tool_choice", - * "function_call", - * "functions", - * "max_retries", - * "extra_headers", - * "parallel_tool_calls", - * "response_format" - * ] - * } - * ] - * } + * "data": [ + * { + * "model_group": "rerank-english-v3.0", + * "providers": [ + * "cohere" + * ], + * "max_input_tokens": null, + * "max_output_tokens": null, + * "input_cost_per_token": 0.0, + * "output_cost_per_token": 0.0, + * "mode": null, + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": false, + * "supports_function_calling": false, + * "supported_openai_params": [ + * "stream", + * "temperature", + * "max_tokens", + * "logit_bias", + * "top_p", + * "frequency_penalty", + * "presence_penalty", + * "stop", + * "n", + * "extra_headers" + * ] + * }, + * { + * "model_group": "gpt-3.5-turbo", + * "providers": [ + * "openai" + * ], + * "max_input_tokens": 16385.0, + * "max_output_tokens": 4096.0, + * "input_cost_per_token": 1.5e-06, + * "output_cost_per_token": 2e-06, + * "mode": "chat", + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": false, + * "supports_function_calling": true, + * "supported_openai_params": [ + * "frequency_penalty", + * "logit_bias", + * "logprobs", + * "top_logprobs", + * "max_tokens", + * "max_completion_tokens", + * "n", + * "presence_penalty", + * "seed", + * "stop", + * "stream", + * "stream_options", + * "temperature", + * "top_p", + * "tools", + * "tool_choice", + * "function_call", + * "functions", + * "max_retries", + * "extra_headers", + * "parallel_tool_calls", + * "response_format" + * ] + * }, + * { + * "model_group": "llava-hf", + * "providers": [ + * "openai" + * ], + * "max_input_tokens": null, + * "max_output_tokens": null, + * "input_cost_per_token": 0.0, + * "output_cost_per_token": 0.0, + * "mode": null, + * "tpm": null, + * "rpm": null, + * "supports_parallel_function_calling": false, + * "supports_vision": true, + * "supports_function_calling": false, + * "supported_openai_params": [ + * "frequency_penalty", + * "logit_bias", + * "logprobs", + * "top_logprobs", + * "max_tokens", + * "max_completion_tokens", + * "n", + * "presence_penalty", + * "seed", + * "stop", + * "stream", + * "stream_options", + * "temperature", + * "top_p", + * "tools", + * "tool_choice", + * "function_call", + * "functions", + * "max_retries", + * "extra_headers", + * "parallel_tool_calls", + * "response_format" + * ] + * } + * ] + * } * ``` */ fun retrieveInfo(): ModelGroupRetrieveInfoResponse = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt index fcbd39af..c17c731f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/OrganizationService.kt @@ -47,28 +47,28 @@ interface OrganizationService { * Only admins can create orgs. * * # Parameters - * - organization_alias: _str_ - The name of the organization. - * - models: _List_ - The models the organization has access to. - * - budget_id: _Optional[str]_ - The id for a budget (tpm/rpm/max budget) for the organization. + * - organization_alias: *str* - The name of the organization. + * - models: *List* - The models the organization has access to. + * - budget_id: *Optional[str]* - The id for a budget (tpm/rpm/max budget) for the organization. * - * ### IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS - * - max_budget: _Optional[float]_ - Max budget for org - * - tpm_limit: _Optional[int]_ - Max tpm limit for org - * - rpm_limit: _Optional[int]_ - Max rpm limit for org - * - max_parallel_requests: _Optional[int]_ - [Not Implemented Yet] Max parallel requests for + * ### IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS ### + * - max_budget: *Optional[float]* - Max budget for org + * - tpm_limit: *Optional[int]* - Max tpm limit for org + * - rpm_limit: *Optional[int]* - Max rpm limit for org + * - max_parallel_requests: *Optional[int]* - [Not Implemented Yet] Max parallel requests for * org - * - soft_budget: _Optional[float]_ - [Not Implemented Yet] Get a slack alert when this soft + * - soft_budget: *Optional[float]* - [Not Implemented Yet] Get a slack alert when this soft * budget is reached. Don't block requests. - * - model_max_budget: _Optional[dict]_ - Max budget for a specific model - * - budget_duration: _Optional[str]_ - Frequency of reseting org budget - * - metadata: _Optional[dict]_ - Metadata for organization, store information for organization. + * - model_max_budget: *Optional[dict]* - Max budget for a specific model + * - budget_duration: *Optional[str]* - Frequency of reseting org budget + * - metadata: *Optional[dict]* - Metadata for organization, store information for organization. * Example metadata - {"extra_info": "some info"} - * - blocked: _bool_ - Flag indicating if the org is blocked or not - will stop all calls from + * - blocked: *bool* - Flag indicating if the org is blocked or not - will stop all calls from * keys with this org_id. - * - tags: _Optional[List[str]]_ - Tags for + * - tags: *Optional[List[str]]* - Tags for * [tracking spend](https://llm.vercel.app/docs/proxy/enterprise#tracking-spend-for-custom-tags) * and/or doing [tag-based routing](https://llm.vercel.app/docs/proxy/tag_routing). - * - organization_id: _Optional[str]_ - The organization id of the team. Default is None. Create + * - organization_id: *Optional[str]* - The organization id of the team. Default is None. Create * via `/organization/new`. * - model_aliases: Optional[dict] - Model aliases for the team. * [Docs](https://docs.hanzo.ai/docs/proxy/team_based_routing#create-team-with-model-alias) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt index d60bb514..6011d8fc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/ProviderService.kt @@ -40,32 +40,32 @@ interface ProviderService { * * ```json * { - * "providers": { - * "openai": { - * "budget_limit": 1e-12, - * "time_period": "1d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "azure": { - * "budget_limit": 100.0, - * "time_period": "1d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "anthropic": { - * "budget_limit": 100.0, - * "time_period": "10d", - * "spend": 0.0, - * "budget_reset_at": null - * }, - * "vertex_ai": { - * "budget_limit": 100.0, - * "time_period": "12d", - * "spend": 0.0, - * "budget_reset_at": null + * "providers": { + * "openai": { + * "budget_limit": 1e-12, + * "time_period": "1d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "azure": { + * "budget_limit": 100.0, + * "time_period": "1d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "anthropic": { + * "budget_limit": 100.0, + * "time_period": "10d", + * "spend": 0.0, + * "budget_reset_at": null + * }, + * "vertex_ai": { + * "budget_limit": 100.0, + * "time_period": "12d", + * "spend": 0.0, + * "budget_reset_at": null + * } * } - * } * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt index a5d37b88..cb313917 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/TeamService.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.team.BlockTeamRequest import ai.hanzo.api.models.team.TeamAddMemberParams import ai.hanzo.api.models.team.TeamAddMemberResponse import ai.hanzo.api.models.team.TeamBlockParams @@ -90,7 +91,7 @@ interface TeamService { * - team_id: (str) Unique team id - used for tracking spend across multiple keys for same team * id. * - * \_deprecated_params: + * _deprecated_params: * - admins: list - A list of user_id's for the admin role * - users: list - A list of user_id's for the user role * @@ -103,12 +104,12 @@ interface TeamService { * }' * * ``` - * ``` + * ``` * curl --location 'http://0.0.0.0:4000/team/new' --header 'Authorization: Bearer sk-1234' --header 'Content-Type: application/json' --data '{ - * "team_alias": "QA Prod Bot", - * "max_budget": 0.000000001, - * "budget_duration": "1d" - * }' + * "team_alias": "QA Prod Bot", + * "max_budget": 0.000000001, + * "budget_duration": "1d" + * }' * ``` */ fun create(): TeamCreateResponse = create(TeamCreateParams.none()) @@ -278,6 +279,17 @@ interface TeamService { requestOptions: RequestOptions = RequestOptions.none(), ): TeamBlockResponse + /** @see block */ + fun block( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): TeamBlockResponse = + block(TeamBlockParams.builder().blockTeamRequest(blockTeamRequest).build(), requestOptions) + + /** @see block */ + fun block(blockTeamRequest: BlockTeamRequest): TeamBlockResponse = + block(blockTeamRequest, RequestOptions.none()) + /** * Disable all logging callbacks for a team * @@ -413,6 +425,20 @@ interface TeamService { requestOptions: RequestOptions = RequestOptions.none(), ): TeamUnblockResponse + /** @see unblock */ + fun unblock( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): TeamUnblockResponse = + unblock( + TeamUnblockParams.builder().blockTeamRequest(blockTeamRequest).build(), + requestOptions, + ) + + /** @see unblock */ + fun unblock(blockTeamRequest: BlockTeamRequest): TeamUnblockResponse = + unblock(blockTeamRequest, RequestOptions.none()) + /** * [BETA] * @@ -550,6 +576,22 @@ interface TeamService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see block */ + @MustBeClosed + fun block( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + block( + TeamBlockParams.builder().blockTeamRequest(blockTeamRequest).build(), + requestOptions, + ) + + /** @see block */ + @MustBeClosed + fun block(blockTeamRequest: BlockTeamRequest): HttpResponseFor = + block(blockTeamRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /team/{team_id}/disable_logging`, but is otherwise * the same as [TeamService.disableLogging]. @@ -684,6 +726,22 @@ interface TeamService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see unblock */ + @MustBeClosed + fun unblock( + blockTeamRequest: BlockTeamRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unblock( + TeamUnblockParams.builder().blockTeamRequest(blockTeamRequest).build(), + requestOptions, + ) + + /** @see unblock */ + @MustBeClosed + fun unblock(blockTeamRequest: BlockTeamRequest): HttpResponseFor = + unblock(blockTeamRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /team/member_update`, but is otherwise the same as * [TeamService.updateMember]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt index 0a6077a9..94f73207 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/UserService.kt @@ -132,45 +132,55 @@ interface UserService { * }' * ``` * - * Parameters: - user_id: Optional[str] - Specify a user id. If not set, a unique id will be - * generated. - user_email: Optional[str] - Specify a user email. - password: Optional[str] - - * Specify a user password. - user_alias: Optional[str] - A descriptive name for you to know who - * this user id refers to. - teams: Optional[list] - specify a list of team id's a user belongs - * to. - send_invite_email: Optional[bool] - Specify if an invite email should be sent. - - * user_role: Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", - * "internal_user", "internal_user_viewer", "team", "customer". Info about each role here: - * `https://github.com/hanzoai/llm/llm/proxy/_types.py#L20` - max_budget: Optional[float] - - * Specify max budget for a given user. - budget_duration: Optional[str] - Budget is reset at - * the end of specified duration. If not set, budget is never reset. You can set duration as - * seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo"). - models: - * Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed to call - * all models) - tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per - * minute) - rpm_limit: Optional[int] - Specify rpm limit for a given user (Requests per - * minute) - auto_create_key: bool - Default=True. Flag used for returning a key as part of the - * /user/new response - aliases: Optional[dict] - Model aliases for the - * user - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) - config: - * Optional[dict] - [DEPRECATED PARAM] User-specific config. - allowed_cache_controls: - * Optional[list] - List of allowed cache control values. Example - ["no-cache", "no-store"]. - * See all values - https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request- - - * blocked: Optional[bool] - [Not Implemented Yet] Whether the user is blocked. - guardrails: - * Optional[List[str]] - [Not Implemented Yet] List of active guardrails for the user - - * permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning - * off pii masking. - metadata: Optional[dict] - Metadata for user, store information for user. - * Example metadata = {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } - - * max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel - * requests. Raises 429 error, if user's parallel requests > x. - soft_budget: Optional[float] - - * Get alerts when user crosses given budget, doesn't block requests. - model_max_budget: - * Optional[dict] - Model-specific max budget for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-budgets-to-keys) - - * model_rpm_limit: Optional[float] - Model-specific rpm limit for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) - - * model_tpm_limit: Optional[float] - Model-specific tpm limit for user. - * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) - spend: - * Optional[float] - Amount spent by user. Default is 0. Will be updated by proxy whenever user - * is used. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days - * ("30d"), months ("1mo"). - team_id: Optional[str] - [DEPRECATED PARAM] The team id of the - * user. Default is None. - duration: Optional[str] - [NOT IMPLEMENTED]. - key_alias: - * Optional[str] - [NOT IMPLEMENTED]. + * Parameters: + * - user_id: Optional[str] - Specify a user id. If not set, a unique id will be generated. + * - user_email: Optional[str] - Specify a user email. + * - password: Optional[str] - Specify a user password. + * - user_alias: Optional[str] - A descriptive name for you to know who this user id refers to. + * - teams: Optional[list] - specify a list of team id's a user belongs to. + * - send_invite_email: Optional[bool] - Specify if an invite email should be sent. + * - user_role: Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", + * "internal_user", "internal_user_viewer", "team", "customer". Info about each role here: + * `https://github.com/hanzoai/llm/llm/proxy/_types.py#L20` + * - max_budget: Optional[float] - Specify max budget for a given user. + * - budget_duration: Optional[str] - Budget is reset at the end of specified duration. If not + * set, budget is never reset. You can set duration as seconds ("30s"), minutes ("30m"), hours + * ("30h"), days ("30d"), months ("1mo"). + * - models: Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed + * to call all models) + * - tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per minute) + * - rpm_limit: Optional[int] - Specify rpm limit for a given user (Requests per minute) + * - auto_create_key: bool - Default=True. Flag used for returning a key as part of the + * /user/new response + * - aliases: Optional[dict] - Model aliases for the + * user - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) + * - config: Optional[dict] - [DEPRECATED PARAM] User-specific config. + * - allowed_cache_controls: Optional[list] - List of allowed cache control values. + * Example - ["no-cache", "no-store"]. See all values - + * https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request- + * - blocked: Optional[bool] - [Not Implemented Yet] Whether the user is blocked. + * - guardrails: Optional[List[str]] - [Not Implemented Yet] List of active guardrails for the + * user + * - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning + * off pii masking. + * - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata + * = {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } + * - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel + * requests. Raises 429 error, if user's parallel requests > x. + * - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block + * requests. + * - model_max_budget: Optional[dict] - Model-specific max budget for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-budgets-to-keys) + * - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) + * - model_tpm_limit: Optional[float] - Model-specific tpm limit for user. + * [Docs](https://docs.hanzo.ai/docs/proxy/users#add-model-specific-limits-to-keys) + * - spend: Optional[float] - Amount spent by user. Default is 0. Will be updated by proxy + * whenever user is used. You can set duration as seconds ("30s"), minutes ("30m"), hours + * ("30h"), days ("30d"), months ("1mo"). + * - team_id: Optional[str] - [DEPRECATED PARAM] The team id of the user. Default is None. + * - duration: Optional[str] - [NOT IMPLEMENTED]. + * - key_alias: Optional[str] - [NOT IMPLEMENTED]. */ fun update(): UserUpdateResponse = update(UserUpdateParams.none()) @@ -193,10 +203,13 @@ interface UserService { * * Used by the UI to populate the user lists. * - * Parameters: role: Optional[str] Filter users by role. Can be one of: - proxy_admin - - * proxy_admin_viewer - internal_user - internal_user_viewer user_ids: Optional[str] Get list of - * users by user_ids. Comma separated list of user_ids. page: int The page number to return - * page_size: int The number of items per page + * Parameters: role: Optional[str] Filter users by role. Can be one of: + * - proxy_admin + * - proxy_admin_viewer + * - internal_user + * - internal_user_viewer user_ids: Optional[str] Get list of users by user_ids. Comma separated + * list of user_ids. page: int The page number to return page_size: int The number of items + * per page * * Currently - admin-only endpoint. * diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt index 15c42ddf..d49ce858 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointService.kt @@ -12,6 +12,7 @@ import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListPar import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointResponse import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointUpdateResponse +import ai.hanzo.api.models.config.passthroughendpoint.PassThroughGenericEndpoint import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -39,6 +40,23 @@ interface PassThroughEndpointService { requestOptions: RequestOptions = RequestOptions.none(), ): PassThroughEndpointCreateResponse + /** @see create */ + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint, + requestOptions: RequestOptions = RequestOptions.none(), + ): PassThroughEndpointCreateResponse = + create( + PassThroughEndpointCreateParams.builder() + .passThroughGenericEndpoint(passThroughGenericEndpoint) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint + ): PassThroughEndpointCreateResponse = create(passThroughGenericEndpoint, RequestOptions.none()) + /** Update a pass-through endpoint */ fun update(endpointId: String): PassThroughEndpointUpdateResponse = update(endpointId, PassThroughEndpointUpdateParams.none()) @@ -142,6 +160,26 @@ interface PassThroughEndpointService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PassThroughEndpointCreateParams.builder() + .passThroughGenericEndpoint(passThroughGenericEndpoint) + .build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + passThroughGenericEndpoint: PassThroughGenericEndpoint + ): HttpResponseFor = + create(passThroughGenericEndpoint, RequestOptions.none()) + /** * Returns a raw HTTP response for `post /config/pass_through_endpoint/{endpoint_id}`, but * is otherwise the same as [PassThroughEndpointService.update]. diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt index 3fe1e904..2d9c3233 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/InfoService.kt @@ -39,20 +39,21 @@ interface InfoService { * Example Response: * ```json * { - * "data": [ - * { - * "model_name": "fake-openai-endpoint", - * "llm_params": { - * "api_base": "https://exampleopenaiendpoint-production.up.railway.app/", - * "model": "openai/fake" - * }, - * "model_info": { - * "id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af", - * "db_model": false - * } - * } - * ] + * "data": [ + * { + * "model_name": "fake-openai-endpoint", + * "llm_params": { + * "api_base": "https://exampleopenaiendpoint-production.up.railway.app/", + * "model": "openai/fake" + * }, + * "model_info": { + * "id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af", + * "db_model": false + * } + * } + * ] * } + * * ``` */ fun list(): InfoListResponse = list(InfoListParams.none()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt index 89e4b772..b9c0a166 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/services/blocking/model/UpdateService.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.services.blocking.model import ai.hanzo.api.core.ClientOptions import ai.hanzo.api.core.RequestOptions import ai.hanzo.api.core.http.HttpResponseFor +import ai.hanzo.api.models.model.update.UpdateDeployment import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdateFullResponse import ai.hanzo.api.models.model.update.UpdatePartialParams @@ -35,6 +36,17 @@ interface UpdateService { requestOptions: RequestOptions = RequestOptions.none(), ): UpdateFullResponse + /** @see full */ + fun full( + updateDeployment: UpdateDeployment, + requestOptions: RequestOptions = RequestOptions.none(), + ): UpdateFullResponse = + full(UpdateFullParams.builder().updateDeployment(updateDeployment).build(), requestOptions) + + /** @see full */ + fun full(updateDeployment: UpdateDeployment): UpdateFullResponse = + full(updateDeployment, RequestOptions.none()) + /** * PATCH Endpoint for partial model updates. * @@ -94,6 +106,22 @@ interface UpdateService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see full */ + @MustBeClosed + fun full( + updateDeployment: UpdateDeployment, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + full( + UpdateFullParams.builder().updateDeployment(updateDeployment).build(), + requestOptions, + ) + + /** @see full */ + @MustBeClosed + fun full(updateDeployment: UpdateDeployment): HttpResponseFor = + full(updateDeployment, RequestOptions.none()) + /** * Returns a raw HTTP response for `patch /model/{model_id}/update`, but is otherwise the * same as [UpdateService.partial]. diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt index 775aefa2..2a049667 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/RetryingHttpClientTest.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.core.http import ai.hanzo.api.client.okhttp.OkHttpClient import ai.hanzo.api.core.RequestOptions +import ai.hanzo.api.core.Sleeper import ai.hanzo.api.errors.HanzoRetryableException import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo @@ -294,12 +295,14 @@ internal class RetryingHttpClientTest { .httpClient(failingHttpClient) .maxRetries(2) .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) .build() @@ -333,12 +336,14 @@ internal class RetryingHttpClientTest { .httpClient(httpClient) // Use a no-op `Sleeper` to make the test fast. .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt index 524ed9b8..1d5f15e4 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/AddServiceAsyncTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync -import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.IpAddress import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -23,12 +22,7 @@ internal class AddServiceAsyncTest { .build() val addServiceAsync = client.add() - val responseFuture = - addServiceAsync.addAllowedIp( - AddAddAllowedIpParams.builder() - .ipAddress(IpAddress.builder().ip("ip").build()) - .build() - ) + val responseFuture = addServiceAsync.addAllowedIp(IpAddress.builder().ip("ip").build()) val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt index c79fe28b..bd3975c9 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/BudgetServiceAsyncTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.models.budget.BudgetCreateParams import ai.hanzo.api.models.budget.BudgetDeleteParams import ai.hanzo.api.models.budget.BudgetInfoParams import ai.hanzo.api.models.budget.BudgetNew import ai.hanzo.api.models.budget.BudgetSettingsParams -import ai.hanzo.api.models.budget.BudgetUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -30,33 +28,29 @@ internal class BudgetServiceAsyncTest { val budgetFuture = budgetServiceAsync.create( - BudgetCreateParams.builder() - .budgetNew( - BudgetNew.builder() - .budgetDuration("budget_duration") - .budgetId("budget_id") - .maxBudget(0.0) - .maxParallelRequests(0L) - .modelMaxBudget( - BudgetNew.ModelMaxBudget.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "budget_duration" to "budget_duration", - "max_budget" to 0, - "rpm_limit" to 0, - "tpm_limit" to 0, - ) - ), + BudgetNew.builder() + .budgetDuration("budget_duration") + .budgetId("budget_id") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget( + BudgetNew.ModelMaxBudget.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "budget_duration" to "budget_duration", + "max_budget" to 0, + "rpm_limit" to 0, + "tpm_limit" to 0, ) - .build() + ), ) - .rpmLimit(0L) - .softBudget(0.0) - .tpmLimit(0L) .build() ) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) .build() ) @@ -76,33 +70,29 @@ internal class BudgetServiceAsyncTest { val budgetFuture = budgetServiceAsync.update( - BudgetUpdateParams.builder() - .budgetNew( - BudgetNew.builder() - .budgetDuration("budget_duration") - .budgetId("budget_id") - .maxBudget(0.0) - .maxParallelRequests(0L) - .modelMaxBudget( - BudgetNew.ModelMaxBudget.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "budget_duration" to "budget_duration", - "max_budget" to 0, - "rpm_limit" to 0, - "tpm_limit" to 0, - ) - ), + BudgetNew.builder() + .budgetDuration("budget_duration") + .budgetId("budget_id") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget( + BudgetNew.ModelMaxBudget.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "budget_duration" to "budget_duration", + "max_budget" to 0, + "rpm_limit" to 0, + "tpm_limit" to 0, ) - .build() + ), ) - .rpmLimit(0L) - .softBudget(0.0) - .tpmLimit(0L) .build() ) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) .build() ) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt index 4287cf50..1ff0c289 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/CustomerServiceAsyncTest.kt @@ -6,11 +6,9 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.customer.BlockUsers -import ai.hanzo.api.models.customer.CustomerBlockParams import ai.hanzo.api.models.customer.CustomerCreateParams import ai.hanzo.api.models.customer.CustomerDeleteParams import ai.hanzo.api.models.customer.CustomerRetrieveInfoParams -import ai.hanzo.api.models.customer.CustomerUnblockParams import ai.hanzo.api.models.customer.CustomerUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -137,11 +135,7 @@ internal class CustomerServiceAsyncTest { val customerServiceAsync = client.customer() val responseFuture = - customerServiceAsync.block( - CustomerBlockParams.builder() - .blockUsers(BlockUsers.builder().addUserId("string").build()) - .build() - ) + customerServiceAsync.block(BlockUsers.builder().addUserId("string").build()) val response = responseFuture.get() response.validate() @@ -177,11 +171,7 @@ internal class CustomerServiceAsyncTest { val customerServiceAsync = client.customer() val responseFuture = - customerServiceAsync.unblock( - CustomerUnblockParams.builder() - .blockUsers(BlockUsers.builder().addUserId("string").build()) - .build() - ) + customerServiceAsync.unblock(BlockUsers.builder().addUserId("string").build()) val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt index 682e7e1c..a49c0299 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/DeleteServiceAsyncTest.kt @@ -5,7 +5,6 @@ package ai.hanzo.api.services.async import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.models.add.IpAddress -import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -24,11 +23,7 @@ internal class DeleteServiceAsyncTest { val deleteServiceAsync = client.delete() val responseFuture = - deleteServiceAsync.createAllowedIp( - DeleteCreateAllowedIpParams.builder() - .ipAddress(IpAddress.builder().ip("ip").build()) - .build() - ) + deleteServiceAsync.createAllowedIp(IpAddress.builder().ip("ip").build()) val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt index db14ee9a..66504ff8 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/TeamServiceAsyncTest.kt @@ -8,14 +8,12 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.team.BlockTeamRequest import ai.hanzo.api.models.team.Member import ai.hanzo.api.models.team.TeamAddMemberParams -import ai.hanzo.api.models.team.TeamBlockParams import ai.hanzo.api.models.team.TeamCreateParams import ai.hanzo.api.models.team.TeamDeleteParams import ai.hanzo.api.models.team.TeamListAvailableParams import ai.hanzo.api.models.team.TeamListParams import ai.hanzo.api.models.team.TeamRemoveMemberParams import ai.hanzo.api.models.team.TeamRetrieveInfoParams -import ai.hanzo.api.models.team.TeamUnblockParams import ai.hanzo.api.models.team.TeamUpdateMemberParams import ai.hanzo.api.models.team.TeamUpdateParams import org.junit.jupiter.api.Disabled @@ -185,11 +183,7 @@ internal class TeamServiceAsyncTest { val teamServiceAsync = client.team() val responseFuture = - teamServiceAsync.block( - TeamBlockParams.builder() - .blockTeamRequest(BlockTeamRequest.builder().teamId("team_id").build()) - .build() - ) + teamServiceAsync.block(BlockTeamRequest.builder().teamId("team_id").build()) val response = responseFuture.get() response.validate() @@ -285,11 +279,7 @@ internal class TeamServiceAsyncTest { val teamServiceAsync = client.team() val responseFuture = - teamServiceAsync.unblock( - TeamUnblockParams.builder() - .blockTeamRequest(BlockTeamRequest.builder().teamId("team_id").build()) - .build() - ) + teamServiceAsync.unblock(BlockTeamRequest.builder().teamId("team_id").build()) val response = responseFuture.get() response.validate() diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt index 6f52f260..b49911eb 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/config/PassThroughEndpointServiceAsyncTest.kt @@ -5,7 +5,6 @@ package ai.hanzo.api.services.async.config import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointCreateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointDeleteParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughGenericEndpoint @@ -28,14 +27,10 @@ internal class PassThroughEndpointServiceAsyncTest { val passThroughEndpointFuture = passThroughEndpointServiceAsync.create( - PassThroughEndpointCreateParams.builder() - .passThroughGenericEndpoint( - PassThroughGenericEndpoint.builder() - .headers(JsonValue.from(mapOf())) - .path("path") - .target("target") - .build() - ) + PassThroughGenericEndpoint.builder() + .headers(JsonValue.from(mapOf())) + .path("path") + .target("target") .build() ) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt index e8e9210e..1ee23b0f 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/async/model/UpdateServiceAsyncTest.kt @@ -7,7 +7,6 @@ import ai.hanzo.api.client.okhttp.HanzoOkHttpClientAsync import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.model.ModelInfo import ai.hanzo.api.models.model.update.UpdateDeployment -import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdatePartialParams import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled @@ -29,61 +28,57 @@ internal class UpdateServiceAsyncTest { val responseFuture = updateServiceAsync.full( - UpdateFullParams.builder() - .updateDeployment( - UpdateDeployment.builder() - .llmParams( - UpdateDeployment.LlmParams.builder() - .apiBase("api_base") - .apiKey("api_key") - .apiVersion("api_version") - .awsAccessKeyId("aws_access_key_id") - .awsRegionName("aws_region_name") - .awsSecretAccessKey("aws_secret_access_key") - .budgetDuration("budget_duration") - .addConfigurableClientsideAuthParam("string") - .customLlmProvider("custom_llm_provider") - .inputCostPerSecond(0.0) - .inputCostPerToken(0.0) - .llmTraceId("llm_trace_id") - .maxBudget(0.0) - .maxFileSizeMb(0.0) - .maxRetries(0L) - .mergeReasoningContentInChoices(true) - .model("model") - .modelInfo(JsonValue.from(mapOf())) - .organization("organization") - .outputCostPerSecond(0.0) - .outputCostPerToken(0.0) - .regionName("region_name") - .rpm(0L) - .streamTimeout(0.0) - .timeout(0.0) - .tpm(0L) - .useInPassThrough(true) - .vertexCredentials(JsonValue.from(mapOf())) - .vertexLocation("vertex_location") - .vertexProject("vertex_project") - .watsonxRegionName("watsonx_region_name") - .build() - ) - .modelInfo( - ModelInfo.builder() - .id("id") - .baseModel("base_model") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdBy("created_by") - .dbModel(true) - .teamId("team_id") - .teamPublicModelName("team_public_model_name") - .tier(ModelInfo.Tier.FREE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedBy("updated_by") - .build() - ) - .modelName("model_name") + UpdateDeployment.builder() + .llmParams( + UpdateDeployment.LlmParams.builder() + .apiBase("api_base") + .apiKey("api_key") + .apiVersion("api_version") + .awsAccessKeyId("aws_access_key_id") + .awsRegionName("aws_region_name") + .awsSecretAccessKey("aws_secret_access_key") + .budgetDuration("budget_duration") + .addConfigurableClientsideAuthParam("string") + .customLlmProvider("custom_llm_provider") + .inputCostPerSecond(0.0) + .inputCostPerToken(0.0) + .llmTraceId("llm_trace_id") + .maxBudget(0.0) + .maxFileSizeMb(0.0) + .maxRetries(0L) + .mergeReasoningContentInChoices(true) + .model("model") + .modelInfo(JsonValue.from(mapOf())) + .organization("organization") + .outputCostPerSecond(0.0) + .outputCostPerToken(0.0) + .regionName("region_name") + .rpm(0L) + .streamTimeout(0.0) + .timeout(0.0) + .tpm(0L) + .useInPassThrough(true) + .vertexCredentials(JsonValue.from(mapOf())) + .vertexLocation("vertex_location") + .vertexProject("vertex_project") + .watsonxRegionName("watsonx_region_name") + .build() + ) + .modelInfo( + ModelInfo.builder() + .id("id") + .baseModel("base_model") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .dbModel(true) + .teamId("team_id") + .teamPublicModelName("team_public_model_name") + .tier(ModelInfo.Tier.FREE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") .build() ) + .modelName("model_name") .build() ) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt index f290352c..f5b74ccd 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/AddServiceTest.kt @@ -4,7 +4,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient -import ai.hanzo.api.models.add.AddAddAllowedIpParams import ai.hanzo.api.models.add.IpAddress import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -23,12 +22,7 @@ internal class AddServiceTest { .build() val addService = client.add() - val response = - addService.addAllowedIp( - AddAddAllowedIpParams.builder() - .ipAddress(IpAddress.builder().ip("ip").build()) - .build() - ) + val response = addService.addAllowedIp(IpAddress.builder().ip("ip").build()) response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt index 25f94467..92e68085 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/BudgetServiceTest.kt @@ -5,12 +5,10 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.models.budget.BudgetCreateParams import ai.hanzo.api.models.budget.BudgetDeleteParams import ai.hanzo.api.models.budget.BudgetInfoParams import ai.hanzo.api.models.budget.BudgetNew import ai.hanzo.api.models.budget.BudgetSettingsParams -import ai.hanzo.api.models.budget.BudgetUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -30,33 +28,29 @@ internal class BudgetServiceTest { val budget = budgetService.create( - BudgetCreateParams.builder() - .budgetNew( - BudgetNew.builder() - .budgetDuration("budget_duration") - .budgetId("budget_id") - .maxBudget(0.0) - .maxParallelRequests(0L) - .modelMaxBudget( - BudgetNew.ModelMaxBudget.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "budget_duration" to "budget_duration", - "max_budget" to 0, - "rpm_limit" to 0, - "tpm_limit" to 0, - ) - ), + BudgetNew.builder() + .budgetDuration("budget_duration") + .budgetId("budget_id") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget( + BudgetNew.ModelMaxBudget.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "budget_duration" to "budget_duration", + "max_budget" to 0, + "rpm_limit" to 0, + "tpm_limit" to 0, ) - .build() + ), ) - .rpmLimit(0L) - .softBudget(0.0) - .tpmLimit(0L) .build() ) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) .build() ) @@ -75,33 +69,29 @@ internal class BudgetServiceTest { val budget = budgetService.update( - BudgetUpdateParams.builder() - .budgetNew( - BudgetNew.builder() - .budgetDuration("budget_duration") - .budgetId("budget_id") - .maxBudget(0.0) - .maxParallelRequests(0L) - .modelMaxBudget( - BudgetNew.ModelMaxBudget.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "budget_duration" to "budget_duration", - "max_budget" to 0, - "rpm_limit" to 0, - "tpm_limit" to 0, - ) - ), + BudgetNew.builder() + .budgetDuration("budget_duration") + .budgetId("budget_id") + .maxBudget(0.0) + .maxParallelRequests(0L) + .modelMaxBudget( + BudgetNew.ModelMaxBudget.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "budget_duration" to "budget_duration", + "max_budget" to 0, + "rpm_limit" to 0, + "tpm_limit" to 0, ) - .build() + ), ) - .rpmLimit(0L) - .softBudget(0.0) - .tpmLimit(0L) .build() ) + .rpmLimit(0L) + .softBudget(0.0) + .tpmLimit(0L) .build() ) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt index acefc54c..eb8b2dd7 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/CustomerServiceTest.kt @@ -6,11 +6,9 @@ import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.customer.BlockUsers -import ai.hanzo.api.models.customer.CustomerBlockParams import ai.hanzo.api.models.customer.CustomerCreateParams import ai.hanzo.api.models.customer.CustomerDeleteParams import ai.hanzo.api.models.customer.CustomerRetrieveInfoParams -import ai.hanzo.api.models.customer.CustomerUnblockParams import ai.hanzo.api.models.customer.CustomerUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -132,12 +130,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customer() - val response = - customerService.block( - CustomerBlockParams.builder() - .blockUsers(BlockUsers.builder().addUserId("string").build()) - .build() - ) + val response = customerService.block(BlockUsers.builder().addUserId("string").build()) response.validate() } @@ -170,12 +163,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customer() - val response = - customerService.unblock( - CustomerUnblockParams.builder() - .blockUsers(BlockUsers.builder().addUserId("string").build()) - .build() - ) + val response = customerService.unblock(BlockUsers.builder().addUserId("string").build()) response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt index 7a49258f..206c172e 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/DeleteServiceTest.kt @@ -5,7 +5,6 @@ package ai.hanzo.api.services.blocking import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.models.add.IpAddress -import ai.hanzo.api.models.delete.DeleteCreateAllowedIpParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,12 +22,7 @@ internal class DeleteServiceTest { .build() val deleteService = client.delete() - val response = - deleteService.createAllowedIp( - DeleteCreateAllowedIpParams.builder() - .ipAddress(IpAddress.builder().ip("ip").build()) - .build() - ) + val response = deleteService.createAllowedIp(IpAddress.builder().ip("ip").build()) response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt index 0b2a42ed..907f595c 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/TeamServiceTest.kt @@ -8,14 +8,12 @@ import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.team.BlockTeamRequest import ai.hanzo.api.models.team.Member import ai.hanzo.api.models.team.TeamAddMemberParams -import ai.hanzo.api.models.team.TeamBlockParams import ai.hanzo.api.models.team.TeamCreateParams import ai.hanzo.api.models.team.TeamDeleteParams import ai.hanzo.api.models.team.TeamListAvailableParams import ai.hanzo.api.models.team.TeamListParams import ai.hanzo.api.models.team.TeamRemoveMemberParams import ai.hanzo.api.models.team.TeamRetrieveInfoParams -import ai.hanzo.api.models.team.TeamUnblockParams import ai.hanzo.api.models.team.TeamUpdateMemberParams import ai.hanzo.api.models.team.TeamUpdateParams import org.junit.jupiter.api.Disabled @@ -179,12 +177,7 @@ internal class TeamServiceTest { .build() val teamService = client.team() - val response = - teamService.block( - TeamBlockParams.builder() - .blockTeamRequest(BlockTeamRequest.builder().teamId("team_id").build()) - .build() - ) + val response = teamService.block(BlockTeamRequest.builder().teamId("team_id").build()) response.validate() } @@ -272,12 +265,7 @@ internal class TeamServiceTest { .build() val teamService = client.team() - val response = - teamService.unblock( - TeamUnblockParams.builder() - .blockTeamRequest(BlockTeamRequest.builder().teamId("team_id").build()) - .build() - ) + val response = teamService.unblock(BlockTeamRequest.builder().teamId("team_id").build()) response.validate() } diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt index 88e62808..a0f7b134 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/config/PassThroughEndpointServiceTest.kt @@ -5,7 +5,6 @@ package ai.hanzo.api.services.blocking.config import ai.hanzo.api.TestServerExtension import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointCreateParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointDeleteParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughEndpointListParams import ai.hanzo.api.models.config.passthroughendpoint.PassThroughGenericEndpoint @@ -28,14 +27,10 @@ internal class PassThroughEndpointServiceTest { val passThroughEndpoint = passThroughEndpointService.create( - PassThroughEndpointCreateParams.builder() - .passThroughGenericEndpoint( - PassThroughGenericEndpoint.builder() - .headers(JsonValue.from(mapOf())) - .path("path") - .target("target") - .build() - ) + PassThroughGenericEndpoint.builder() + .headers(JsonValue.from(mapOf())) + .path("path") + .target("target") .build() ) diff --git a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt index 47fb79d5..127aa36b 100644 --- a/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt +++ b/hanzo-java-core/src/test/kotlin/ai/hanzo/api/services/blocking/model/UpdateServiceTest.kt @@ -7,7 +7,6 @@ import ai.hanzo.api.client.okhttp.HanzoOkHttpClient import ai.hanzo.api.core.JsonValue import ai.hanzo.api.models.model.ModelInfo import ai.hanzo.api.models.model.update.UpdateDeployment -import ai.hanzo.api.models.model.update.UpdateFullParams import ai.hanzo.api.models.model.update.UpdatePartialParams import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled @@ -29,61 +28,57 @@ internal class UpdateServiceTest { val response = updateService.full( - UpdateFullParams.builder() - .updateDeployment( - UpdateDeployment.builder() - .llmParams( - UpdateDeployment.LlmParams.builder() - .apiBase("api_base") - .apiKey("api_key") - .apiVersion("api_version") - .awsAccessKeyId("aws_access_key_id") - .awsRegionName("aws_region_name") - .awsSecretAccessKey("aws_secret_access_key") - .budgetDuration("budget_duration") - .addConfigurableClientsideAuthParam("string") - .customLlmProvider("custom_llm_provider") - .inputCostPerSecond(0.0) - .inputCostPerToken(0.0) - .llmTraceId("llm_trace_id") - .maxBudget(0.0) - .maxFileSizeMb(0.0) - .maxRetries(0L) - .mergeReasoningContentInChoices(true) - .model("model") - .modelInfo(JsonValue.from(mapOf())) - .organization("organization") - .outputCostPerSecond(0.0) - .outputCostPerToken(0.0) - .regionName("region_name") - .rpm(0L) - .streamTimeout(0.0) - .timeout(0.0) - .tpm(0L) - .useInPassThrough(true) - .vertexCredentials(JsonValue.from(mapOf())) - .vertexLocation("vertex_location") - .vertexProject("vertex_project") - .watsonxRegionName("watsonx_region_name") - .build() - ) - .modelInfo( - ModelInfo.builder() - .id("id") - .baseModel("base_model") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdBy("created_by") - .dbModel(true) - .teamId("team_id") - .teamPublicModelName("team_public_model_name") - .tier(ModelInfo.Tier.FREE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedBy("updated_by") - .build() - ) - .modelName("model_name") + UpdateDeployment.builder() + .llmParams( + UpdateDeployment.LlmParams.builder() + .apiBase("api_base") + .apiKey("api_key") + .apiVersion("api_version") + .awsAccessKeyId("aws_access_key_id") + .awsRegionName("aws_region_name") + .awsSecretAccessKey("aws_secret_access_key") + .budgetDuration("budget_duration") + .addConfigurableClientsideAuthParam("string") + .customLlmProvider("custom_llm_provider") + .inputCostPerSecond(0.0) + .inputCostPerToken(0.0) + .llmTraceId("llm_trace_id") + .maxBudget(0.0) + .maxFileSizeMb(0.0) + .maxRetries(0L) + .mergeReasoningContentInChoices(true) + .model("model") + .modelInfo(JsonValue.from(mapOf())) + .organization("organization") + .outputCostPerSecond(0.0) + .outputCostPerToken(0.0) + .regionName("region_name") + .rpm(0L) + .streamTimeout(0.0) + .timeout(0.0) + .tpm(0L) + .useInPassThrough(true) + .vertexCredentials(JsonValue.from(mapOf())) + .vertexLocation("vertex_location") + .vertexProject("vertex_project") + .watsonxRegionName("watsonx_region_name") + .build() + ) + .modelInfo( + ModelInfo.builder() + .id("id") + .baseModel("base_model") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") + .dbModel(true) + .teamId("team_id") + .teamPublicModelName("team_public_model_name") + .tier(ModelInfo.Tier.FREE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedBy("updated_by") .build() ) + .modelName("model_name") .build() ) diff --git a/scripts/fast-format b/scripts/fast-format index e16bfc56..1b3bc473 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -2,7 +2,12 @@ set -euo pipefail +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" if [ $# -eq 0 ]; then echo "Usage: $0 [additional-formatter-args...]" @@ -12,6 +17,8 @@ fi FILE_LIST="$1" +echo "Looking for file: $FILE_LIST" + if [ ! -f "$FILE_LIST" ]; then echo "Error: File '$FILE_LIST' not found" exit 1 @@ -23,9 +30,9 @@ if ! command -v ktfmt-fast-format &> /dev/null; then fi # Process Kotlin files -kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') -kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') -echo "==> Found $(echo "$kt_files" | wc -l) Kotlin files:" +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" From 589ce7af97f7b1fcea2519ae75f184ea7a6529ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 24 Jan 2026 02:31:30 +0000 Subject: [PATCH 38/75] feat(api): api update --- .github/workflows/ci.yml | 30 +- .github/workflows/publish-sonatype.yml | 4 +- .github/workflows/release-doctor.yml | 2 +- .stats.yml | 6 +- LICENSE | 2 +- README.md | 17 +- .../src/main/kotlin/hanzo.kotlin.gradle.kts | 3 + .../src/main/kotlin/hanzo.publish.gradle.kts | 21 +- hanzo-java-client-okhttp/build.gradle.kts | 1 + .../api/client/okhttp/HanzoOkHttpClient.kt | 22 + .../client/okhttp/HanzoOkHttpClientAsync.kt | 22 + .../hanzo/api/client/okhttp/OkHttpClient.kt | 53 +- .../api/client/okhttp/OkHttpClientTest.kt | 44 + hanzo-java-core/build.gradle.kts | 18 +- .../kotlin/ai/hanzo/api/core/ClientOptions.kt | 3 +- .../kotlin/ai/hanzo/api/core/ObjectMappers.kt | 31 +- .../ai/hanzo/api/core/http/HttpRequest.kt | 30 + .../hanzo/api/core/http/RetryingHttpClient.kt | 20 +- .../active/ActiveListCallbacksParams.kt | 22 +- .../models/anthropic/AnthropicCreateParams.kt | 2 +- .../models/anthropic/AnthropicDeleteParams.kt | 2 +- .../models/anthropic/AnthropicModifyParams.kt | 2 +- .../anthropic/AnthropicRetrieveParams.kt | 2 +- .../models/anthropic/AnthropicUpdateParams.kt | 2 +- .../hanzo/api/models/azure/AzureCallParams.kt | 3 + .../api/models/azure/AzureCreateParams.kt | 3 + .../api/models/azure/AzureDeleteParams.kt | 3 + .../api/models/azure/AzurePatchParams.kt | 3 + .../api/models/azure/AzureUpdateParams.kt | 3 + .../api/models/batches/BatchListParams.kt | 27 +- .../batches/BatchListWithProviderParams.kt | 27 +- .../api/models/bedrock/BedrockCreateParams.kt | 5 +- .../api/models/bedrock/BedrockDeleteParams.kt | 5 +- .../api/models/bedrock/BedrockPatchParams.kt | 5 +- .../models/bedrock/BedrockRetrieveParams.kt | 5 +- .../api/models/bedrock/BedrockUpdateParams.kt | 5 +- .../api/models/budget/BudgetCreateParams.kt | 2 + .../ai/hanzo/api/models/budget/BudgetNew.kt | 51 +- .../api/models/budget/BudgetUpdateParams.kt | 1 + .../api/models/cache/CacheDeleteParams.kt | 4 +- .../api/models/cache/CachePingResponse.kt | 212 +- .../completions/CompletionCreateParams.kt | 16913 ++++++++++++++- .../api/models/cohere/CohereCreateParams.kt | 2 +- .../api/models/cohere/CohereDeleteParams.kt | 2 +- .../api/models/cohere/CohereModifyParams.kt | 2 +- .../api/models/cohere/CohereRetrieveParams.kt | 2 +- .../api/models/cohere/CohereUpdateParams.kt | 2 +- .../PassThroughEndpointDeleteParams.kt | 2 +- .../PassThroughEndpointListParams.kt | 17 +- .../PassThroughEndpointUpdateParams.kt | 77 +- .../PassThroughGenericEndpoint.kt | 522 +- .../credentials/CredentialCreateParams.kt | 341 +- .../credentials/CredentialDeleteParams.kt | 2 + .../api/models/credentials/CredentialItem.kt | 277 +- .../models/customer/CustomerCreateParams.kt | 168 +- .../models/customer/CustomerDeleteParams.kt | 2 +- .../models/customer/CustomerListResponse.kt | 979 - .../customer/CustomerRetrieveInfoParams.kt | 2 +- .../customer/CustomerRetrieveInfoResponse.kt | 979 - .../models/customer/CustomerUpdateParams.kt | 2 +- .../models/customer/LiteLlmEndUserTable.kt | 561 + .../embeddings/EmbeddingCreateParams.kt | 1532 +- .../api/models/engines/EngineEmbedParams.kt | 1548 +- .../models/engines/chat/ChatCompleteParams.kt | 16926 +++++++++++++++- .../api/models/files/FileCreateParams.kt | 223 +- .../hanzo/api/models/files/FileListParams.kt | 20 +- .../models/finetuning/jobs/JobCreateParams.kt | 1722 +- .../models/finetuning/jobs/JobListParams.kt | 78 +- .../finetuning/jobs/JobRetrieveParams.kt | 35 +- .../jobs/LiteLlmFineTuningJobCreate.kt | 1423 ++ .../jobs/cancel/CancelCreateParams.kt | 2 +- .../api/models/gemini/GeminiCreateParams.kt | 2 +- .../api/models/gemini/GeminiDeleteParams.kt | 2 +- .../api/models/gemini/GeminiPatchParams.kt | 2 +- .../api/models/gemini/GeminiRetrieveParams.kt | 2 +- .../api/models/gemini/GeminiUpdateParams.kt | 2 +- .../global/spend/SpendListTagsParams.kt | 2 +- .../global/spend/SpendListTagsResponse.kt | 318 +- .../models/global/spend/SpendResetParams.kt | 8 +- .../spend/SpendRetrieveReportResponse.kt | 318 +- .../models/guardrails/GuardrailListParams.kt | 2 +- .../guardrails/GuardrailListResponse.kt | 2175 +- .../api/models/health/HealthCheckAllParams.kt | 28 +- .../health/HealthCheckServicesParams.kt | 24 + .../generations/GenerationCreateParams.kt | 25 +- .../api/models/key/GenerateKeyResponse.kt | 4181 +++- .../ai/hanzo/api/models/key/KeyBlockParams.kt | 35 +- .../hanzo/api/models/key/KeyBlockResponse.kt | 2126 +- .../hanzo/api/models/key/KeyDeleteParams.kt | 35 +- .../hanzo/api/models/key/KeyGenerateParams.kt | 4994 ++++- .../ai/hanzo/api/models/key/KeyListParams.kt | 130 +- .../hanzo/api/models/key/KeyListResponse.kt | 7414 ++++++- .../models/key/KeyRegenerateByKeyParams.kt | 39 +- .../api/models/key/KeyRetrieveInfoParams.kt | 4 +- .../hanzo/api/models/key/KeyUnblockParams.kt | 35 +- .../hanzo/api/models/key/KeyUpdateParams.kt | 4637 ++++- .../key/regenerate/RegenerateKeyRequest.kt | 4240 +++- .../models/langfuse/LangfuseCreateParams.kt | 4 +- .../models/langfuse/LangfuseDeleteParams.kt | 4 +- .../models/langfuse/LangfusePatchParams.kt | 4 +- .../models/langfuse/LangfuseRetrieveParams.kt | 4 +- .../models/langfuse/LangfuseUpdateParams.kt | 4 +- .../ConfigurableClientsideParamsCustomAuth.kt | 174 - .../api/models/model/ModelCreateParams.kt | 13507 ++++++++++-- .../api/models/model/info/InfoListParams.kt | 35 +- .../models/model/update/UpdateDeployment.kt | 13446 ++++++++++-- .../ModelGroupRetrieveInfoParams.kt | 4 +- .../api/models/models/ModelListParams.kt | 109 +- .../moderations/ModerationCreateParams.kt | 4 +- .../deployments/DeploymentEmbedParams.kt | 1548 +- .../deployments/chat/ChatCompleteParams.kt | 16926 +++++++++++++++- .../api/models/organization/BudgetTable.kt | 594 + .../api/models/organization/OrgMember.kt | 6 + .../OrganizationAddMemberParams.kt | 8 +- .../OrganizationAddMemberResponse.kt | 3016 ++- .../organization/OrganizationCreateParams.kt | 1349 +- .../OrganizationCreateResponse.kt | 2917 ++- .../OrganizationDeleteResponse.kt | 3413 ---- .../organization/OrganizationListParams.kt | 67 +- .../organization/OrganizationListResponse.kt | 3413 ---- .../OrganizationMembershipTable.kt | 484 + .../OrganizationTableWithMembers.kt | 5588 +++++ .../OrganizationUpdateMemberParams.kt | 201 +- .../OrganizationUpdateMemberResponse.kt | 900 - .../organization/OrganizationUpdateParams.kt | 678 +- .../OrganizationUpdateResponse.kt | 3413 ---- .../api/models/organization/UserRoles.kt | 172 + .../organization/info/InfoRetrieveResponse.kt | 3413 ---- .../provider/ProviderListBudgetsParams.kt | 2 +- .../models/responses/ResponseCreateParams.kt | 12 + .../models/responses/ResponseDeleteParams.kt | 4 + .../responses/ResponseRetrieveParams.kt | 8 + .../inputitems/InputItemListParams.kt | 11 +- .../models/settings/SettingRetrieveParams.kt | 22 +- .../models/spend/SpendCalculateSpendParams.kt | 183 +- .../api/models/spend/SpendListLogsParams.kt | 49 +- .../api/models/spend/SpendListLogsResponse.kt | 318 +- .../api/models/spend/SpendListTagsParams.kt | 2 +- .../api/models/spend/SpendListTagsResponse.kt | 318 +- .../kotlin/ai/hanzo/api/models/team/Member.kt | 17 + .../api/models/team/TeamAddMemberParams.kt | 57 +- .../api/models/team/TeamAddMemberResponse.kt | 5235 +++-- .../hanzo/api/models/team/TeamCreateParams.kt | 3482 +++- .../api/models/team/TeamCreateResponse.kt | 1151 +- .../hanzo/api/models/team/TeamDeleteParams.kt | 35 +- .../api/models/team/TeamRemoveMemberParams.kt | 2 +- .../api/models/team/TeamUpdateMemberParams.kt | 190 +- .../models/team/TeamUpdateMemberResponse.kt | 96 +- .../hanzo/api/models/team/TeamUpdateParams.kt | 2972 ++- .../models/team/callback/CallbackAddParams.kt | 35 +- .../hanzo/api/models/user/UserCreateParams.kt | 2772 ++- .../api/models/user/UserCreateResponse.kt | 4136 +++- .../hanzo/api/models/user/UserDeleteParams.kt | 35 +- .../hanzo/api/models/user/UserListParams.kt | 274 - .../hanzo/api/models/user/UserListResponse.kt | 113 - .../api/models/user/UserRetrieveInfoParams.kt | 2 +- .../hanzo/api/models/user/UserUpdateParams.kt | 2023 +- .../UtilGetSupportedOpenAIParamsParams.kt | 2 +- .../models/utils/UtilTokenCounterParams.kt | 373 +- .../models/utils/UtilTokenCounterResponse.kt | 288 +- .../utils/UtilTransformRequestParams.kt | 521 +- .../utils/UtilTransformRequestResponse.kt | 285 +- .../models/vertexai/VertexAiCreateParams.kt | 4 +- .../models/vertexai/VertexAiDeleteParams.kt | 4 +- .../models/vertexai/VertexAiPatchParams.kt | 4 +- .../models/vertexai/VertexAiRetrieveParams.kt | 4 +- .../models/vertexai/VertexAiUpdateParams.kt | 4 +- .../api/services/async/ActiveServiceAsync.kt | 22 +- .../services/async/AnthropicServiceAsync.kt | 10 +- .../api/services/async/AzureServiceAsync.kt | 15 + .../api/services/async/BedrockServiceAsync.kt | 25 +- .../api/services/async/BudgetServiceAsync.kt | 3 + .../api/services/async/CacheServiceAsync.kt | 4 +- .../api/services/async/CohereServiceAsync.kt | 10 +- .../services/async/CustomerServiceAsync.kt | 40 +- .../async/CustomerServiceAsyncImpl.kt | 19 +- .../services/async/EmbeddingServiceAsync.kt | 32 +- .../async/EmbeddingServiceAsyncImpl.kt | 2 +- .../api/services/async/EngineServiceAsync.kt | 58 +- .../services/async/EngineServiceAsyncImpl.kt | 4 +- .../api/services/async/FileServiceAsync.kt | 2 +- .../api/services/async/GeminiServiceAsync.kt | 10 +- .../services/async/GuardrailServiceAsync.kt | 2 +- .../api/services/async/HealthServiceAsync.kt | 2 +- .../api/services/async/KeyServiceAsync.kt | 114 +- .../services/async/LangfuseServiceAsync.kt | 20 +- .../services/async/ModelGroupServiceAsync.kt | 7 +- .../services/async/ModerationServiceAsync.kt | 4 +- .../async/OrganizationServiceAsync.kt | 94 +- .../async/OrganizationServiceAsyncImpl.kt | 40 +- .../services/async/ProviderServiceAsync.kt | 2 +- .../services/async/ResponseServiceAsync.kt | 24 + .../api/services/async/SettingServiceAsync.kt | 22 +- .../api/services/async/SpendServiceAsync.kt | 22 +- .../api/services/async/TeamServiceAsync.kt | 105 +- .../api/services/async/UserServiceAsync.kt | 115 +- .../services/async/UserServiceAsyncImpl.kt | 39 - .../api/services/async/UtilServiceAsync.kt | 9 +- .../services/async/VertexAiServiceAsync.kt | 20 +- .../async/chat/CompletionServiceAsync.kt | 33 +- .../async/chat/CompletionServiceAsyncImpl.kt | 2 +- .../config/PassThroughEndpointServiceAsync.kt | 54 +- .../PassThroughEndpointServiceAsyncImpl.kt | 2 +- .../async/engines/ChatServiceAsync.kt | 58 +- .../async/engines/ChatServiceAsyncImpl.kt | 4 +- .../async/finetuning/JobServiceAsync.kt | 120 +- .../finetuning/jobs/CancelServiceAsync.kt | 2 +- .../async/global/SpendServiceAsync.kt | 10 +- .../services/async/model/InfoServiceAsync.kt | 8 +- .../async/openai/DeploymentServiceAsync.kt | 58 +- .../openai/DeploymentServiceAsyncImpl.kt | 4 +- .../openai/deployments/ChatServiceAsync.kt | 58 +- .../deployments/ChatServiceAsyncImpl.kt | 4 +- .../async/organization/InfoServiceAsync.kt | 10 +- .../organization/InfoServiceAsyncImpl.kt | 10 +- .../async/responses/InputItemServiceAsync.kt | 11 +- .../api/services/blocking/ActiveService.kt | 22 +- .../api/services/blocking/AnthropicService.kt | 10 +- .../api/services/blocking/AzureService.kt | 15 + .../api/services/blocking/BedrockService.kt | 25 +- .../api/services/blocking/BudgetService.kt | 3 + .../api/services/blocking/CacheService.kt | 4 +- .../api/services/blocking/CohereService.kt | 10 +- .../api/services/blocking/CustomerService.kt | 39 +- .../services/blocking/CustomerServiceImpl.kt | 19 +- .../api/services/blocking/EmbeddingService.kt | 31 +- .../services/blocking/EmbeddingServiceImpl.kt | 2 +- .../api/services/blocking/EngineService.kt | 52 +- .../services/blocking/EngineServiceImpl.kt | 4 +- .../api/services/blocking/FileService.kt | 2 +- .../api/services/blocking/GeminiService.kt | 10 +- .../api/services/blocking/GuardrailService.kt | 2 +- .../api/services/blocking/HealthService.kt | 2 +- .../hanzo/api/services/blocking/KeyService.kt | 114 +- .../api/services/blocking/LangfuseService.kt | 20 +- .../services/blocking/ModelGroupService.kt | 7 +- .../services/blocking/ModerationService.kt | 4 +- .../services/blocking/OrganizationService.kt | 94 +- .../blocking/OrganizationServiceImpl.kt | 40 +- .../api/services/blocking/ProviderService.kt | 2 +- .../api/services/blocking/ResponseService.kt | 24 + .../api/services/blocking/SettingService.kt | 22 +- .../api/services/blocking/SpendService.kt | 22 +- .../api/services/blocking/TeamService.kt | 105 +- .../api/services/blocking/UserService.kt | 114 +- .../api/services/blocking/UserServiceImpl.kt | 33 - .../api/services/blocking/UtilService.kt | 9 +- .../api/services/blocking/VertexAiService.kt | 20 +- .../blocking/chat/CompletionService.kt | 31 +- .../blocking/chat/CompletionServiceImpl.kt | 2 +- .../config/PassThroughEndpointService.kt | 56 +- .../config/PassThroughEndpointServiceImpl.kt | 2 +- .../services/blocking/engines/ChatService.kt | 54 +- .../blocking/engines/ChatServiceImpl.kt | 4 +- .../blocking/finetuning/JobService.kt | 116 +- .../blocking/finetuning/jobs/CancelService.kt | 2 +- .../services/blocking/global/SpendService.kt | 10 +- .../services/blocking/model/InfoService.kt | 8 +- .../blocking/openai/DeploymentService.kt | 54 +- .../blocking/openai/DeploymentServiceImpl.kt | 4 +- .../openai/deployments/ChatService.kt | 54 +- .../openai/deployments/ChatServiceImpl.kt | 4 +- .../blocking/organization/InfoService.kt | 10 +- .../blocking/organization/InfoServiceImpl.kt | 10 +- .../blocking/responses/InputItemService.kt | 11 +- .../ai/hanzo/api/core/ObjectMappersTest.kt | 57 +- .../ai/hanzo/api/core/http/HttpRequestTest.kt | 110 + .../api/models/batches/BatchListParamsTest.kt | 16 +- .../BatchListWithProviderParamsTest.kt | 16 +- .../models/budget/BudgetCreateParamsTest.kt | 4 + .../hanzo/api/models/budget/BudgetNewTest.kt | 5 + .../models/budget/BudgetUpdateParamsTest.kt | 4 + .../api/models/cache/CachePingResponseTest.kt | 26 +- .../completions/CompletionCreateParamsTest.kt | 248 +- .../PassThroughEndpointCreateParamsTest.kt | 84 +- .../PassThroughEndpointListParamsTest.kt | 15 +- .../PassThroughEndpointResponseTest.kt | 69 +- .../PassThroughEndpointUpdateParamsTest.kt | 125 +- .../PassThroughGenericEndpointTest.kt | 72 +- .../credentials/CredentialCreateParamsTest.kt | 51 +- .../models/credentials/CredentialItemTest.kt | 39 +- .../customer/CustomerCreateParamsTest.kt | 7 + .../customer/CustomerListResponseTest.kt | 89 - .../CustomerRetrieveInfoResponseTest.kt | 89 - .../customer/LiteLlmEndUserTableTest.kt | 105 + .../embeddings/EmbeddingCreateParamsTest.kt | 76 +- .../models/engines/EngineEmbedParamsTest.kt | 81 +- .../engines/chat/ChatCompleteParamsTest.kt | 261 +- .../api/models/files/FileCreateParamsTest.kt | 9 + .../api/models/files/FileListParamsTest.kt | 21 +- .../finetuning/jobs/JobCreateParamsTest.kt | 106 +- .../finetuning/jobs/JobListParamsTest.kt | 17 +- .../finetuning/jobs/JobRetrieveParamsTest.kt | 15 +- .../jobs/LiteLlmFineTuningJobCreateTest.kt | 80 + .../guardrails/GuardrailListResponseTest.kt | 162 +- .../models/health/HealthCheckAllParamsTest.kt | 9 +- .../generations/GenerationCreateParamsTest.kt | 22 +- .../api/models/key/GenerateKeyResponseTest.kt | 358 +- .../api/models/key/KeyBlockParamsTest.kt | 8 +- .../api/models/key/KeyBlockResponseTest.kt | 221 +- .../api/models/key/KeyDeleteParamsTest.kt | 8 +- .../api/models/key/KeyGenerateParamsTest.kt | 458 +- .../hanzo/api/models/key/KeyListParamsTest.kt | 18 + .../key/KeyRegenerateByKeyParamsTest.kt | 464 +- .../api/models/key/KeyUnblockParamsTest.kt | 8 +- .../api/models/key/KeyUpdateParamsTest.kt | 448 +- .../regenerate/RegenerateKeyRequestTest.kt | 348 +- ...figurableClientsideParamsCustomAuthTest.kt | 35 - .../api/models/model/ModelCreateParamsTest.kt | 246 +- .../models/model/info/InfoListParamsTest.kt | 6 +- .../model/update/UpdateDeploymentTest.kt | 240 +- .../model/update/UpdateFullParamsTest.kt | 241 +- .../model/update/UpdatePartialParamsTest.kt | 241 +- .../api/models/models/ModelListParamsTest.kt | 23 +- .../deployments/DeploymentEmbedParamsTest.kt | 81 +- .../chat/ChatCompleteParamsTest.kt | 261 +- .../models/organization/BudgetTableTest.kt | 73 + .../OrganizationAddMemberResponseTest.kt | 211 +- .../OrganizationCreateParamsTest.kt | 113 +- .../OrganizationCreateResponseTest.kt | 362 +- .../OrganizationDeleteResponseTest.kt | 282 - .../OrganizationListParamsTest.kt | 25 +- .../OrganizationListResponseTest.kt | 282 - ....kt => OrganizationMembershipTableTest.kt} | 68 +- .../OrganizationTableWithMembersTest.kt | 695 + .../OrganizationUpdateMemberParamsTest.kt | 6 +- .../OrganizationUpdateParamsTest.kt | 44 +- .../OrganizationUpdateResponseTest.kt | 282 - .../info/InfoRetrieveResponseTest.kt | 281 - .../spend/SpendCalculateSpendParamsTest.kt | 19 +- .../models/spend/SpendListLogsParamsTest.kt | 3 + .../models/team/TeamAddMemberResponseTest.kt | 340 +- .../api/models/team/TeamCreateParamsTest.kt | 271 +- .../api/models/team/TeamCreateResponseTest.kt | 117 +- .../api/models/team/TeamDeleteParamsTest.kt | 17 +- .../models/team/TeamUpdateMemberParamsTest.kt | 6 + .../team/TeamUpdateMemberResponseTest.kt | 6 + .../api/models/team/TeamUpdateParamsTest.kt | 261 +- .../team/callback/CallbackAddParamsTest.kt | 8 +- .../api/models/user/UserCreateParamsTest.kt | 191 +- .../api/models/user/UserCreateResponseTest.kt | 358 +- .../api/models/user/UserDeleteParamsTest.kt | 17 +- .../api/models/user/UserListParamsTest.kt | 42 - .../api/models/user/UserListResponseTest.kt | 30 - .../api/models/user/UserUpdateParamsTest.kt | 182 +- .../utils/UtilTokenCounterParamsTest.kt | 71 +- .../utils/UtilTokenCounterResponseTest.kt | 26 + .../utils/UtilTransformRequestParamsTest.kt | 19 +- .../utils/UtilTransformRequestResponseTest.kt | 40 +- .../services/async/BatchServiceAsyncTest.kt | 8 +- .../services/async/BudgetServiceAsyncTest.kt | 3 + .../async/CredentialServiceAsyncTest.kt | 12 +- .../async/CustomerServiceAsyncTest.kt | 15 +- .../async/EmbeddingServiceAsyncTest.kt | 23 +- .../services/async/EngineServiceAsyncTest.kt | 26 +- .../services/async/FileServiceAsyncTest.kt | 9 +- .../services/async/HealthServiceAsyncTest.kt | 4 +- .../api/services/async/KeyServiceAsyncTest.kt | 353 +- .../services/async/ModelServiceAsyncTest.kt | 80 +- .../async/OrganizationServiceAsyncTest.kt | 80 +- .../services/async/SpendServiceAsyncTest.kt | 7 +- .../services/async/TeamServiceAsyncTest.kt | 132 +- .../services/async/UserServiceAsyncTest.kt | 146 +- .../services/async/UtilServiceAsyncTest.kt | 18 +- .../async/chat/CompletionServiceAsyncTest.kt | 73 +- .../PassThroughEndpointServiceAsyncTest.kt | 64 +- .../async/engines/ChatServiceAsyncTest.kt | 75 +- .../async/finetuning/JobServiceAsyncTest.kt | 11 +- .../images/GenerationServiceAsyncTest.kt | 4 +- .../async/model/InfoServiceAsyncTest.kt | 4 +- .../async/model/UpdateServiceAsyncTest.kt | 161 +- .../openai/DeploymentServiceAsyncTest.kt | 26 +- .../deployments/ChatServiceAsyncTest.kt | 75 +- .../organization/InfoServiceAsyncTest.kt | 6 +- .../async/team/CallbackServiceAsyncTest.kt | 2 +- .../api/services/blocking/BatchServiceTest.kt | 8 +- .../services/blocking/BudgetServiceTest.kt | 3 + .../blocking/CredentialServiceTest.kt | 12 +- .../services/blocking/CustomerServiceTest.kt | 11 +- .../services/blocking/EmbeddingServiceTest.kt | 23 +- .../services/blocking/EngineServiceTest.kt | 26 +- .../api/services/blocking/FileServiceTest.kt | 9 +- .../services/blocking/HealthServiceTest.kt | 5 +- .../api/services/blocking/KeyServiceTest.kt | 353 +- .../api/services/blocking/ModelServiceTest.kt | 80 +- .../blocking/OrganizationServiceTest.kt | 72 +- .../api/services/blocking/SpendServiceTest.kt | 7 +- .../api/services/blocking/TeamServiceTest.kt | 132 +- .../api/services/blocking/UserServiceTest.kt | 145 +- .../api/services/blocking/UtilServiceTest.kt | 18 +- .../blocking/chat/CompletionServiceTest.kt | 73 +- .../config/PassThroughEndpointServiceTest.kt | 64 +- .../blocking/engines/ChatServiceTest.kt | 75 +- .../blocking/finetuning/JobServiceTest.kt | 11 +- .../blocking/images/GenerationServiceTest.kt | 4 +- .../blocking/model/InfoServiceTest.kt | 3 +- .../blocking/model/UpdateServiceTest.kt | 161 +- .../blocking/openai/DeploymentServiceTest.kt | 26 +- .../openai/deployments/ChatServiceTest.kt | 75 +- .../blocking/organization/InfoServiceTest.kt | 4 +- .../blocking/team/CallbackServiceTest.kt | 2 +- hanzo-java-example/build.gradle.kts | 3 +- hanzo-java-proguard-test/build.gradle.kts | 2 +- .../api/proguard/ProGuardCompatibilityTest.kt | 24 + scripts/upload-artifacts | 193 + 405 files changed, 159715 insertions(+), 32854 deletions(-) create mode 100644 hanzo-java-client-okhttp/src/test/kotlin/ai/hanzo/api/client/okhttp/OkHttpClientTest.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/LiteLlmEndUserTable.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/LiteLlmFineTuningJobCreate.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/BudgetTable.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponse.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationListResponse.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationMembershipTable.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationTableWithMembers.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateMemberResponse.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponse.kt create mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/UserRoles.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponse.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListParams.kt delete mode 100644 hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/user/UserListResponse.kt create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/core/http/HttpRequestTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerListResponseTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponseTest.kt create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/customer/LiteLlmEndUserTableTest.kt create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/finetuning/jobs/LiteLlmFineTuningJobCreateTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuthTest.kt create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/BudgetTableTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationDeleteResponseTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationListResponseTest.kt rename hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/{OrganizationUpdateMemberResponseTest.kt => OrganizationMembershipTableTest.kt} (52%) create mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationTableWithMembersTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/OrganizationUpdateResponseTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/organization/info/InfoRetrieveResponseTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListParamsTest.kt delete mode 100644 hanzo-java-core/src/test/kotlin/ai/hanzo/api/models/user/UserListResponseTest.kt create mode 100755 scripts/upload-artifacts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdde8e99..a211506d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,10 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | @@ -40,14 +40,17 @@ jobs: build: timeout-minutes: 15 name: build + permissions: + contents: read + id-token: write runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | @@ -61,16 +64,31 @@ jobs: - name: Build SDK run: ./scripts/build + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/hanzo-ai-java' + id: github-oidc + uses: actions/github-script@v8 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Build and upload Maven artifacts + if: github.repository == 'stainless-sdks/hanzo-ai-java' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + PROJECT: hanzo-ai-java + run: ./scripts/upload-artifacts test: timeout-minutes: 15 name: test runs-on: ${{ github.repository == 'stainless-sdks/hanzo-ai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 7bfbe407..a89fe023 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 6de875a6..272e3ac8 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'hanzoai/java-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Check release environment run: | diff --git a/.stats.yml b/.stats.yml index 310f6103..1c6affb9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 188 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-10a8fe872c67396add3ebc3a10252df5bcd6d0f4e9a255d923875a806b2f1609.yml -openapi_spec_hash: 495ad4b04c4dd929e9566b6a099ff931 +configured_endpoints: 187 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2Fhanzo-ai-f3051af15c3ecf2556c73a185fcd4dfff4f444c8977a4840b0b17df16984224d.yml +openapi_spec_hash: 94cb4110b315114c72be390df33a4b00 config_hash: e927bafd76a1eace11894efc3517d245 diff --git a/LICENSE b/LICENSE index 614d2f02..ff91a2c8 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 Hanzo + Copyright 2026 Hanzo Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 19ef3fd4..5e2e658e 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,15 @@ The Hanzo Java SDK is similar to the Hanzo Kotlin SDK but with minor differences It is generated with [Stainless](https://www.stainless.com/). +## MCP Server + +Use the Hanzo MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=hanzoai-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImhhbnpvYWktbWNwIl19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22hanzoai-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22hanzoai-mcp%22%5D%7D) + +> Note: You may need to set environment variables in your MCP client. + The REST API documentation can be found on [docs.hanzo.ai](https://docs.hanzo.ai). Javadocs are available on [javadoc.io](https://javadoc.io/doc/ai.hanzo.api/hanzo-java/0.1.0-alpha.2). @@ -294,13 +303,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square Enable logging by setting the `HANZO_LOG` environment variable to `info`: ```sh -$ export HANZO_LOG=info +export HANZO_LOG=info ``` Or to `debug` for more verbose logging: ```sh -$ export HANZO_LOG=debug +export HANZO_LOG=debug ``` ## ProGuard and R8 @@ -320,6 +329,8 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t > [!CAUTION] > We make no guarantee that the SDK works correctly when the Jackson version check is disabled. +Also note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead. + ## Network options ### Retries @@ -492,7 +503,7 @@ import ai.hanzo.api.core.JsonValue; import ai.hanzo.api.models.model.ModelCreateParams; ModelCreateParams params = ModelCreateParams.builder() - .llmParams(ModelCreateParams.LlmParams.builder() + .litellmParams(ModelCreateParams.LitellmParams.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); diff --git a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts index c86cd9f0..fc8f35d8 100644 --- a/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.kotlin.gradle.kts @@ -33,6 +33,9 @@ kotlin { tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") + + // `SKIP_MOCK_TESTS` affects which tests run so it must be added as input for proper cache invalidation. + inputs.property("skipMockTests", System.getenv("SKIP_MOCK_TESTS")).optional(true) } val ktfmt by configurations.creating diff --git a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts index d4c39529..2e3484a9 100644 --- a/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/hanzo.publish.gradle.kts @@ -7,6 +7,17 @@ plugins { id("com.vanniktech.maven.publish") } +publishing { + repositories { + if (project.hasProperty("publishLocal")) { + maven { + name = "LocalFileSystem" + url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + } + } + } +} + repositories { gradlePluginPortal() mavenCentral() @@ -17,8 +28,10 @@ extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID") extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD") configure { - signAllPublications() - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + if (!project.hasProperty("publishLocal")) { + signAllPublications() + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + } coordinates(project.group.toString(), project.name, project.version.toString()) configure( @@ -29,8 +42,8 @@ configure { ) pom { - name.set("Hanzo API") - description.set("API documentation for Hanzo") + name.set("LiteLLM API") + description.set("Proxy Server to call 100+ LLMs in the OpenAI format.\n[**Customize Swagger Docs**](https://docs.litellm.ai/docs/proxy/enterprise#swagger-docs---custom-routes--branding)\n\n👉 [`LiteLLM Admin Panel on /ui`](/ui). Create, Edit Keys with SSO. Having\nissues? Try [`Fallback Login`](/fallback/login)\n\n💸 [`LiteLLM Model Cost Map`](https://models.litellm.ai/).\n\n🔎 [`LiteLLM Model Hub`](/ui/model_hub_table). See available models on the\nproxy. [**Docs**](https://docs.litellm.ai/docs/proxy/ai_hub)") url.set("https://docs.hanzo.ai") licenses { diff --git a/hanzo-java-client-okhttp/build.gradle.kts b/hanzo-java-client-okhttp/build.gradle.kts index 20cd525a..4307d79f 100644 --- a/hanzo-java-client-okhttp/build.gradle.kts +++ b/hanzo-java-client-okhttp/build.gradle.kts @@ -11,4 +11,5 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt index 778c7e40..139f16c1 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClient.kt @@ -16,6 +16,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -44,11 +45,31 @@ class HanzoOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -303,6 +324,7 @@ class HanzoOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt index 3a965e58..d6689bbc 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/HanzoOkHttpClientAsync.kt @@ -16,6 +16,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -44,11 +45,31 @@ class HanzoOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -303,6 +324,7 @@ class HanzoOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt index 53370f56..3dc8e1a6 100644 --- a/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt +++ b/hanzo-java-client-okhttp/src/main/kotlin/ai/hanzo/api/client/okhttp/OkHttpClient.kt @@ -13,12 +13,15 @@ import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration +import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -29,8 +32,8 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : - HttpClient { +class OkHttpClient +private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) @@ -50,20 +53,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC ): CompletableFuture { val future = CompletableFuture() - request.body?.run { future.whenComplete { _, _ -> close() } } - - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + val call = newCall(request, requestOptions) + call.enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(HanzoIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(HanzoIoException("Request failed", e)) } - ) + } + ) + + future.whenComplete { _, e -> + if (e is CancellationException) { + call.cancel() + } + request.body?.close() + } return future } @@ -86,7 +94,7 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC if (logLevel != null) { clientBuilder.addNetworkInterceptor( HttpLoggingInterceptor().setLevel(logLevel).apply { - redactHeader("Ocp-Apim-Subscription-Key") + redactHeader("x-litellm-api-key") } ) } @@ -111,19 +119,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC val builder = Request.Builder().url(toUrl()).method(method.name, body) headers.names().forEach { name -> - headers.values(name).forEach { builder.header(name, it) } + headers.values(name).forEach { builder.addHeader(name, it) } } if ( !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 ) { - builder.header( + builder.addHeader( "X-Stainless-Read-Timeout", Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.header( + builder.addHeader( "X-Stainless-Timeout", Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) @@ -194,6 +202,7 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -204,6 +213,10 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { this.sslSocketFactory = sslSocketFactory } @@ -219,12 +232,16 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() + // `RetryingHttpClient` handles retries if the user enabled them. + .retryOnConnectionFailure(false) .connectTimeout(timeout.connect()) .readTimeout(timeout.read()) .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) .apply { + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { diff --git a/hanzo-java-client-okhttp/src/test/kotlin/ai/hanzo/api/client/okhttp/OkHttpClientTest.kt b/hanzo-java-client-okhttp/src/test/kotlin/ai/hanzo/api/client/okhttp/OkHttpClientTest.kt new file mode 100644 index 00000000..7f855e39 --- /dev/null +++ b/hanzo-java-client-okhttp/src/test/kotlin/ai/hanzo/api/client/okhttp/OkHttpClientTest.kt @@ -0,0 +1,44 @@ +package ai.hanzo.api.client.okhttp + +import ai.hanzo.api.core.http.HttpMethod +import ai.hanzo.api.core.http.HttpRequest +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class OkHttpClientTest { + + private lateinit var baseUrl: String + private lateinit var httpClient: OkHttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + httpClient = OkHttpClient.builder().build() + } + + @Test + fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val responseFuture = + httpClient.executeAsync( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build() + ) + val call = httpClient.okHttpClient.dispatcher.runningCalls().single() + + responseFuture.cancel(false) + + // Should have cancelled the underlying call + assertThat(call.isCanceled()).isTrue() + } +} diff --git a/hanzo-java-core/build.gradle.kts b/hanzo-java-core/build.gradle.kts index 78e32327..4d1c6331 100644 --- a/hanzo-java-core/build.gradle.kts +++ b/hanzo-java-core/build.gradle.kts @@ -5,14 +5,16 @@ plugins { configurations.all { resolutionStrategy { - // Compile and test against a lower Jackson version to ensure we're compatible with it. - // We publish with a higher version (see below) to ensure users depend on a secure version by default. - force("com.fasterxml.jackson.core:jackson-core:2.13.4") - force("com.fasterxml.jackson.core:jackson-databind:2.13.4") - force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") - force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") - force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") - force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + // Compile and test against a lower Jackson version to ensure we're compatible with it. Note that + // we generally support 2.13.4, but test against 2.14.0 because 2.13.4 has some annoying (but + // niche) bugs (users should upgrade if they encounter them). We publish with a higher version + // (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.14.0") + force("com.fasterxml.jackson.core:jackson-databind:2.14.0") + force("com.fasterxml.jackson.core:jackson-annotations:2.14.0") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.0") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt index 19851417..66631ea7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ClientOptions.kt @@ -415,9 +415,10 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) apiKey.let { if (!it.isEmpty()) { - headers.put("Ocp-Apim-Subscription-Key", it) + headers.put("x-litellm-api-key", it) } } headers.replaceAll(this.headers.build()) diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt index 1a43c083..9c610872 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/ObjectMappers.kt @@ -24,7 +24,8 @@ import java.io.InputStream import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime -import java.time.ZonedDateTime +import java.time.OffsetDateTime +import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField @@ -36,7 +37,7 @@ fun jsonMapper(): JsonMapper = .addModule( SimpleModule() .addSerializer(InputStreamSerializer) - .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + .addDeserializer(OffsetDateTime::class.java, LenientOffsetDateTimeDeserializer()) ) .withCoercionConfig(LogicalType.Boolean) { it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) @@ -47,6 +48,7 @@ fun jsonMapper(): JsonMapper = } .withCoercionConfig(LogicalType.Integer) { it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) .setCoercion(CoercionInputShape.String, CoercionAction.Fail) .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) @@ -64,6 +66,12 @@ fun jsonMapper(): JsonMapper = .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) } + .withCoercionConfig(LogicalType.DateTime) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } .withCoercionConfig(LogicalType.Array) { it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) @@ -124,10 +132,10 @@ private object InputStreamSerializer : BaseSerializer(InputStream:: } /** - * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + * A deserializer that can deserialize [OffsetDateTime] from datetimes, dates, and zoned datetimes. */ -private class LenientLocalDateTimeDeserializer : - StdDeserializer(LocalDateTime::class.java) { +private class LenientOffsetDateTimeDeserializer : + StdDeserializer(OffsetDateTime::class.java) { companion object { @@ -141,7 +149,7 @@ private class LenientLocalDateTimeDeserializer : override fun logicalType(): LogicalType = LogicalType.DateTime - override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + override fun deserialize(p: JsonParser, context: DeserializationContext): OffsetDateTime { val exceptions = mutableListOf() for (formatter in DATE_TIME_FORMATTERS) { @@ -150,17 +158,20 @@ private class LenientLocalDateTimeDeserializer : return when { !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() + LocalDate.from(temporal) + .atStartOfDay() + .atZone(ZoneId.of("UTC")) + .toOffsetDateTime() !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() + LocalDateTime.from(temporal).atZone(ZoneId.of("UTC")).toOffsetDateTime() + else -> OffsetDateTime.from(temporal) } } catch (e: DateTimeException) { exceptions.add(e) } } - throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + throw JsonParseException(p, "Cannot parse `OffsetDateTime` from value: ${p.text}").apply { exceptions.forEach { addSuppressed(it) } } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt index 9afb39ca..04404fbc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/HttpRequest.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.core.http import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.toImmutable +import java.net.URLEncoder class HttpRequest private constructor( @@ -13,6 +14,35 @@ private constructor( @get:JvmName("body") val body: HttpRequestBody?, ) { + fun url(): String = buildString { + append(baseUrl) + + pathSegments.forEach { segment -> + if (!endsWith("/")) { + append("/") + } + append(URLEncoder.encode(segment, "UTF-8")) + } + + if (queryParams.isEmpty()) { + return@buildString + } + + append("?") + var isFirst = true + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { value -> + if (!isFirst) { + append("&") + } + append(URLEncoder.encode(key, "UTF-8")) + append("=") + append(URLEncoder.encode(value, "UTF-8")) + isFirst = false + } + } + } + fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt index 9e807198..e17cec71 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/core/http/RetryingHttpClient.kt @@ -31,10 +31,6 @@ private constructor( ) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { - if (!isRetryable(request) || maxRetries <= 0) { - return httpClient.execute(request, requestOptions) - } - var modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. @@ -48,6 +44,10 @@ private constructor( modifiedRequest = setRetryCountHeader(modifiedRequest, retries) } + if (!isRetryable(modifiedRequest)) { + return httpClient.execute(modifiedRequest, requestOptions) + } + val response = try { val response = httpClient.execute(modifiedRequest, requestOptions) @@ -75,10 +75,6 @@ private constructor( request: HttpRequest, requestOptions: RequestOptions, ): CompletableFuture { - if (!isRetryable(request) || maxRetries <= 0) { - return httpClient.executeAsync(request, requestOptions) - } - val modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. @@ -94,8 +90,12 @@ private constructor( val requestWithRetryCount = if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request - return httpClient - .executeAsync(requestWithRetryCount, requestOptions) + val responseFuture = httpClient.executeAsync(requestWithRetryCount, requestOptions) + if (!isRetryable(requestWithRetryCount)) { + return responseFuture + } + + return responseFuture .handleAsync( fun( response: HttpResponse?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt index e2932265..e8002193 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/active/ActiveListCallbacksParams.kt @@ -8,7 +8,7 @@ import ai.hanzo.api.core.http.QueryParams import java.util.Objects /** - * Returns a list of llm level settings + * Returns a list of litellm level settings * * This is useful for debugging and ensuring the proxy server is configured correctly. * @@ -16,17 +16,17 @@ import java.util.Objects * ``` * { * "alerting": _alerting, - * "llm.callbacks": llm_callbacks, - * "llm.input_callback": llm_input_callbacks, - * "llm.failure_callback": llm_failure_callbacks, - * "llm.success_callback": llm_success_callbacks, - * "llm._async_success_callback": llm_async_success_callbacks, - * "llm._async_failure_callback": llm_async_failure_callbacks, - * "llm._async_input_callback": llm_async_input_callbacks, - * "all_llm_callbacks": all_llm_callbacks, - * "num_callbacks": len(all_llm_callbacks), + * "litellm.callbacks": litellm_callbacks, + * "litellm.input_callback": litellm_input_callbacks, + * "litellm.failure_callback": litellm_failure_callbacks, + * "litellm.success_callback": litellm_success_callbacks, + * "litellm._async_success_callback": litellm_async_success_callbacks, + * "litellm._async_failure_callback": litellm_async_failure_callbacks, + * "litellm._async_input_callback": litellm_async_input_callbacks, + * "all_litellm_callbacks": all_litellm_callbacks, + * "num_callbacks": len(all_litellm_callbacks), * "num_alerting": _num_alerting, - * "llm.request_timeout": llm.request_timeout, + * "litellm.request_timeout": litellm.request_timeout, * } * ``` */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt index 64e2fe3c..1a355f7d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicCreateParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */ class AnthropicCreateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt index 06021e70..e9ed26cd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicDeleteParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */ class AnthropicDeleteParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt index bd52aa0e..00086d48 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicModifyParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */ class AnthropicModifyParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt index 0b927414..51ed59a2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicRetrieveParams.kt @@ -9,7 +9,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */ class AnthropicRetrieveParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt index f6110089..541c66ee 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/anthropic/AnthropicUpdateParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/anthropic_completion) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion) */ class AnthropicUpdateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt index 1f041c32..add1f0e2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCallParams.kt @@ -13,6 +13,9 @@ import kotlin.jvm.optionals.getOrNull * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` + * + * Checks if the deployment id in the url is a litellm model name. If so, it will route using the + * llm_router.allm_passthrough_route. */ class AzureCallParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt index d26340a5..807e0ede 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureCreateParams.kt @@ -15,6 +15,9 @@ import kotlin.jvm.optionals.getOrNull * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` + * + * Checks if the deployment id in the url is a litellm model name. If so, it will route using the + * llm_router.allm_passthrough_route. */ class AzureCreateParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt index 026e2cce..09278e4d 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureDeleteParams.kt @@ -15,6 +15,9 @@ import kotlin.jvm.optionals.getOrNull * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` + * + * Checks if the deployment id in the url is a litellm model name. If so, it will route using the + * llm_router.allm_passthrough_route. */ class AzureDeleteParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt index bd8229c3..512eca15 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzurePatchParams.kt @@ -15,6 +15,9 @@ import kotlin.jvm.optionals.getOrNull * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` + * + * Checks if the deployment id in the url is a litellm model name. If so, it will route using the + * llm_router.allm_passthrough_route. */ class AzurePatchParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt index 988950be..0a551f28 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/azure/AzureUpdateParams.kt @@ -15,6 +15,9 @@ import kotlin.jvm.optionals.getOrNull * Call any azure endpoint using the proxy. * * Just use `{PROXY_BASE_URL}/azure/{endpoint:path}` + * + * Checks if the deployment id in the url is a litellm model name. If so, it will route using the + * llm_router.allm_passthrough_route. */ class AzureUpdateParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt index a78f103f..0c2da8f8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListParams.kt @@ -24,6 +24,7 @@ private constructor( private val after: String?, private val limit: Long?, private val provider: String?, + private val targetModelNames: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -34,6 +35,8 @@ private constructor( fun provider(): Optional = Optional.ofNullable(provider) + fun targetModelNames(): Optional = Optional.ofNullable(targetModelNames) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -56,6 +59,7 @@ private constructor( private var after: String? = null private var limit: Long? = null private var provider: String? = null + private var targetModelNames: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -64,6 +68,7 @@ private constructor( after = batchListParams.after limit = batchListParams.limit provider = batchListParams.provider + targetModelNames = batchListParams.targetModelNames additionalHeaders = batchListParams.additionalHeaders.toBuilder() additionalQueryParams = batchListParams.additionalQueryParams.toBuilder() } @@ -90,6 +95,14 @@ private constructor( /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ fun provider(provider: Optional) = provider(provider.getOrNull()) + fun targetModelNames(targetModelNames: String?) = apply { + this.targetModelNames = targetModelNames + } + + /** Alias for calling [Builder.targetModelNames] with `targetModelNames.orElse(null)`. */ + fun targetModelNames(targetModelNames: Optional) = + targetModelNames(targetModelNames.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -198,6 +211,7 @@ private constructor( after, limit, provider, + targetModelNames, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -211,6 +225,7 @@ private constructor( after?.let { put("after", it) } limit?.let { put("limit", it.toString()) } provider?.let { put("provider", it) } + targetModelNames?.let { put("target_model_names", it) } putAll(additionalQueryParams) } .build() @@ -224,13 +239,21 @@ private constructor( after == other.after && limit == other.limit && provider == other.provider && + targetModelNames == other.targetModelNames && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(after, limit, provider, additionalHeaders, additionalQueryParams) + Objects.hash( + after, + limit, + provider, + targetModelNames, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "BatchListParams{after=$after, limit=$limit, provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BatchListParams{after=$after, limit=$limit, provider=$provider, targetModelNames=$targetModelNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt index fb3075b9..2a1cfe58 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/batches/BatchListWithProviderParams.kt @@ -24,6 +24,7 @@ private constructor( private val provider: String?, private val after: String?, private val limit: Long?, + private val targetModelNames: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -34,6 +35,8 @@ private constructor( fun limit(): Optional = Optional.ofNullable(limit) + fun targetModelNames(): Optional = Optional.ofNullable(targetModelNames) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -58,6 +61,7 @@ private constructor( private var provider: String? = null private var after: String? = null private var limit: Long? = null + private var targetModelNames: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -66,6 +70,7 @@ private constructor( provider = batchListWithProviderParams.provider after = batchListWithProviderParams.after limit = batchListWithProviderParams.limit + targetModelNames = batchListWithProviderParams.targetModelNames additionalHeaders = batchListWithProviderParams.additionalHeaders.toBuilder() additionalQueryParams = batchListWithProviderParams.additionalQueryParams.toBuilder() } @@ -92,6 +97,14 @@ private constructor( /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) + fun targetModelNames(targetModelNames: String?) = apply { + this.targetModelNames = targetModelNames + } + + /** Alias for calling [Builder.targetModelNames] with `targetModelNames.orElse(null)`. */ + fun targetModelNames(targetModelNames: Optional) = + targetModelNames(targetModelNames.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -200,6 +213,7 @@ private constructor( provider, after, limit, + targetModelNames, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -218,6 +232,7 @@ private constructor( .apply { after?.let { put("after", it) } limit?.let { put("limit", it.toString()) } + targetModelNames?.let { put("target_model_names", it) } putAll(additionalQueryParams) } .build() @@ -231,13 +246,21 @@ private constructor( provider == other.provider && after == other.after && limit == other.limit && + targetModelNames == other.targetModelNames && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(provider, after, limit, additionalHeaders, additionalQueryParams) + Objects.hash( + provider, + after, + limit, + targetModelNames, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "BatchListWithProviderParams{provider=$provider, after=$after, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BatchListWithProviderParams{provider=$provider, after=$after, limit=$limit, targetModelNames=$targetModelNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt index 00a3d2ea..f500a6a9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockCreateParams.kt @@ -11,7 +11,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ +/** + * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint. + * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock) + */ class BedrockCreateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt index 4d91fe27..c690ef16 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockDeleteParams.kt @@ -11,7 +11,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ +/** + * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint. + * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock) + */ class BedrockDeleteParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt index b13b8b78..13a6caef 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockPatchParams.kt @@ -11,7 +11,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ +/** + * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint. + * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock) + */ class BedrockPatchParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt index dbd34dad..71031606 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockRetrieveParams.kt @@ -9,7 +9,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ +/** + * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint. + * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock) + */ class BedrockRetrieveParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt index f4159be3..6667c553 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/bedrock/BedrockUpdateParams.kt @@ -11,7 +11,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/bedrock) */ +/** + * This is the v1 passthrough for Bedrock. V2 is handled by the `/bedrock/v2` endpoint. + * [Docs](https://docs.litellm.ai/docs/pass_through/bedrock) + */ class BedrockUpdateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt index a5aa51f1..4595af23 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetCreateParams.kt @@ -23,6 +23,8 @@ import java.util.Objects * - model_max_budget: Optional[dict] - Specify max budget for a given model. Example: * {"openai/gpt-4o-mini": {"max_budget": 100.0, "budget_duration": "1d", "tpm_limit": 100000, * "rpm_limit": 100000}} + * - budget_reset_at: Optional[datetime] - Datetime when the initial budget is reset. Default is + * now. */ class BudgetCreateParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt index 50994fa8..1af94bbc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetNew.kt @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -22,6 +23,7 @@ class BudgetNew private constructor( private val budgetDuration: JsonField, private val budgetId: JsonField, + private val budgetResetAt: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, private val modelMaxBudget: JsonField, @@ -37,6 +39,9 @@ private constructor( @ExcludeMissing budgetDuration: JsonField = JsonMissing.of(), @JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(), + @JsonProperty("budget_reset_at") + @ExcludeMissing + budgetResetAt: JsonField = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @JsonProperty("max_parallel_requests") @ExcludeMissing @@ -52,6 +57,7 @@ private constructor( ) : this( budgetDuration, budgetId, + budgetResetAt, maxBudget, maxParallelRequests, modelMaxBudget, @@ -77,6 +83,14 @@ private constructor( */ fun budgetId(): Optional = budgetId.getOptional("budget_id") + /** + * Datetime when the budget is reset + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") + /** * Requests will fail if this budget (in USD) is exceeded. * @@ -143,6 +157,15 @@ private constructor( */ @JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId + /** + * Returns the raw JSON value of [budgetResetAt]. + * + * Unlike [budgetResetAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("budget_reset_at") + @ExcludeMissing + fun _budgetResetAt(): JsonField = budgetResetAt + /** * Returns the raw JSON value of [maxBudget]. * @@ -213,6 +236,7 @@ private constructor( private var budgetDuration: JsonField = JsonMissing.of() private var budgetId: JsonField = JsonMissing.of() + private var budgetResetAt: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() private var modelMaxBudget: JsonField = JsonMissing.of() @@ -225,6 +249,7 @@ private constructor( internal fun from(budgetNew: BudgetNew) = apply { budgetDuration = budgetNew.budgetDuration budgetId = budgetNew.budgetId + budgetResetAt = budgetNew.budgetResetAt maxBudget = budgetNew.maxBudget maxParallelRequests = budgetNew.maxParallelRequests modelMaxBudget = budgetNew.modelMaxBudget @@ -267,6 +292,25 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } + /** Datetime when the budget is reset */ + fun budgetResetAt(budgetResetAt: OffsetDateTime?) = + budgetResetAt(JsonField.ofNullable(budgetResetAt)) + + /** Alias for calling [Builder.budgetResetAt] with `budgetResetAt.orElse(null)`. */ + fun budgetResetAt(budgetResetAt: Optional) = + budgetResetAt(budgetResetAt.getOrNull()) + + /** + * Sets [Builder.budgetResetAt] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetResetAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun budgetResetAt(budgetResetAt: JsonField) = apply { + this.budgetResetAt = budgetResetAt + } + /** Requests will fail if this budget (in USD) is exceeded. */ fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) @@ -432,6 +476,7 @@ private constructor( BudgetNew( budgetDuration, budgetId, + budgetResetAt, maxBudget, maxParallelRequests, modelMaxBudget, @@ -451,6 +496,7 @@ private constructor( budgetDuration() budgetId() + budgetResetAt() maxBudget() maxParallelRequests() modelMaxBudget().ifPresent { it.validate() } @@ -477,6 +523,7 @@ private constructor( internal fun validity(): Int = (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetId.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + @@ -595,6 +642,7 @@ private constructor( return other is BudgetNew && budgetDuration == other.budgetDuration && budgetId == other.budgetId && + budgetResetAt == other.budgetResetAt && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && modelMaxBudget == other.modelMaxBudget && @@ -608,6 +656,7 @@ private constructor( Objects.hash( budgetDuration, budgetId, + budgetResetAt, maxBudget, maxParallelRequests, modelMaxBudget, @@ -621,5 +670,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BudgetNew{budgetDuration=$budgetDuration, budgetId=$budgetId, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}" + "BudgetNew{budgetDuration=$budgetDuration, budgetId=$budgetId, budgetResetAt=$budgetResetAt, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt index 0cd47a5d..4464bddc 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/budget/BudgetUpdateParams.kt @@ -23,6 +23,7 @@ import java.util.Objects * - model_max_budget: Optional[dict] - Specify max budget for a given model. Example: * {"openai/gpt-4o-mini": {"max_budget": 100.0, "budget_duration": "1d", "tpm_limit": 100000, * "rpm_limit": 100000}} + * - budget_reset_at: Optional[datetime] - Update the Datetime when the budget was last reset. */ class BudgetUpdateParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt index 17253ed3..88acb3cd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CacheDeleteParams.kt @@ -11,8 +11,8 @@ import java.util.Objects import java.util.Optional /** - * Endpoint for deleting a key from the cache. All responses from llm proxy have `x-llm-cache-key` - * in the headers + * Endpoint for deleting a key from the cache. All responses from litellm proxy have + * `x-litellm-cache-key` in the headers * * Parameters: * - **keys**: *Optional[List[str]]* - A list of keys to delete from the cache. Example {"keys": diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt index 0cc0d933..1606d05a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cache/CachePingResponse.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,8 +23,8 @@ class CachePingResponse private constructor( private val cacheType: JsonField, private val status: JsonField, - private val healthCheckCacheParams: JsonValue, - private val llmCacheParams: JsonField, + private val healthCheckCacheParams: JsonField, + private val litellmCacheParams: JsonField, private val pingResponse: JsonField, private val setCacheResponse: JsonField, private val additionalProperties: MutableMap, @@ -35,10 +36,10 @@ private constructor( @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("health_check_cache_params") @ExcludeMissing - healthCheckCacheParams: JsonValue = JsonMissing.of(), - @JsonProperty("llm_cache_params") + healthCheckCacheParams: JsonField = JsonMissing.of(), + @JsonProperty("litellm_cache_params") @ExcludeMissing - llmCacheParams: JsonField = JsonMissing.of(), + litellmCacheParams: JsonField = JsonMissing.of(), @JsonProperty("ping_response") @ExcludeMissing pingResponse: JsonField = JsonMissing.of(), @@ -49,7 +50,7 @@ private constructor( cacheType, status, healthCheckCacheParams, - llmCacheParams, + litellmCacheParams, pingResponse, setCacheResponse, mutableMapOf(), @@ -67,15 +68,19 @@ private constructor( */ fun status(): String = status.getRequired("status") - @JsonProperty("health_check_cache_params") - @ExcludeMissing - fun _healthCheckCacheParams(): JsonValue = healthCheckCacheParams + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun healthCheckCacheParams(): Optional = + healthCheckCacheParams.getOptional("health_check_cache_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmCacheParams(): Optional = llmCacheParams.getOptional("llm_cache_params") + fun litellmCacheParams(): Optional = + litellmCacheParams.getOptional("litellm_cache_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -104,13 +109,24 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** - * Returns the raw JSON value of [llmCacheParams]. + * Returns the raw JSON value of [healthCheckCacheParams]. * - * Unlike [llmCacheParams], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [healthCheckCacheParams], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("llm_cache_params") + @JsonProperty("health_check_cache_params") @ExcludeMissing - fun _llmCacheParams(): JsonField = llmCacheParams + fun _healthCheckCacheParams(): JsonField = healthCheckCacheParams + + /** + * Returns the raw JSON value of [litellmCacheParams]. + * + * Unlike [litellmCacheParams], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_cache_params") + @ExcludeMissing + fun _litellmCacheParams(): JsonField = litellmCacheParams /** * Returns the raw JSON value of [pingResponse]. @@ -162,8 +178,8 @@ private constructor( private var cacheType: JsonField? = null private var status: JsonField? = null - private var healthCheckCacheParams: JsonValue = JsonMissing.of() - private var llmCacheParams: JsonField = JsonMissing.of() + private var healthCheckCacheParams: JsonField = JsonMissing.of() + private var litellmCacheParams: JsonField = JsonMissing.of() private var pingResponse: JsonField = JsonMissing.of() private var setCacheResponse: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -173,7 +189,7 @@ private constructor( cacheType = cachePingResponse.cacheType status = cachePingResponse.status healthCheckCacheParams = cachePingResponse.healthCheckCacheParams - llmCacheParams = cachePingResponse.llmCacheParams + litellmCacheParams = cachePingResponse.litellmCacheParams pingResponse = cachePingResponse.pingResponse setCacheResponse = cachePingResponse.setCacheResponse additionalProperties = cachePingResponse.additionalProperties.toMutableMap() @@ -200,26 +216,46 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } - fun healthCheckCacheParams(healthCheckCacheParams: JsonValue) = apply { - this.healthCheckCacheParams = healthCheckCacheParams - } + fun healthCheckCacheParams(healthCheckCacheParams: HealthCheckCacheParams?) = + healthCheckCacheParams(JsonField.ofNullable(healthCheckCacheParams)) + + /** + * Alias for calling [Builder.healthCheckCacheParams] with + * `healthCheckCacheParams.orElse(null)`. + */ + fun healthCheckCacheParams(healthCheckCacheParams: Optional) = + healthCheckCacheParams(healthCheckCacheParams.getOrNull()) + + /** + * Sets [Builder.healthCheckCacheParams] to an arbitrary JSON value. + * + * You should usually call [Builder.healthCheckCacheParams] with a well-typed + * [HealthCheckCacheParams] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun healthCheckCacheParams(healthCheckCacheParams: JsonField) = + apply { + this.healthCheckCacheParams = healthCheckCacheParams + } - fun llmCacheParams(llmCacheParams: String?) = - llmCacheParams(JsonField.ofNullable(llmCacheParams)) + fun litellmCacheParams(litellmCacheParams: String?) = + litellmCacheParams(JsonField.ofNullable(litellmCacheParams)) - /** Alias for calling [Builder.llmCacheParams] with `llmCacheParams.orElse(null)`. */ - fun llmCacheParams(llmCacheParams: Optional) = - llmCacheParams(llmCacheParams.getOrNull()) + /** + * Alias for calling [Builder.litellmCacheParams] with `litellmCacheParams.orElse(null)`. + */ + fun litellmCacheParams(litellmCacheParams: Optional) = + litellmCacheParams(litellmCacheParams.getOrNull()) /** - * Sets [Builder.llmCacheParams] to an arbitrary JSON value. + * Sets [Builder.litellmCacheParams] to an arbitrary JSON value. * - * You should usually call [Builder.llmCacheParams] with a well-typed [String] value + * You should usually call [Builder.litellmCacheParams] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun llmCacheParams(llmCacheParams: JsonField) = apply { - this.llmCacheParams = llmCacheParams + fun litellmCacheParams(litellmCacheParams: JsonField) = apply { + this.litellmCacheParams = litellmCacheParams } fun pingResponse(pingResponse: Boolean?) = pingResponse(JsonField.ofNullable(pingResponse)) @@ -300,7 +336,7 @@ private constructor( checkRequired("cacheType", cacheType), checkRequired("status", status), healthCheckCacheParams, - llmCacheParams, + litellmCacheParams, pingResponse, setCacheResponse, additionalProperties.toMutableMap(), @@ -316,7 +352,8 @@ private constructor( cacheType() status() - llmCacheParams() + healthCheckCacheParams().ifPresent { it.validate() } + litellmCacheParams() pingResponse() setCacheResponse() validated = true @@ -339,10 +376,115 @@ private constructor( internal fun validity(): Int = (if (cacheType.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + - (if (llmCacheParams.asKnown().isPresent) 1 else 0) + + (healthCheckCacheParams.asKnown().getOrNull()?.validity() ?: 0) + + (if (litellmCacheParams.asKnown().isPresent) 1 else 0) + (if (pingResponse.asKnown().isPresent) 1 else 0) + (if (setCacheResponse.asKnown().isPresent) 1 else 0) + class HealthCheckCacheParams + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HealthCheckCacheParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HealthCheckCacheParams]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(healthCheckCacheParams: HealthCheckCacheParams) = apply { + additionalProperties = healthCheckCacheParams.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HealthCheckCacheParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): HealthCheckCacheParams = + HealthCheckCacheParams(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): HealthCheckCacheParams = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HealthCheckCacheParams && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HealthCheckCacheParams{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -352,7 +494,7 @@ private constructor( cacheType == other.cacheType && status == other.status && healthCheckCacheParams == other.healthCheckCacheParams && - llmCacheParams == other.llmCacheParams && + litellmCacheParams == other.litellmCacheParams && pingResponse == other.pingResponse && setCacheResponse == other.setCacheResponse && additionalProperties == other.additionalProperties @@ -363,7 +505,7 @@ private constructor( cacheType, status, healthCheckCacheParams, - llmCacheParams, + litellmCacheParams, pingResponse, setCacheResponse, additionalProperties, @@ -373,5 +515,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CachePingResponse{cacheType=$cacheType, status=$status, healthCheckCacheParams=$healthCheckCacheParams, llmCacheParams=$llmCacheParams, pingResponse=$pingResponse, setCacheResponse=$setCacheResponse, additionalProperties=$additionalProperties}" + "CachePingResponse{cacheType=$cacheType, status=$status, healthCheckCacheParams=$healthCheckCacheParams, litellmCacheParams=$litellmCacheParams, pingResponse=$pingResponse, setCacheResponse=$setCacheResponse, additionalProperties=$additionalProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt index f417ec47..2f9ac31f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/chat/completions/CompletionCreateParams.kt @@ -2,11 +2,34 @@ package ai.hanzo.api.models.chat.completions +import ai.hanzo.api.core.BaseDeserializer +import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.Enum +import ai.hanzo.api.core.ExcludeMissing +import ai.hanzo.api.core.JsonField +import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.allMaxBy +import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable +import ai.hanzo.api.errors.HanzoInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -32,16 +55,394 @@ import kotlin.jvm.optionals.getOrNull */ class CompletionCreateParams private constructor( - private val model: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { - fun model(): Optional = Optional.ofNullable(model) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List = body.messages() - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun model(): String = body.model() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = body.caching() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbackDict(): Optional = + body.contextWindowFallbackDict() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = body.fallbacks() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun frequencyPenalty(): Optional = body.frequencyPenalty() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functionCall(): Optional = body.functionCall() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functions(): Optional> = body.functions() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrails(): Optional> = body.guardrails() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logitBias(): Optional = body.logitBias() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logprobs(): Optional = body.logprobs() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = body.maxTokens() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun n(): Optional = body.n() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = body.numRetries() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional = body.parallelToolCalls() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun presencePenalty(): Optional = body.presencePenalty() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFormat(): Optional = body.responseFormat() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun seed(): Optional = body.seed() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceTier(): Optional = body.serviceTier() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stop(): Optional = body.stop() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stream(): Optional = body.stream() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamOptions(): Optional = body.streamOptions() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = body.temperature() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun toolChoice(): Optional = body.toolChoice() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tools(): Optional> = body.tools() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topLogprobs(): Optional = body.topLogprobs() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topP(): Optional = body.topP() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = body.user() + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _messages(): JsonField> = body._messages() + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _model(): JsonField = body._model() + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _caching(): JsonField = body._caching() + + /** + * Returns the raw JSON value of [contextWindowFallbackDict]. + * + * Unlike [contextWindowFallbackDict], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _contextWindowFallbackDict(): JsonField = + body._contextWindowFallbackDict() + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fallbacks(): JsonField> = body._fallbacks() + + /** + * Returns the raw JSON value of [frequencyPenalty]. + * + * Unlike [frequencyPenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _frequencyPenalty(): JsonField = body._frequencyPenalty() + + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _functionCall(): JsonField = body._functionCall() + + /** + * Returns the raw JSON value of [functions]. + * + * Unlike [functions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _functions(): JsonField> = body._functions() + + /** + * Returns the raw JSON value of [guardrails]. + * + * Unlike [guardrails], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _guardrails(): JsonField> = body._guardrails() + + /** + * Returns the raw JSON value of [logitBias]. + * + * Unlike [logitBias], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _logitBias(): JsonField = body._logitBias() + + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _logprobs(): JsonField = body._logprobs() + + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _maxTokens(): JsonField = body._maxTokens() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [n]. + * + * Unlike [n], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _n(): JsonField = body._n() + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _numRetries(): JsonField = body._numRetries() + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _parallelToolCalls(): JsonField = body._parallelToolCalls() + + /** + * Returns the raw JSON value of [presencePenalty]. + * + * Unlike [presencePenalty], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _presencePenalty(): JsonField = body._presencePenalty() + + /** + * Returns the raw JSON value of [responseFormat]. + * + * Unlike [responseFormat], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _responseFormat(): JsonField = body._responseFormat() + + /** + * Returns the raw JSON value of [seed]. + * + * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _seed(): JsonField = body._seed() + + /** + * Returns the raw JSON value of [serviceTier]. + * + * Unlike [serviceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _serviceTier(): JsonField = body._serviceTier() + + /** + * Returns the raw JSON value of [stop]. + * + * Unlike [stop], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _stop(): JsonField = body._stop() + + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _stream(): JsonField = body._stream() + + /** + * Returns the raw JSON value of [streamOptions]. + * + * Unlike [streamOptions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _streamOptions(): JsonField = body._streamOptions() + + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _temperature(): JsonField = body._temperature() + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _toolChoice(): JsonField = body._toolChoice() + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tools(): JsonField> = body._tools() + + /** + * Returns the raw JSON value of [topLogprobs]. + * + * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topLogprobs(): JsonField = body._topLogprobs() + + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topP(): JsonField = body._topP() + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _user(): JsonField = body._user() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -53,180 +454,16448 @@ private constructor( companion object { - @JvmStatic fun none(): CompletionCreateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [CompletionCreateParams]. */ + /** + * Returns a mutable builder for constructing an instance of [CompletionCreateParams]. + * + * The following fields are required: + * ```java + * .messages() + * .model() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [CompletionCreateParams]. */ class Builder internal constructor() { - private var model: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(completionCreateParams: CompletionCreateParams) = apply { - model = completionCreateParams.model + body = completionCreateParams.body.toBuilder() additionalHeaders = completionCreateParams.additionalHeaders.toBuilder() additionalQueryParams = completionCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - completionCreateParams.additionalBodyProperties.toMutableMap() } - fun model(model: String?) = apply { this.model = model } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [messages] + * - [model] + * - [caching] + * - [contextWindowFallbackDict] + * - [fallbacks] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) + fun messages(messages: List) = apply { body.messages(messages) } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField>) = apply { body.messages(messages) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { body.addMessage(message) } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) + /** + * Alias for calling [addMessage] with `Message.ofChatCompletionUser(chatCompletionUser)`. + */ + fun addMessage(chatCompletionUser: Message.ChatCompletionUserMessage) = apply { + body.addMessage(chatCompletionUser) } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionAssistant(chatCompletionAssistant)`. + */ + fun addMessage(chatCompletionAssistant: Message.ChatCompletionAssistantMessage) = apply { + body.addMessage(chatCompletionAssistant) } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) + /** + * Alias for calling [addMessage] with `Message.ofChatCompletionTool(chatCompletionTool)`. + */ + fun addMessage(chatCompletionTool: Message.ChatCompletionToolMessage) = apply { + body.addMessage(chatCompletionTool) } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionSystem(chatCompletionSystem)`. + */ + fun addMessage(chatCompletionSystem: Message.ChatCompletionSystemMessage) = apply { + body.addMessage(chatCompletionSystem) } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionFunction(chatCompletionFunction)`. + */ + fun addMessage(chatCompletionFunction: Message.ChatCompletionFunctionMessage) = apply { + body.addMessage(chatCompletionFunction) } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionDeveloper(chatCompletionDeveloper)`. + */ + fun addMessage(chatCompletionDeveloper: Message.ChatCompletionDeveloperMessage) = apply { + body.addMessage(chatCompletionDeveloper) } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun model(model: String) = apply { body.model(model) } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField) = apply { body.model(model) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun caching(caching: Boolean?) = apply { body.caching(caching) } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + /** + * Alias for [Builder.caching]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun caching(caching: Boolean) = caching(caching as Boolean?) - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** Alias for calling [Builder.caching] with `caching.orElse(null)`. */ + fun caching(caching: Optional) = caching(caching.getOrNull()) - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun caching(caching: JsonField) = apply { body.caching(caching) } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun contextWindowFallbackDict(contextWindowFallbackDict: ContextWindowFallbackDict?) = + apply { + body.contextWindowFallbackDict(contextWindowFallbackDict) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + /** + * Alias for calling [Builder.contextWindowFallbackDict] with + * `contextWindowFallbackDict.orElse(null)`. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: Optional + ) = contextWindowFallbackDict(contextWindowFallbackDict.getOrNull()) - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + /** + * Sets [Builder.contextWindowFallbackDict] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbackDict] with a well-typed + * [ContextWindowFallbackDict] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: JsonField + ) = apply { body.contextWindowFallbackDict(contextWindowFallbackDict) } - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun fallbacks(fallbacks: List?) = apply { body.fallbacks(fallbacks) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { body.fallbacks(fallbacks) } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) + /** + * Adds a single [String] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: String) = apply { body.addFallback(fallback) } + + fun frequencyPenalty(frequencyPenalty: Double?) = apply { + body.frequencyPenalty(frequencyPenalty) } - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Alias for [Builder.frequencyPenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(frequencyPenalty as Double?) - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + /** Alias for calling [Builder.frequencyPenalty] with `frequencyPenalty.orElse(null)`. */ + fun frequencyPenalty(frequencyPenalty: Optional) = + frequencyPenalty(frequencyPenalty.getOrNull()) - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) + /** + * Sets [Builder.frequencyPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.frequencyPenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + body.frequencyPenalty(frequencyPenalty) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun functionCall(functionCall: FunctionCall?) = apply { body.functionCall(functionCall) } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) + + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun functionCall(functionCall: JsonField) = apply { + body.functionCall(functionCall) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + /** Alias for calling [functionCall] with `FunctionCall.ofString(string)`. */ + fun functionCall(string: String) = apply { body.functionCall(string) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) + /** Alias for calling [functionCall] with `FunctionCall.ofUnionMember1(unionMember1)`. */ + fun functionCall(unionMember1: FunctionCall.UnionMember1) = apply { + body.functionCall(unionMember1) } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun functions(functions: List?) = apply { body.functions(functions) } + + /** Alias for calling [Builder.functions] with `functions.orElse(null)`. */ + fun functions(functions: Optional>) = functions(functions.getOrNull()) /** - * Returns an immutable instance of [CompletionCreateParams]. + * Sets [Builder.functions] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * You should usually call [Builder.functions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun build(): CompletionCreateParams = - CompletionCreateParams( - model, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } + fun functions(functions: JsonField>) = apply { body.functions(functions) } + + /** + * Adds a single [Function] to [functions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFunction(function: Function) = apply { body.addFunction(function) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + fun guardrails(guardrails: List?) = apply { body.guardrails(guardrails) } - override fun _headers(): Headers = additionalHeaders + /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */ + fun guardrails(guardrails: Optional>) = guardrails(guardrails.getOrNull()) - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - model?.let { put("model", it) } - putAll(additionalQueryParams) - } - .build() + /** + * Sets [Builder.guardrails] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun guardrails(guardrails: JsonField>) = apply { body.guardrails(guardrails) } + + /** + * Adds a single [String] to [guardrails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGuardrail(guardrail: String) = apply { body.addGuardrail(guardrail) } + + fun logitBias(logitBias: LogitBias?) = apply { body.logitBias(logitBias) } + + /** Alias for calling [Builder.logitBias] with `logitBias.orElse(null)`. */ + fun logitBias(logitBias: Optional) = logitBias(logitBias.getOrNull()) + + /** + * Sets [Builder.logitBias] to an arbitrary JSON value. + * + * You should usually call [Builder.logitBias] with a well-typed [LogitBias] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun logitBias(logitBias: JsonField) = apply { body.logitBias(logitBias) } + + fun logprobs(logprobs: Boolean?) = apply { body.logprobs(logprobs) } + + /** + * Alias for [Builder.logprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun logprobs(logprobs: Boolean) = logprobs(logprobs as Boolean?) + + /** Alias for calling [Builder.logprobs] with `logprobs.orElse(null)`. */ + fun logprobs(logprobs: Optional) = logprobs(logprobs.getOrNull()) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun logprobs(logprobs: JsonField) = apply { body.logprobs(logprobs) } + + fun maxTokens(maxTokens: Long?) = apply { body.maxTokens(maxTokens) } + + /** + * Alias for [Builder.maxTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxTokens(maxTokens: Long) = maxTokens(maxTokens as Long?) + + /** Alias for calling [Builder.maxTokens] with `maxTokens.orElse(null)`. */ + fun maxTokens(maxTokens: Optional) = maxTokens(maxTokens.getOrNull()) + + /** + * Sets [Builder.maxTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokens] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun maxTokens(maxTokens: JsonField) = apply { body.maxTokens(maxTokens) } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun n(n: Long?) = apply { body.n(n) } + + /** + * Alias for [Builder.n]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun n(n: Long) = n(n as Long?) + + /** Alias for calling [Builder.n] with `n.orElse(null)`. */ + fun n(n: Optional) = n(n.getOrNull()) + + /** + * Sets [Builder.n] to an arbitrary JSON value. + * + * You should usually call [Builder.n] with a well-typed [Long] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun n(n: JsonField) = apply { body.n(n) } + + fun numRetries(numRetries: Long?) = apply { body.numRetries(numRetries) } + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numRetries(numRetries: JsonField) = apply { body.numRetries(numRetries) } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. */ + fun parallelToolCalls(parallelToolCalls: Optional) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + fun presencePenalty(presencePenalty: Double?) = apply { + body.presencePenalty(presencePenalty) + } + + /** + * Alias for [Builder.presencePenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun presencePenalty(presencePenalty: Double) = presencePenalty(presencePenalty as Double?) + + /** Alias for calling [Builder.presencePenalty] with `presencePenalty.orElse(null)`. */ + fun presencePenalty(presencePenalty: Optional) = + presencePenalty(presencePenalty.getOrNull()) + + /** + * Sets [Builder.presencePenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.presencePenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun presencePenalty(presencePenalty: JsonField) = apply { + body.presencePenalty(presencePenalty) + } + + fun responseFormat(responseFormat: ResponseFormat?) = apply { + body.responseFormat(responseFormat) + } + + /** Alias for calling [Builder.responseFormat] with `responseFormat.orElse(null)`. */ + fun responseFormat(responseFormat: Optional) = + responseFormat(responseFormat.getOrNull()) + + /** + * Sets [Builder.responseFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.responseFormat] with a well-typed [ResponseFormat] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun responseFormat(responseFormat: JsonField) = apply { + body.responseFormat(responseFormat) + } + + fun seed(seed: Long?) = apply { body.seed(seed) } + + /** + * Alias for [Builder.seed]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun seed(seed: Long) = seed(seed as Long?) + + /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ + fun seed(seed: Optional) = seed(seed.getOrNull()) + + /** + * Sets [Builder.seed] to an arbitrary JSON value. + * + * You should usually call [Builder.seed] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun seed(seed: JsonField) = apply { body.seed(seed) } + + fun serviceTier(serviceTier: String?) = apply { body.serviceTier(serviceTier) } + + /** Alias for calling [Builder.serviceTier] with `serviceTier.orElse(null)`. */ + fun serviceTier(serviceTier: Optional) = serviceTier(serviceTier.getOrNull()) + + /** + * Sets [Builder.serviceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceTier] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun serviceTier(serviceTier: JsonField) = apply { body.serviceTier(serviceTier) } + + fun stop(stop: Stop?) = apply { body.stop(stop) } + + /** Alias for calling [Builder.stop] with `stop.orElse(null)`. */ + fun stop(stop: Optional) = stop(stop.getOrNull()) + + /** + * Sets [Builder.stop] to an arbitrary JSON value. + * + * You should usually call [Builder.stop] with a well-typed [Stop] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun stop(stop: JsonField) = apply { body.stop(stop) } + + /** Alias for calling [stop] with `Stop.ofString(string)`. */ + fun stop(string: String) = apply { body.stop(string) } + + /** Alias for calling [stop] with `Stop.ofStrings(strings)`. */ + fun stopOfStrings(strings: List) = apply { body.stopOfStrings(strings) } + + fun stream(stream: Boolean?) = apply { body.stream(stream) } + + /** + * Alias for [Builder.stream]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun stream(stream: Boolean) = stream(stream as Boolean?) + + /** Alias for calling [Builder.stream] with `stream.orElse(null)`. */ + fun stream(stream: Optional) = stream(stream.getOrNull()) + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun stream(stream: JsonField) = apply { body.stream(stream) } + + fun streamOptions(streamOptions: StreamOptions?) = apply { + body.streamOptions(streamOptions) + } + + /** Alias for calling [Builder.streamOptions] with `streamOptions.orElse(null)`. */ + fun streamOptions(streamOptions: Optional) = + streamOptions(streamOptions.getOrNull()) + + /** + * Sets [Builder.streamOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.streamOptions] with a well-typed [StreamOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streamOptions(streamOptions: JsonField) = apply { + body.streamOptions(streamOptions) + } + + fun temperature(temperature: Double?) = apply { body.temperature(temperature) } + + /** + * Alias for [Builder.temperature]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun temperature(temperature: Double) = temperature(temperature as Double?) + + /** Alias for calling [Builder.temperature] with `temperature.orElse(null)`. */ + fun temperature(temperature: Optional) = temperature(temperature.getOrNull()) + + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun temperature(temperature: JsonField) = apply { body.temperature(temperature) } + + fun toolChoice(toolChoice: ToolChoice?) = apply { body.toolChoice(toolChoice) } + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [ToolChoice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolChoice(toolChoice: JsonField) = apply { body.toolChoice(toolChoice) } + + /** Alias for calling [toolChoice] with `ToolChoice.ofString(string)`. */ + fun toolChoice(string: String) = apply { body.toolChoice(string) } + + /** Alias for calling [toolChoice] with `ToolChoice.ofUnionMember1(unionMember1)`. */ + fun toolChoice(unionMember1: ToolChoice.UnionMember1) = apply { + body.toolChoice(unionMember1) + } + + fun tools(tools: List?) = apply { body.tools(tools) } + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tools(tools: JsonField>) = apply { body.tools(tools) } + + /** + * Adds a single [Tool] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: Tool) = apply { body.addTool(tool) } + + fun topLogprobs(topLogprobs: Long?) = apply { body.topLogprobs(topLogprobs) } + + /** + * Alias for [Builder.topLogprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topLogprobs(topLogprobs: Long) = topLogprobs(topLogprobs as Long?) + + /** Alias for calling [Builder.topLogprobs] with `topLogprobs.orElse(null)`. */ + fun topLogprobs(topLogprobs: Optional) = topLogprobs(topLogprobs.getOrNull()) + + /** + * Sets [Builder.topLogprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.topLogprobs] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topLogprobs(topLogprobs: JsonField) = apply { body.topLogprobs(topLogprobs) } + + fun topP(topP: Double?) = apply { body.topP(topP) } + + /** + * Alias for [Builder.topP]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topP(topP: Double) = topP(topP as Double?) + + /** Alias for calling [Builder.topP] with `topP.orElse(null)`. */ + fun topP(topP: Optional) = topP(topP.getOrNull()) + + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topP(topP: JsonField) = apply { body.topP(topP) } + + fun user(user: String?) = apply { body.user(user) } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun user(user: JsonField) = apply { body.user(user) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CompletionCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .model() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompletionCreateParams = + CompletionCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val messages: JsonField>, + private val model: JsonField, + private val caching: JsonField, + private val contextWindowFallbackDict: JsonField, + private val fallbacks: JsonField>, + private val frequencyPenalty: JsonField, + private val functionCall: JsonField, + private val functions: JsonField>, + private val guardrails: JsonField>, + private val logitBias: JsonField, + private val logprobs: JsonField, + private val maxTokens: JsonField, + private val metadata: JsonField, + private val n: JsonField, + private val numRetries: JsonField, + private val parallelToolCalls: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val seed: JsonField, + private val serviceTier: JsonField, + private val stop: JsonField, + private val stream: JsonField, + private val streamOptions: JsonField, + private val temperature: JsonField, + private val toolChoice: JsonField, + private val tools: JsonField>, + private val topLogprobs: JsonField, + private val topP: JsonField, + private val user: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("messages") + @ExcludeMissing + messages: JsonField> = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("caching") @ExcludeMissing caching: JsonField = JsonMissing.of(), + @JsonProperty("context_window_fallback_dict") + @ExcludeMissing + contextWindowFallbackDict: JsonField = JsonMissing.of(), + @JsonProperty("fallbacks") + @ExcludeMissing + fallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("frequency_penalty") + @ExcludeMissing + frequencyPenalty: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + functionCall: JsonField = JsonMissing.of(), + @JsonProperty("functions") + @ExcludeMissing + functions: JsonField> = JsonMissing.of(), + @JsonProperty("guardrails") + @ExcludeMissing + guardrails: JsonField> = JsonMissing.of(), + @JsonProperty("logit_bias") + @ExcludeMissing + logitBias: JsonField = JsonMissing.of(), + @JsonProperty("logprobs") + @ExcludeMissing + logprobs: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens") + @ExcludeMissing + maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("n") @ExcludeMissing n: JsonField = JsonMissing.of(), + @JsonProperty("num_retries") + @ExcludeMissing + numRetries: JsonField = JsonMissing.of(), + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + parallelToolCalls: JsonField = JsonMissing.of(), + @JsonProperty("presence_penalty") + @ExcludeMissing + presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("response_format") + @ExcludeMissing + responseFormat: JsonField = JsonMissing.of(), + @JsonProperty("seed") @ExcludeMissing seed: JsonField = JsonMissing.of(), + @JsonProperty("service_tier") + @ExcludeMissing + serviceTier: JsonField = JsonMissing.of(), + @JsonProperty("stop") @ExcludeMissing stop: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing stream: JsonField = JsonMissing.of(), + @JsonProperty("stream_options") + @ExcludeMissing + streamOptions: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + temperature: JsonField = JsonMissing.of(), + @JsonProperty("tool_choice") + @ExcludeMissing + toolChoice: JsonField = JsonMissing.of(), + @JsonProperty("tools") @ExcludeMissing tools: JsonField> = JsonMissing.of(), + @JsonProperty("top_logprobs") + @ExcludeMissing + topLogprobs: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing topP: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonField = JsonMissing.of(), + ) : this( + messages, + model, + caching, + contextWindowFallbackDict, + fallbacks, + frequencyPenalty, + functionCall, + functions, + guardrails, + logitBias, + logprobs, + maxTokens, + metadata, + n, + numRetries, + parallelToolCalls, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop, + stream, + streamOptions, + temperature, + toolChoice, + tools, + topLogprobs, + topP, + user, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List = messages.getRequired("messages") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun model(): String = model.getRequired("model") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = caching.getOptional("caching") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbackDict(): Optional = + contextWindowFallbackDict.getOptional("context_window_fallback_dict") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = fallbacks.getOptional("fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun frequencyPenalty(): Optional = frequencyPenalty.getOptional("frequency_penalty") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functionCall(): Optional = functionCall.getOptional("function_call") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functions(): Optional> = functions.getOptional("functions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrails(): Optional> = guardrails.getOptional("guardrails") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logitBias(): Optional = logitBias.getOptional("logit_bias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logprobs(): Optional = logprobs.getOptional("logprobs") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = maxTokens.getOptional("max_tokens") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun n(): Optional = n.getOptional("n") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = numRetries.getOptional("num_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional = + parallelToolCalls.getOptional("parallel_tool_calls") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun presencePenalty(): Optional = presencePenalty.getOptional("presence_penalty") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFormat(): Optional = + responseFormat.getOptional("response_format") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun seed(): Optional = seed.getOptional("seed") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceTier(): Optional = serviceTier.getOptional("service_tier") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stop(): Optional = stop.getOptional("stop") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stream(): Optional = stream.getOptional("stream") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamOptions(): Optional = streamOptions.getOptional("stream_options") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = temperature.getOptional("temperature") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun toolChoice(): Optional = toolChoice.getOptional("tool_choice") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tools(): Optional> = tools.getOptional("tools") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topLogprobs(): Optional = topLogprobs.getOptional("top_logprobs") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topP(): Optional = topP.getOptional("top_p") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = user.getOptional("user") + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messages") + @ExcludeMissing + fun _messages(): JsonField> = messages + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caching") @ExcludeMissing fun _caching(): JsonField = caching + + /** + * Returns the raw JSON value of [contextWindowFallbackDict]. + * + * Unlike [contextWindowFallbackDict], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context_window_fallback_dict") + @ExcludeMissing + fun _contextWindowFallbackDict(): JsonField = + contextWindowFallbackDict + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fallbacks") + @ExcludeMissing + fun _fallbacks(): JsonField> = fallbacks + + /** + * Returns the raw JSON value of [frequencyPenalty]. + * + * Unlike [frequencyPenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency_penalty") + @ExcludeMissing + fun _frequencyPenalty(): JsonField = frequencyPenalty + + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall(): JsonField = functionCall + + /** + * Returns the raw JSON value of [functions]. + * + * Unlike [functions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("functions") + @ExcludeMissing + fun _functions(): JsonField> = functions + + /** + * Returns the raw JSON value of [guardrails]. + * + * Unlike [guardrails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("guardrails") + @ExcludeMissing + fun _guardrails(): JsonField> = guardrails + + /** + * Returns the raw JSON value of [logitBias]. + * + * Unlike [logitBias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logit_bias") + @ExcludeMissing + fun _logitBias(): JsonField = logitBias + + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField = logprobs + + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [n]. + * + * Unlike [n], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_retries") @ExcludeMissing fun _numRetries(): JsonField = numRetries + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + fun _parallelToolCalls(): JsonField = parallelToolCalls + + /** + * Returns the raw JSON value of [presencePenalty]. + * + * Unlike [presencePenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("presence_penalty") + @ExcludeMissing + fun _presencePenalty(): JsonField = presencePenalty + + /** + * Returns the raw JSON value of [responseFormat]. + * + * Unlike [responseFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("response_format") + @ExcludeMissing + fun _responseFormat(): JsonField = responseFormat + + /** + * Returns the raw JSON value of [seed]. + * + * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seed") @ExcludeMissing fun _seed(): JsonField = seed + + /** + * Returns the raw JSON value of [serviceTier]. + * + * Unlike [serviceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("service_tier") + @ExcludeMissing + fun _serviceTier(): JsonField = serviceTier + + /** + * Returns the raw JSON value of [stop]. + * + * Unlike [stop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField = stop + + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + + /** + * Returns the raw JSON value of [streamOptions]. + * + * Unlike [streamOptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stream_options") + @ExcludeMissing + fun _streamOptions(): JsonField = streamOptions + + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tool_choice") + @ExcludeMissing + fun _toolChoice(): JsonField = toolChoice + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField> = tools + + /** + * Returns the raw JSON value of [topLogprobs]. + * + * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_logprobs") + @ExcludeMissing + fun _topLogprobs(): JsonField = topLogprobs + + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonField = user + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .messages() + * .model() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var messages: JsonField>? = null + private var model: JsonField? = null + private var caching: JsonField = JsonMissing.of() + private var contextWindowFallbackDict: JsonField = + JsonMissing.of() + private var fallbacks: JsonField>? = null + private var frequencyPenalty: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var functions: JsonField>? = null + private var guardrails: JsonField>? = null + private var logitBias: JsonField = JsonMissing.of() + private var logprobs: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var n: JsonField = JsonMissing.of() + private var numRetries: JsonField = JsonMissing.of() + private var parallelToolCalls: JsonField = JsonMissing.of() + private var presencePenalty: JsonField = JsonMissing.of() + private var responseFormat: JsonField = JsonMissing.of() + private var seed: JsonField = JsonMissing.of() + private var serviceTier: JsonField = JsonMissing.of() + private var stop: JsonField = JsonMissing.of() + private var stream: JsonField = JsonMissing.of() + private var streamOptions: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var toolChoice: JsonField = JsonMissing.of() + private var tools: JsonField>? = null + private var topLogprobs: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var user: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + messages = body.messages.map { it.toMutableList() } + model = body.model + caching = body.caching + contextWindowFallbackDict = body.contextWindowFallbackDict + fallbacks = body.fallbacks.map { it.toMutableList() } + frequencyPenalty = body.frequencyPenalty + functionCall = body.functionCall + functions = body.functions.map { it.toMutableList() } + guardrails = body.guardrails.map { it.toMutableList() } + logitBias = body.logitBias + logprobs = body.logprobs + maxTokens = body.maxTokens + metadata = body.metadata + n = body.n + numRetries = body.numRetries + parallelToolCalls = body.parallelToolCalls + presencePenalty = body.presencePenalty + responseFormat = body.responseFormat + seed = body.seed + serviceTier = body.serviceTier + stop = body.stop + stream = body.stream + streamOptions = body.streamOptions + temperature = body.temperature + toolChoice = body.toolChoice + tools = body.tools.map { it.toMutableList() } + topLogprobs = body.topLogprobs + topP = body.topP + user = body.user + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun messages(messages: List) = messages(JsonField.of(messages)) + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField>) = apply { + this.messages = messages.map { it.toMutableList() } + } + + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) + } + } + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionUser(chatCompletionUser)`. + */ + fun addMessage(chatCompletionUser: Message.ChatCompletionUserMessage) = + addMessage(Message.ofChatCompletionUser(chatCompletionUser)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionAssistant(chatCompletionAssistant)`. + */ + fun addMessage(chatCompletionAssistant: Message.ChatCompletionAssistantMessage) = + addMessage(Message.ofChatCompletionAssistant(chatCompletionAssistant)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionTool(chatCompletionTool)`. + */ + fun addMessage(chatCompletionTool: Message.ChatCompletionToolMessage) = + addMessage(Message.ofChatCompletionTool(chatCompletionTool)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionSystem(chatCompletionSystem)`. + */ + fun addMessage(chatCompletionSystem: Message.ChatCompletionSystemMessage) = + addMessage(Message.ofChatCompletionSystem(chatCompletionSystem)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionFunction(chatCompletionFunction)`. + */ + fun addMessage(chatCompletionFunction: Message.ChatCompletionFunctionMessage) = + addMessage(Message.ofChatCompletionFunction(chatCompletionFunction)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionDeveloper(chatCompletionDeveloper)`. + */ + fun addMessage(chatCompletionDeveloper: Message.ChatCompletionDeveloperMessage) = + addMessage(Message.ofChatCompletionDeveloper(chatCompletionDeveloper)) + + fun model(model: String) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + fun caching(caching: Boolean?) = caching(JsonField.ofNullable(caching)) + + /** + * Alias for [Builder.caching]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun caching(caching: Boolean) = caching(caching as Boolean?) + + /** Alias for calling [Builder.caching] with `caching.orElse(null)`. */ + fun caching(caching: Optional) = caching(caching.getOrNull()) + + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caching(caching: JsonField) = apply { this.caching = caching } + + fun contextWindowFallbackDict(contextWindowFallbackDict: ContextWindowFallbackDict?) = + contextWindowFallbackDict(JsonField.ofNullable(contextWindowFallbackDict)) + + /** + * Alias for calling [Builder.contextWindowFallbackDict] with + * `contextWindowFallbackDict.orElse(null)`. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: Optional + ) = contextWindowFallbackDict(contextWindowFallbackDict.getOrNull()) + + /** + * Sets [Builder.contextWindowFallbackDict] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbackDict] with a well-typed + * [ContextWindowFallbackDict] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: JsonField + ) = apply { this.contextWindowFallbackDict = contextWindowFallbackDict } + + fun fallbacks(fallbacks: List?) = fallbacks(JsonField.ofNullable(fallbacks)) + + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) + + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { + this.fallbacks = fallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: String) = apply { + fallbacks = + (fallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("fallbacks", it).add(fallback) + } + } + + fun frequencyPenalty(frequencyPenalty: Double?) = + frequencyPenalty(JsonField.ofNullable(frequencyPenalty)) + + /** + * Alias for [Builder.frequencyPenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(frequencyPenalty as Double?) + + /** + * Alias for calling [Builder.frequencyPenalty] with `frequencyPenalty.orElse(null)`. + */ + fun frequencyPenalty(frequencyPenalty: Optional) = + frequencyPenalty(frequencyPenalty.getOrNull()) + + /** + * Sets [Builder.frequencyPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.frequencyPenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + this.frequencyPenalty = frequencyPenalty + } + + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) + + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) + + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + /** Alias for calling [functionCall] with `FunctionCall.ofString(string)`. */ + fun functionCall(string: String) = functionCall(FunctionCall.ofString(string)) + + /** + * Alias for calling [functionCall] with `FunctionCall.ofUnionMember1(unionMember1)`. + */ + fun functionCall(unionMember1: FunctionCall.UnionMember1) = + functionCall(FunctionCall.ofUnionMember1(unionMember1)) + + fun functions(functions: List?) = functions(JsonField.ofNullable(functions)) + + /** Alias for calling [Builder.functions] with `functions.orElse(null)`. */ + fun functions(functions: Optional>) = functions(functions.getOrNull()) + + /** + * Sets [Builder.functions] to an arbitrary JSON value. + * + * You should usually call [Builder.functions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun functions(functions: JsonField>) = apply { + this.functions = functions.map { it.toMutableList() } + } + + /** + * Adds a single [Function] to [functions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFunction(function: Function) = apply { + functions = + (functions ?: JsonField.of(mutableListOf())).also { + checkKnown("functions", it).add(function) + } + } + + fun guardrails(guardrails: List?) = guardrails(JsonField.ofNullable(guardrails)) + + /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */ + fun guardrails(guardrails: Optional>) = guardrails(guardrails.getOrNull()) + + /** + * Sets [Builder.guardrails] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun guardrails(guardrails: JsonField>) = apply { + this.guardrails = guardrails.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [guardrails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGuardrail(guardrail: String) = apply { + guardrails = + (guardrails ?: JsonField.of(mutableListOf())).also { + checkKnown("guardrails", it).add(guardrail) + } + } + + fun logitBias(logitBias: LogitBias?) = logitBias(JsonField.ofNullable(logitBias)) + + /** Alias for calling [Builder.logitBias] with `logitBias.orElse(null)`. */ + fun logitBias(logitBias: Optional) = logitBias(logitBias.getOrNull()) + + /** + * Sets [Builder.logitBias] to an arbitrary JSON value. + * + * You should usually call [Builder.logitBias] with a well-typed [LogitBias] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logitBias(logitBias: JsonField) = apply { this.logitBias = logitBias } + + fun logprobs(logprobs: Boolean?) = logprobs(JsonField.ofNullable(logprobs)) + + /** + * Alias for [Builder.logprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun logprobs(logprobs: Boolean) = logprobs(logprobs as Boolean?) + + /** Alias for calling [Builder.logprobs] with `logprobs.orElse(null)`. */ + fun logprobs(logprobs: Optional) = logprobs(logprobs.getOrNull()) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logprobs(logprobs: JsonField) = apply { this.logprobs = logprobs } + + fun maxTokens(maxTokens: Long?) = maxTokens(JsonField.ofNullable(maxTokens)) + + /** + * Alias for [Builder.maxTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxTokens(maxTokens: Long) = maxTokens(maxTokens as Long?) + + /** Alias for calling [Builder.maxTokens] with `maxTokens.orElse(null)`. */ + fun maxTokens(maxTokens: Optional) = maxTokens(maxTokens.getOrNull()) + + /** + * Sets [Builder.maxTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun n(n: Long?) = n(JsonField.ofNullable(n)) + + /** + * Alias for [Builder.n]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun n(n: Long) = n(n as Long?) + + /** Alias for calling [Builder.n] with `n.orElse(null)`. */ + fun n(n: Optional) = n(n.getOrNull()) + + /** + * Sets [Builder.n] to an arbitrary JSON value. + * + * You should usually call [Builder.n] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun n(n: JsonField) = apply { this.n = n } + + fun numRetries(numRetries: Long?) = numRetries(JsonField.ofNullable(numRetries)) + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numRetries(numRetries: JsonField) = apply { this.numRetries = numRetries } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = + parallelToolCalls(JsonField.ofNullable(parallelToolCalls)) + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** + * Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. + */ + fun parallelToolCalls(parallelToolCalls: Optional) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField) = apply { + this.parallelToolCalls = parallelToolCalls + } + + fun presencePenalty(presencePenalty: Double?) = + presencePenalty(JsonField.ofNullable(presencePenalty)) + + /** + * Alias for [Builder.presencePenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun presencePenalty(presencePenalty: Double) = + presencePenalty(presencePenalty as Double?) + + /** Alias for calling [Builder.presencePenalty] with `presencePenalty.orElse(null)`. */ + fun presencePenalty(presencePenalty: Optional) = + presencePenalty(presencePenalty.getOrNull()) + + /** + * Sets [Builder.presencePenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.presencePenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun presencePenalty(presencePenalty: JsonField) = apply { + this.presencePenalty = presencePenalty + } + + fun responseFormat(responseFormat: ResponseFormat?) = + responseFormat(JsonField.ofNullable(responseFormat)) + + /** Alias for calling [Builder.responseFormat] with `responseFormat.orElse(null)`. */ + fun responseFormat(responseFormat: Optional) = + responseFormat(responseFormat.getOrNull()) + + /** + * Sets [Builder.responseFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.responseFormat] with a well-typed [ResponseFormat] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun responseFormat(responseFormat: JsonField) = apply { + this.responseFormat = responseFormat + } + + fun seed(seed: Long?) = seed(JsonField.ofNullable(seed)) + + /** + * Alias for [Builder.seed]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun seed(seed: Long) = seed(seed as Long?) + + /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ + fun seed(seed: Optional) = seed(seed.getOrNull()) + + /** + * Sets [Builder.seed] to an arbitrary JSON value. + * + * You should usually call [Builder.seed] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun seed(seed: JsonField) = apply { this.seed = seed } + + fun serviceTier(serviceTier: String?) = serviceTier(JsonField.ofNullable(serviceTier)) + + /** Alias for calling [Builder.serviceTier] with `serviceTier.orElse(null)`. */ + fun serviceTier(serviceTier: Optional) = serviceTier(serviceTier.getOrNull()) + + /** + * Sets [Builder.serviceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceTier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serviceTier(serviceTier: JsonField) = apply { + this.serviceTier = serviceTier + } + + fun stop(stop: Stop?) = stop(JsonField.ofNullable(stop)) + + /** Alias for calling [Builder.stop] with `stop.orElse(null)`. */ + fun stop(stop: Optional) = stop(stop.getOrNull()) + + /** + * Sets [Builder.stop] to an arbitrary JSON value. + * + * You should usually call [Builder.stop] with a well-typed [Stop] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun stop(stop: JsonField) = apply { this.stop = stop } + + /** Alias for calling [stop] with `Stop.ofString(string)`. */ + fun stop(string: String) = stop(Stop.ofString(string)) + + /** Alias for calling [stop] with `Stop.ofStrings(strings)`. */ + fun stopOfStrings(strings: List) = stop(Stop.ofStrings(strings)) + + fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) + + /** + * Alias for [Builder.stream]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun stream(stream: Boolean) = stream(stream as Boolean?) + + /** Alias for calling [Builder.stream] with `stream.orElse(null)`. */ + fun stream(stream: Optional) = stream(stream.getOrNull()) + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stream(stream: JsonField) = apply { this.stream = stream } + + fun streamOptions(streamOptions: StreamOptions?) = + streamOptions(JsonField.ofNullable(streamOptions)) + + /** Alias for calling [Builder.streamOptions] with `streamOptions.orElse(null)`. */ + fun streamOptions(streamOptions: Optional) = + streamOptions(streamOptions.getOrNull()) + + /** + * Sets [Builder.streamOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.streamOptions] with a well-typed [StreamOptions] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun streamOptions(streamOptions: JsonField) = apply { + this.streamOptions = streamOptions + } + + fun temperature(temperature: Double?) = temperature(JsonField.ofNullable(temperature)) + + /** + * Alias for [Builder.temperature]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun temperature(temperature: Double) = temperature(temperature as Double?) + + /** Alias for calling [Builder.temperature] with `temperature.orElse(null)`. */ + fun temperature(temperature: Optional) = temperature(temperature.getOrNull()) + + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + fun toolChoice(toolChoice: ToolChoice?) = toolChoice(JsonField.ofNullable(toolChoice)) + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [ToolChoice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolChoice(toolChoice: JsonField) = apply { + this.toolChoice = toolChoice + } + + /** Alias for calling [toolChoice] with `ToolChoice.ofString(string)`. */ + fun toolChoice(string: String) = toolChoice(ToolChoice.ofString(string)) + + /** Alias for calling [toolChoice] with `ToolChoice.ofUnionMember1(unionMember1)`. */ + fun toolChoice(unionMember1: ToolChoice.UnionMember1) = + toolChoice(ToolChoice.ofUnionMember1(unionMember1)) + + fun tools(tools: List?) = tools(JsonField.ofNullable(tools)) + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tools(tools: JsonField>) = apply { + this.tools = tools.map { it.toMutableList() } + } + + /** + * Adds a single [Tool] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: Tool) = apply { + tools = + (tools ?: JsonField.of(mutableListOf())).also { + checkKnown("tools", it).add(tool) + } + } + + fun topLogprobs(topLogprobs: Long?) = topLogprobs(JsonField.ofNullable(topLogprobs)) + + /** + * Alias for [Builder.topLogprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topLogprobs(topLogprobs: Long) = topLogprobs(topLogprobs as Long?) + + /** Alias for calling [Builder.topLogprobs] with `topLogprobs.orElse(null)`. */ + fun topLogprobs(topLogprobs: Optional) = topLogprobs(topLogprobs.getOrNull()) + + /** + * Sets [Builder.topLogprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.topLogprobs] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topLogprobs(topLogprobs: JsonField) = apply { this.topLogprobs = topLogprobs } + + fun topP(topP: Double?) = topP(JsonField.ofNullable(topP)) + + /** + * Alias for [Builder.topP]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topP(topP: Double) = topP(topP as Double?) + + /** Alias for calling [Builder.topP] with `topP.orElse(null)`. */ + fun topP(topP: Optional) = topP(topP.getOrNull()) + + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topP(topP: JsonField) = apply { this.topP = topP } + + fun user(user: String?) = user(JsonField.ofNullable(user)) + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun user(user: JsonField) = apply { this.user = user } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .model() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("messages", messages).map { it.toImmutable() }, + checkRequired("model", model), + caching, + contextWindowFallbackDict, + (fallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + frequencyPenalty, + functionCall, + (functions ?: JsonMissing.of()).map { it.toImmutable() }, + (guardrails ?: JsonMissing.of()).map { it.toImmutable() }, + logitBias, + logprobs, + maxTokens, + metadata, + n, + numRetries, + parallelToolCalls, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop, + stream, + streamOptions, + temperature, + toolChoice, + (tools ?: JsonMissing.of()).map { it.toImmutable() }, + topLogprobs, + topP, + user, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + messages().forEach { it.validate() } + model() + caching() + contextWindowFallbackDict().ifPresent { it.validate() } + fallbacks() + frequencyPenalty() + functionCall().ifPresent { it.validate() } + functions().ifPresent { it.forEach { it.validate() } } + guardrails() + logitBias().ifPresent { it.validate() } + logprobs() + maxTokens() + metadata().ifPresent { it.validate() } + n() + numRetries() + parallelToolCalls() + presencePenalty() + responseFormat().ifPresent { it.validate() } + seed() + serviceTier() + stop().ifPresent { it.validate() } + stream() + streamOptions().ifPresent { it.validate() } + temperature() + toolChoice().ifPresent { it.validate() } + tools().ifPresent { it.forEach { it.validate() } } + topLogprobs() + topP() + user() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (messages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (caching.asKnown().isPresent) 1 else 0) + + (contextWindowFallbackDict.asKnown().getOrNull()?.validity() ?: 0) + + (fallbacks.asKnown().getOrNull()?.size ?: 0) + + (if (frequencyPenalty.asKnown().isPresent) 1 else 0) + + (functionCall.asKnown().getOrNull()?.validity() ?: 0) + + (functions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (guardrails.asKnown().getOrNull()?.size ?: 0) + + (logitBias.asKnown().getOrNull()?.validity() ?: 0) + + (if (logprobs.asKnown().isPresent) 1 else 0) + + (if (maxTokens.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (n.asKnown().isPresent) 1 else 0) + + (if (numRetries.asKnown().isPresent) 1 else 0) + + (if (parallelToolCalls.asKnown().isPresent) 1 else 0) + + (if (presencePenalty.asKnown().isPresent) 1 else 0) + + (responseFormat.asKnown().getOrNull()?.validity() ?: 0) + + (if (seed.asKnown().isPresent) 1 else 0) + + (if (serviceTier.asKnown().isPresent) 1 else 0) + + (stop.asKnown().getOrNull()?.validity() ?: 0) + + (if (stream.asKnown().isPresent) 1 else 0) + + (streamOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (temperature.asKnown().isPresent) 1 else 0) + + (toolChoice.asKnown().getOrNull()?.validity() ?: 0) + + (tools.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (topLogprobs.asKnown().isPresent) 1 else 0) + + (if (topP.asKnown().isPresent) 1 else 0) + + (if (user.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + messages == other.messages && + model == other.model && + caching == other.caching && + contextWindowFallbackDict == other.contextWindowFallbackDict && + fallbacks == other.fallbacks && + frequencyPenalty == other.frequencyPenalty && + functionCall == other.functionCall && + functions == other.functions && + guardrails == other.guardrails && + logitBias == other.logitBias && + logprobs == other.logprobs && + maxTokens == other.maxTokens && + metadata == other.metadata && + n == other.n && + numRetries == other.numRetries && + parallelToolCalls == other.parallelToolCalls && + presencePenalty == other.presencePenalty && + responseFormat == other.responseFormat && + seed == other.seed && + serviceTier == other.serviceTier && + stop == other.stop && + stream == other.stream && + streamOptions == other.streamOptions && + temperature == other.temperature && + toolChoice == other.toolChoice && + tools == other.tools && + topLogprobs == other.topLogprobs && + topP == other.topP && + user == other.user && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + messages, + model, + caching, + contextWindowFallbackDict, + fallbacks, + frequencyPenalty, + functionCall, + functions, + guardrails, + logitBias, + logprobs, + maxTokens, + metadata, + n, + numRetries, + parallelToolCalls, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop, + stream, + streamOptions, + temperature, + toolChoice, + tools, + topLogprobs, + topP, + user, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{messages=$messages, model=$model, caching=$caching, contextWindowFallbackDict=$contextWindowFallbackDict, fallbacks=$fallbacks, frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, functions=$functions, guardrails=$guardrails, logitBias=$logitBias, logprobs=$logprobs, maxTokens=$maxTokens, metadata=$metadata, n=$n, numRetries=$numRetries, parallelToolCalls=$parallelToolCalls, presencePenalty=$presencePenalty, responseFormat=$responseFormat, seed=$seed, serviceTier=$serviceTier, stop=$stop, stream=$stream, streamOptions=$streamOptions, temperature=$temperature, toolChoice=$toolChoice, tools=$tools, topLogprobs=$topLogprobs, topP=$topP, user=$user, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + class Message + private constructor( + private val chatCompletionUser: ChatCompletionUserMessage? = null, + private val chatCompletionAssistant: ChatCompletionAssistantMessage? = null, + private val chatCompletionTool: ChatCompletionToolMessage? = null, + private val chatCompletionSystem: ChatCompletionSystemMessage? = null, + private val chatCompletionFunction: ChatCompletionFunctionMessage? = null, + private val chatCompletionDeveloper: ChatCompletionDeveloperMessage? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletionUser(): Optional = + Optional.ofNullable(chatCompletionUser) + + fun chatCompletionAssistant(): Optional = + Optional.ofNullable(chatCompletionAssistant) + + fun chatCompletionTool(): Optional = + Optional.ofNullable(chatCompletionTool) + + fun chatCompletionSystem(): Optional = + Optional.ofNullable(chatCompletionSystem) + + fun chatCompletionFunction(): Optional = + Optional.ofNullable(chatCompletionFunction) + + fun chatCompletionDeveloper(): Optional = + Optional.ofNullable(chatCompletionDeveloper) + + fun isChatCompletionUser(): Boolean = chatCompletionUser != null + + fun isChatCompletionAssistant(): Boolean = chatCompletionAssistant != null + + fun isChatCompletionTool(): Boolean = chatCompletionTool != null + + fun isChatCompletionSystem(): Boolean = chatCompletionSystem != null + + fun isChatCompletionFunction(): Boolean = chatCompletionFunction != null + + fun isChatCompletionDeveloper(): Boolean = chatCompletionDeveloper != null + + fun asChatCompletionUser(): ChatCompletionUserMessage = + chatCompletionUser.getOrThrow("chatCompletionUser") + + fun asChatCompletionAssistant(): ChatCompletionAssistantMessage = + chatCompletionAssistant.getOrThrow("chatCompletionAssistant") + + fun asChatCompletionTool(): ChatCompletionToolMessage = + chatCompletionTool.getOrThrow("chatCompletionTool") + + fun asChatCompletionSystem(): ChatCompletionSystemMessage = + chatCompletionSystem.getOrThrow("chatCompletionSystem") + + fun asChatCompletionFunction(): ChatCompletionFunctionMessage = + chatCompletionFunction.getOrThrow("chatCompletionFunction") + + fun asChatCompletionDeveloper(): ChatCompletionDeveloperMessage = + chatCompletionDeveloper.getOrThrow("chatCompletionDeveloper") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletionUser != null -> visitor.visitChatCompletionUser(chatCompletionUser) + chatCompletionAssistant != null -> + visitor.visitChatCompletionAssistant(chatCompletionAssistant) + chatCompletionTool != null -> visitor.visitChatCompletionTool(chatCompletionTool) + chatCompletionSystem != null -> + visitor.visitChatCompletionSystem(chatCompletionSystem) + chatCompletionFunction != null -> + visitor.visitChatCompletionFunction(chatCompletionFunction) + chatCompletionDeveloper != null -> + visitor.visitChatCompletionDeveloper(chatCompletionDeveloper) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletionUser( + chatCompletionUser: ChatCompletionUserMessage + ) { + chatCompletionUser.validate() + } + + override fun visitChatCompletionAssistant( + chatCompletionAssistant: ChatCompletionAssistantMessage + ) { + chatCompletionAssistant.validate() + } + + override fun visitChatCompletionTool( + chatCompletionTool: ChatCompletionToolMessage + ) { + chatCompletionTool.validate() + } + + override fun visitChatCompletionSystem( + chatCompletionSystem: ChatCompletionSystemMessage + ) { + chatCompletionSystem.validate() + } + + override fun visitChatCompletionFunction( + chatCompletionFunction: ChatCompletionFunctionMessage + ) { + chatCompletionFunction.validate() + } + + override fun visitChatCompletionDeveloper( + chatCompletionDeveloper: ChatCompletionDeveloperMessage + ) { + chatCompletionDeveloper.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletionUser( + chatCompletionUser: ChatCompletionUserMessage + ) = chatCompletionUser.validity() + + override fun visitChatCompletionAssistant( + chatCompletionAssistant: ChatCompletionAssistantMessage + ) = chatCompletionAssistant.validity() + + override fun visitChatCompletionTool( + chatCompletionTool: ChatCompletionToolMessage + ) = chatCompletionTool.validity() + + override fun visitChatCompletionSystem( + chatCompletionSystem: ChatCompletionSystemMessage + ) = chatCompletionSystem.validity() + + override fun visitChatCompletionFunction( + chatCompletionFunction: ChatCompletionFunctionMessage + ) = chatCompletionFunction.validity() + + override fun visitChatCompletionDeveloper( + chatCompletionDeveloper: ChatCompletionDeveloperMessage + ) = chatCompletionDeveloper.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Message && + chatCompletionUser == other.chatCompletionUser && + chatCompletionAssistant == other.chatCompletionAssistant && + chatCompletionTool == other.chatCompletionTool && + chatCompletionSystem == other.chatCompletionSystem && + chatCompletionFunction == other.chatCompletionFunction && + chatCompletionDeveloper == other.chatCompletionDeveloper + } + + override fun hashCode(): Int = + Objects.hash( + chatCompletionUser, + chatCompletionAssistant, + chatCompletionTool, + chatCompletionSystem, + chatCompletionFunction, + chatCompletionDeveloper, + ) + + override fun toString(): String = + when { + chatCompletionUser != null -> "Message{chatCompletionUser=$chatCompletionUser}" + chatCompletionAssistant != null -> + "Message{chatCompletionAssistant=$chatCompletionAssistant}" + chatCompletionTool != null -> "Message{chatCompletionTool=$chatCompletionTool}" + chatCompletionSystem != null -> + "Message{chatCompletionSystem=$chatCompletionSystem}" + chatCompletionFunction != null -> + "Message{chatCompletionFunction=$chatCompletionFunction}" + chatCompletionDeveloper != null -> + "Message{chatCompletionDeveloper=$chatCompletionDeveloper}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + + companion object { + + @JvmStatic + fun ofChatCompletionUser(chatCompletionUser: ChatCompletionUserMessage) = + Message(chatCompletionUser = chatCompletionUser) + + @JvmStatic + fun ofChatCompletionAssistant(chatCompletionAssistant: ChatCompletionAssistantMessage) = + Message(chatCompletionAssistant = chatCompletionAssistant) + + @JvmStatic + fun ofChatCompletionTool(chatCompletionTool: ChatCompletionToolMessage) = + Message(chatCompletionTool = chatCompletionTool) + + @JvmStatic + fun ofChatCompletionSystem(chatCompletionSystem: ChatCompletionSystemMessage) = + Message(chatCompletionSystem = chatCompletionSystem) + + @JvmStatic + fun ofChatCompletionFunction(chatCompletionFunction: ChatCompletionFunctionMessage) = + Message(chatCompletionFunction = chatCompletionFunction) + + @JvmStatic + fun ofChatCompletionDeveloper(chatCompletionDeveloper: ChatCompletionDeveloperMessage) = + Message(chatCompletionDeveloper = chatCompletionDeveloper) + } + + /** + * An interface that defines how to map each variant of [Message] to a value of type [T]. + */ + interface Visitor { + + fun visitChatCompletionUser(chatCompletionUser: ChatCompletionUserMessage): T + + fun visitChatCompletionAssistant( + chatCompletionAssistant: ChatCompletionAssistantMessage + ): T + + fun visitChatCompletionTool(chatCompletionTool: ChatCompletionToolMessage): T + + fun visitChatCompletionSystem(chatCompletionSystem: ChatCompletionSystemMessage): T + + fun visitChatCompletionFunction( + chatCompletionFunction: ChatCompletionFunctionMessage + ): T + + fun visitChatCompletionDeveloper( + chatCompletionDeveloper: ChatCompletionDeveloperMessage + ): T + + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Message: $json") + } + } + + internal class Deserializer : BaseDeserializer(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Message(chatCompletionUser = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionAssistant = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Message(chatCompletionTool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionSystem = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionFunction = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionDeveloper = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Message(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletionUser != null -> + generator.writeObject(value.chatCompletionUser) + value.chatCompletionAssistant != null -> + generator.writeObject(value.chatCompletionAssistant) + value.chatCompletionTool != null -> + generator.writeObject(value.chatCompletionTool) + value.chatCompletionSystem != null -> + generator.writeObject(value.chatCompletionSystem) + value.chatCompletionFunction != null -> + generator.writeObject(value.chatCompletionFunction) + value.chatCompletionDeveloper != null -> + generator.writeObject(value.chatCompletionDeveloper) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + class ChatCompletionUserMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(content, role, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("user") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionUserMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionUserMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("user") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionUserMessage: ChatCompletionUserMessage) = apply { + content = chatCompletionUserMessage.content + role = chatCompletionUserMessage.role + cacheControl = chatCompletionUserMessage.cacheControl + additionalProperties = + chatCompletionUserMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = + content( + Content.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + ) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("user") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionUserMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionUserMessage = + ChatCompletionUserMessage( + checkRequired("content", content), + role, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionUserMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("user")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("user")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent4s: List? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent4s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent4s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent4s(): Boolean = + unnamedSchemaWithArrayParent4s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent4s(): List = + unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent4s != null -> + visitor.visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) { + unnamedSchemaWithArrayParent4s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = unnamedSchemaWithArrayParent4s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent4s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent4s != null -> + "Content{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = + Content( + unnamedSchemaWithArrayParent4s = + unnamedSchemaWithArrayParent4s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent4s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent4s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent4s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) + class UnnamedSchemaWithArrayParent4 + private constructor( + private val chatCompletionTextObject: ChatCompletionTextObject? = null, + private val chatCompletionImageObject: ChatCompletionImageObject? = null, + private val chatCompletionAudioObject: ChatCompletionAudioObject? = null, + private val chatCompletionDocumentObject: ChatCompletionDocumentObject? = null, + private val chatCompletionVideoObject: ChatCompletionVideoObject? = null, + private val chatCompletionFileObject: ChatCompletionFileObject? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletionTextObject(): Optional = + Optional.ofNullable(chatCompletionTextObject) + + fun chatCompletionImageObject(): Optional = + Optional.ofNullable(chatCompletionImageObject) + + fun chatCompletionAudioObject(): Optional = + Optional.ofNullable(chatCompletionAudioObject) + + fun chatCompletionDocumentObject(): Optional = + Optional.ofNullable(chatCompletionDocumentObject) + + fun chatCompletionVideoObject(): Optional = + Optional.ofNullable(chatCompletionVideoObject) + + fun chatCompletionFileObject(): Optional = + Optional.ofNullable(chatCompletionFileObject) + + fun isChatCompletionTextObject(): Boolean = chatCompletionTextObject != null + + fun isChatCompletionImageObject(): Boolean = chatCompletionImageObject != null + + fun isChatCompletionAudioObject(): Boolean = chatCompletionAudioObject != null + + fun isChatCompletionDocumentObject(): Boolean = + chatCompletionDocumentObject != null + + fun isChatCompletionVideoObject(): Boolean = chatCompletionVideoObject != null + + fun isChatCompletionFileObject(): Boolean = chatCompletionFileObject != null + + fun asChatCompletionTextObject(): ChatCompletionTextObject = + chatCompletionTextObject.getOrThrow("chatCompletionTextObject") + + fun asChatCompletionImageObject(): ChatCompletionImageObject = + chatCompletionImageObject.getOrThrow("chatCompletionImageObject") + + fun asChatCompletionAudioObject(): ChatCompletionAudioObject = + chatCompletionAudioObject.getOrThrow("chatCompletionAudioObject") + + fun asChatCompletionDocumentObject(): ChatCompletionDocumentObject = + chatCompletionDocumentObject.getOrThrow("chatCompletionDocumentObject") + + fun asChatCompletionVideoObject(): ChatCompletionVideoObject = + chatCompletionVideoObject.getOrThrow("chatCompletionVideoObject") + + fun asChatCompletionFileObject(): ChatCompletionFileObject = + chatCompletionFileObject.getOrThrow("chatCompletionFileObject") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletionTextObject != null -> + visitor.visitChatCompletionTextObject(chatCompletionTextObject) + chatCompletionImageObject != null -> + visitor.visitChatCompletionImageObject(chatCompletionImageObject) + chatCompletionAudioObject != null -> + visitor.visitChatCompletionAudioObject(chatCompletionAudioObject) + chatCompletionDocumentObject != null -> + visitor.visitChatCompletionDocumentObject( + chatCompletionDocumentObject + ) + chatCompletionVideoObject != null -> + visitor.visitChatCompletionVideoObject(chatCompletionVideoObject) + chatCompletionFileObject != null -> + visitor.visitChatCompletionFileObject(chatCompletionFileObject) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent4 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) { + chatCompletionTextObject.validate() + } + + override fun visitChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ) { + chatCompletionImageObject.validate() + } + + override fun visitChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ) { + chatCompletionAudioObject.validate() + } + + override fun visitChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) { + chatCompletionDocumentObject.validate() + } + + override fun visitChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ) { + chatCompletionVideoObject.validate() + } + + override fun visitChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ) { + chatCompletionFileObject.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = chatCompletionTextObject.validity() + + override fun visitChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ) = chatCompletionImageObject.validity() + + override fun visitChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ) = chatCompletionAudioObject.validity() + + override fun visitChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) = chatCompletionDocumentObject.validity() + + override fun visitChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ) = chatCompletionVideoObject.validity() + + override fun visitChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ) = chatCompletionFileObject.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent4 && + chatCompletionTextObject == other.chatCompletionTextObject && + chatCompletionImageObject == other.chatCompletionImageObject && + chatCompletionAudioObject == other.chatCompletionAudioObject && + chatCompletionDocumentObject == other.chatCompletionDocumentObject && + chatCompletionVideoObject == other.chatCompletionVideoObject && + chatCompletionFileObject == other.chatCompletionFileObject + } + + override fun hashCode(): Int = + Objects.hash( + chatCompletionTextObject, + chatCompletionImageObject, + chatCompletionAudioObject, + chatCompletionDocumentObject, + chatCompletionVideoObject, + chatCompletionFileObject, + ) + + override fun toString(): String = + when { + chatCompletionTextObject != null -> + "UnnamedSchemaWithArrayParent4{chatCompletionTextObject=$chatCompletionTextObject}" + chatCompletionImageObject != null -> + "UnnamedSchemaWithArrayParent4{chatCompletionImageObject=$chatCompletionImageObject}" + chatCompletionAudioObject != null -> + "UnnamedSchemaWithArrayParent4{chatCompletionAudioObject=$chatCompletionAudioObject}" + chatCompletionDocumentObject != null -> + "UnnamedSchemaWithArrayParent4{chatCompletionDocumentObject=$chatCompletionDocumentObject}" + chatCompletionVideoObject != null -> + "UnnamedSchemaWithArrayParent4{chatCompletionVideoObject=$chatCompletionVideoObject}" + chatCompletionFileObject != null -> + "UnnamedSchemaWithArrayParent4{chatCompletionFileObject=$chatCompletionFileObject}" + _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") + } + + companion object { + + @JvmStatic + fun ofChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = + UnnamedSchemaWithArrayParent4( + chatCompletionTextObject = chatCompletionTextObject + ) + + @JvmStatic + fun ofChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ) = + UnnamedSchemaWithArrayParent4( + chatCompletionImageObject = chatCompletionImageObject + ) + + @JvmStatic + fun ofChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ) = + UnnamedSchemaWithArrayParent4( + chatCompletionAudioObject = chatCompletionAudioObject + ) + + @JvmStatic + fun ofChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) = + UnnamedSchemaWithArrayParent4( + chatCompletionDocumentObject = chatCompletionDocumentObject + ) + + @JvmStatic + fun ofChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ) = + UnnamedSchemaWithArrayParent4( + chatCompletionVideoObject = chatCompletionVideoObject + ) + + @JvmStatic + fun ofChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ) = + UnnamedSchemaWithArrayParent4( + chatCompletionFileObject = chatCompletionFileObject + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + */ + interface Visitor { + + fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ): T + + fun visitChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ): T + + fun visitChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ): T + + fun visitChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ): T + + fun visitChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ): T + + fun visitChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent4: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent4 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + chatCompletionTextObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + chatCompletionImageObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + chatCompletionAudioObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + chatCompletionDocumentObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + chatCompletionVideoObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + chatCompletionFileObject = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from boolean). + 0 -> UnnamedSchemaWithArrayParent4(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent4, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletionTextObject != null -> + generator.writeObject(value.chatCompletionTextObject) + value.chatCompletionImageObject != null -> + generator.writeObject(value.chatCompletionImageObject) + value.chatCompletionAudioObject != null -> + generator.writeObject(value.chatCompletionAudioObject) + value.chatCompletionDocumentObject != null -> + generator.writeObject(value.chatCompletionDocumentObject) + value.chatCompletionVideoObject != null -> + generator.writeObject(value.chatCompletionVideoObject) + value.chatCompletionFileObject != null -> + generator.writeObject(value.chatCompletionFileObject) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent4" + ) + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if + * the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionImageObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(imageUrl, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("image_url") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionImageObject]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionImageObject]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("image_url") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionImageObject: ChatCompletionImageObject + ) = apply { + imageUrl = chatCompletionImageObject.imageUrl + type = chatCompletionImageObject.type + additionalProperties = + chatCompletionImageObject.additionalProperties.toMutableMap() + } + + fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed + * [ImageUrl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** Alias for calling [imageUrl] with `ImageUrl.ofString(string)`. */ + fun imageUrl(string: String) = imageUrl(ImageUrl.ofString(string)) + + /** + * Alias for calling [imageUrl] with + * `ImageUrl.ofChatCompletionImageUrlObject(chatCompletionImageUrlObject)`. + */ + fun imageUrl( + chatCompletionImageUrlObject: ImageUrl.ChatCompletionImageUrlObject + ) = + imageUrl( + ImageUrl.ofChatCompletionImageUrlObject( + chatCompletionImageUrlObject + ) + ) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("image_url") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionImageObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionImageObject = + ChatCompletionImageObject( + checkRequired("imageUrl", imageUrl), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionImageObject = apply { + if (validated) { + return@apply + } + + imageUrl().validate() + _type().let { + if (it != JsonValue.from("image_url")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (imageUrl.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("image_url")) 1 else 0 } + + @JsonDeserialize(using = ImageUrl.Deserializer::class) + @JsonSerialize(using = ImageUrl.Serializer::class) + class ImageUrl + private constructor( + private val string: String? = null, + private val chatCompletionImageUrlObject: + ChatCompletionImageUrlObject? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionImageUrlObject(): + Optional = + Optional.ofNullable(chatCompletionImageUrlObject) + + fun isString(): Boolean = string != null + + fun isChatCompletionImageUrlObject(): Boolean = + chatCompletionImageUrlObject != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionImageUrlObject(): ChatCompletionImageUrlObject = + chatCompletionImageUrlObject.getOrThrow( + "chatCompletionImageUrlObject" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionImageUrlObject != null -> + visitor.visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ImageUrl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject: + ChatCompletionImageUrlObject + ) { + chatCompletionImageUrlObject.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject: + ChatCompletionImageUrlObject + ) = chatCompletionImageUrlObject.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ImageUrl && + string == other.string && + chatCompletionImageUrlObject == + other.chatCompletionImageUrlObject + } + + override fun hashCode(): Int = + Objects.hash(string, chatCompletionImageUrlObject) + + override fun toString(): String = + when { + string != null -> "ImageUrl{string=$string}" + chatCompletionImageUrlObject != null -> + "ImageUrl{chatCompletionImageUrlObject=$chatCompletionImageUrlObject}" + _json != null -> "ImageUrl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ImageUrl") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ImageUrl(string = string) + + @JvmStatic + fun ofChatCompletionImageUrlObject( + chatCompletionImageUrlObject: ChatCompletionImageUrlObject + ) = + ImageUrl( + chatCompletionImageUrlObject = chatCompletionImageUrlObject + ) + } + + /** + * An interface that defines how to map each variant of [ImageUrl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject: ChatCompletionImageUrlObject + ): T + + /** + * Maps an unknown variant of [ImageUrl] to a value of type [T]. + * + * An instance of [ImageUrl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown ImageUrl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ImageUrl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ImageUrl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef< + ChatCompletionImageUrlObject + >(), + ) + ?.let { + ImageUrl( + chatCompletionImageUrlObject = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ImageUrl(string = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> ImageUrl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ImageUrl::class) { + + override fun serialize( + value: ImageUrl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionImageUrlObject != null -> + generator.writeObject( + value.chatCompletionImageUrlObject + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ImageUrl") + } + } + } + + class ChatCompletionImageUrlObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val format: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") + @ExcludeMissing + url: JsonField = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + ) : this(url, detail, format, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("format") + @ExcludeMissing + fun _format(): JsonField = format + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionImageUrlObject]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionImageUrlObject]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var detail: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionImageUrlObject: ChatCompletionImageUrlObject + ) = apply { + url = chatCompletionImageUrlObject.url + detail = chatCompletionImageUrlObject.detail + format = chatCompletionImageUrlObject.format + additionalProperties = + chatCompletionImageUrlObject.additionalProperties + .toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun format(format: String) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { + this.format = format + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [ChatCompletionImageUrlObject]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionImageUrlObject = + ChatCompletionImageUrlObject( + checkRequired("url", url), + detail, + format, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionImageUrlObject = apply { + if (validated) { + return@apply + } + + url() + detail() + format() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (if (detail.asKnown().isPresent) 1 else 0) + + (if (format.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionImageUrlObject && + url == other.url && + detail == other.detail && + format == other.format && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, detail, format, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionImageUrlObject{url=$url, detail=$detail, format=$format, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionImageObject && + imageUrl == other.imageUrl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionImageObject{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + } + + class ChatCompletionAudioObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val inputAudio: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("input_audio") + @ExcludeMissing + inputAudio: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(inputAudio, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun inputAudio(): InputAudio = inputAudio.getRequired("input_audio") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("input_audio") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [inputAudio]. + * + * Unlike [inputAudio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_audio") + @ExcludeMissing + fun _inputAudio(): JsonField = inputAudio + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionAudioObject]. + * + * The following fields are required: + * ```java + * .inputAudio() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionAudioObject]. */ + class Builder internal constructor() { + + private var inputAudio: JsonField? = null + private var type: JsonValue = JsonValue.from("input_audio") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionAudioObject: ChatCompletionAudioObject + ) = apply { + inputAudio = chatCompletionAudioObject.inputAudio + type = chatCompletionAudioObject.type + additionalProperties = + chatCompletionAudioObject.additionalProperties.toMutableMap() + } + + fun inputAudio(inputAudio: InputAudio) = + inputAudio(JsonField.of(inputAudio)) + + /** + * Sets [Builder.inputAudio] to an arbitrary JSON value. + * + * You should usually call [Builder.inputAudio] with a well-typed + * [InputAudio] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun inputAudio(inputAudio: JsonField) = apply { + this.inputAudio = inputAudio + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("input_audio") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionAudioObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .inputAudio() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionAudioObject = + ChatCompletionAudioObject( + checkRequired("inputAudio", inputAudio), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionAudioObject = apply { + if (validated) { + return@apply + } + + inputAudio().validate() + _type().let { + if (it != JsonValue.from("input_audio")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (inputAudio.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("input_audio")) 1 else 0 } + + class InputAudio + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val format: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + ) : this(data, format, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun data(): String = data.getRequired("data") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun format(): Format = format.getRequired("format") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("format") + @ExcludeMissing + fun _format(): JsonField = format + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InputAudio]. + * + * The following fields are required: + * ```java + * .data() + * .format() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputAudio]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var format: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(inputAudio: InputAudio) = apply { + data = inputAudio.data + format = inputAudio.format + additionalProperties = + inputAudio.additionalProperties.toMutableMap() + } + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed + * [Format] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { + this.format = format + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InputAudio]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .data() + * .format() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InputAudio = + InputAudio( + checkRequired("data", data), + checkRequired("format", format), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InputAudio = apply { + if (validated) { + return@apply + } + + data() + format().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (data.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + class Format + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized + * from data that doesn't match any known member, and you want to + * know that value. For example, if the SDK is on an older version + * than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val WAV = of("wav") + + @JvmField val MP3 = of("mp3") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + WAV, + MP3, + } + + /** + * An enum containing [Format]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known + * member. For example, if the SDK is on an older version than the + * API, then the API may respond with new members that the SDK is + * unaware of. + * - It was constructed with an arbitrary value using the [of] + * method. + */ + enum class Value { + WAV, + MP3, + /** + * An enum member indicating that [Format] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's + * value, or [Value._UNKNOWN] if the class was instantiated with an + * unknown value. + * + * Use the [known] method instead if you're certain the value is + * always known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + WAV -> Value.WAV + MP3 -> Value.MP3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's + * value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + WAV -> Known.WAV + MP3 -> Known.MP3 + else -> + throw HanzoInvalidDataException( + "Unknown Format: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputAudio && + data == other.data && + format == other.format && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, format, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputAudio{data=$data, format=$format, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionAudioObject && + inputAudio == other.inputAudio && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inputAudio, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionAudioObject{inputAudio=$inputAudio, type=$type, additionalProperties=$additionalProperties}" + } + + class ChatCompletionDocumentObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val citations: JsonField, + private val context: JsonField, + private val source: JsonField, + private val title: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("citations") + @ExcludeMissing + citations: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("title") + @ExcludeMissing + title: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(citations, context, source, title, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun citations(): Optional = citations.getOptional("citations") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun context(): String = context.getRequired("context") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun source(): Source = source.getRequired("source") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("document") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [citations]. + * + * Unlike [citations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("citations") + @ExcludeMissing + fun _citations(): JsonField = citations + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("title") + @ExcludeMissing + fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionDocumentObject]. + * + * The following fields are required: + * ```java + * .citations() + * .context() + * .source() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionDocumentObject]. */ + class Builder internal constructor() { + + private var citations: JsonField? = null + private var context: JsonField? = null + private var source: JsonField? = null + private var title: JsonField? = null + private var type: JsonValue = JsonValue.from("document") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) = apply { + citations = chatCompletionDocumentObject.citations + context = chatCompletionDocumentObject.context + source = chatCompletionDocumentObject.source + title = chatCompletionDocumentObject.title + type = chatCompletionDocumentObject.type + additionalProperties = + chatCompletionDocumentObject.additionalProperties.toMutableMap() + } + + fun citations(citations: Citations?) = + citations(JsonField.ofNullable(citations)) + + /** + * Alias for calling [Builder.citations] with `citations.orElse(null)`. + */ + fun citations(citations: Optional) = + citations(citations.getOrNull()) + + /** + * Sets [Builder.citations] to an arbitrary JSON value. + * + * You should usually call [Builder.citations] with a well-typed + * [Citations] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun citations(citations: JsonField) = apply { + this.citations = citations + } + + fun context(context: String) = context(JsonField.of(context)) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun context(context: JsonField) = apply { + this.context = context + } + + fun source(source: Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("document") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionDocumentObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .citations() + * .context() + * .source() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionDocumentObject = + ChatCompletionDocumentObject( + checkRequired("citations", citations), + checkRequired("context", context), + checkRequired("source", source), + checkRequired("title", title), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionDocumentObject = apply { + if (validated) { + return@apply + } + + citations().ifPresent { it.validate() } + context() + source().validate() + title() + _type().let { + if (it != JsonValue.from("document")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (citations.asKnown().getOrNull()?.validity() ?: 0) + + (if (context.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("document")) 1 else 0 } + + class Citations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") + @ExcludeMissing + enabled: JsonField = JsonMissing.of() + ) : this(enabled, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun enabled(): Boolean = enabled.getRequired("enabled") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enabled") + @ExcludeMissing + fun _enabled(): JsonField = enabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Citations]. + * + * The following fields are required: + * ```java + * .enabled() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Citations]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(citations: Citations) = apply { + enabled = citations.enabled + additionalProperties = + citations.additionalProperties.toMutableMap() + } + + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun enabled(enabled: JsonField) = apply { + this.enabled = enabled + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Citations]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .enabled() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Citations = + Citations( + checkRequired("enabled", enabled), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Citations = apply { + if (validated) { + return@apply + } + + enabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (enabled.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Citations && + enabled == other.enabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(enabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Citations{enabled=$enabled, additionalProperties=$additionalProperties}" + } + + class Source + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val mediaType: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("media_type") + @ExcludeMissing + mediaType: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(data, mediaType, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun data(): String = data.getRequired("data") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun mediaType(): String = mediaType.getRequired("media_type") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if + * the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [mediaType]. + * + * Unlike [mediaType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("media_type") + @ExcludeMissing + fun _mediaType(): JsonField = mediaType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Source]. + * + * The following fields are required: + * ```java + * .data() + * .mediaType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Source]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var mediaType: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(source: Source) = apply { + data = source.data + mediaType = source.mediaType + type = source.type + additionalProperties = + source.additionalProperties.toMutableMap() + } + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun mediaType(mediaType: String) = + mediaType(JsonField.of(mediaType)) + + /** + * Sets [Builder.mediaType] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaType] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun mediaType(mediaType: JsonField) = apply { + this.mediaType = mediaType + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Source]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .data() + * .mediaType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Source = + Source( + checkRequired("data", data), + checkRequired("mediaType", mediaType), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + data() + mediaType() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (data.asKnown().isPresent) 1 else 0) + + (if (mediaType.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Source && + data == other.data && + mediaType == other.mediaType && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, mediaType, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Source{data=$data, mediaType=$mediaType, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionDocumentObject && + citations == other.citations && + context == other.context && + source == other.source && + title == other.title && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + citations, + context, + source, + title, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionDocumentObject{citations=$citations, context=$context, source=$source, title=$title, type=$type, additionalProperties=$additionalProperties}" + } + + class ChatCompletionVideoObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val videoUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("video_url") + @ExcludeMissing + videoUrl: JsonField = JsonMissing.of(), + ) : this(type, videoUrl, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("video_url") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun videoUrl(): VideoUrl = videoUrl.getRequired("video_url") + + /** + * Returns the raw JSON value of [videoUrl]. + * + * Unlike [videoUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("video_url") + @ExcludeMissing + fun _videoUrl(): JsonField = videoUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionVideoObject]. + * + * The following fields are required: + * ```java + * .videoUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionVideoObject]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("video_url") + private var videoUrl: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionVideoObject: ChatCompletionVideoObject + ) = apply { + type = chatCompletionVideoObject.type + videoUrl = chatCompletionVideoObject.videoUrl + additionalProperties = + chatCompletionVideoObject.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("video_url") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun videoUrl(videoUrl: VideoUrl) = videoUrl(JsonField.of(videoUrl)) + + /** + * Sets [Builder.videoUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.videoUrl] with a well-typed + * [VideoUrl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun videoUrl(videoUrl: JsonField) = apply { + this.videoUrl = videoUrl + } + + /** Alias for calling [videoUrl] with `VideoUrl.ofString(string)`. */ + fun videoUrl(string: String) = videoUrl(VideoUrl.ofString(string)) + + /** + * Alias for calling [videoUrl] with + * `VideoUrl.ofChatCompletionVideoUrlObject(chatCompletionVideoUrlObject)`. + */ + fun videoUrl( + chatCompletionVideoUrlObject: VideoUrl.ChatCompletionVideoUrlObject + ) = + videoUrl( + VideoUrl.ofChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject + ) + ) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionVideoObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .videoUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionVideoObject = + ChatCompletionVideoObject( + type, + checkRequired("videoUrl", videoUrl), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionVideoObject = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("video_url")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + videoUrl().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("video_url")) 1 else 0 } + + (videoUrl.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = VideoUrl.Deserializer::class) + @JsonSerialize(using = VideoUrl.Serializer::class) + class VideoUrl + private constructor( + private val string: String? = null, + private val chatCompletionVideoUrlObject: + ChatCompletionVideoUrlObject? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionVideoUrlObject(): + Optional = + Optional.ofNullable(chatCompletionVideoUrlObject) + + fun isString(): Boolean = string != null + + fun isChatCompletionVideoUrlObject(): Boolean = + chatCompletionVideoUrlObject != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionVideoUrlObject(): ChatCompletionVideoUrlObject = + chatCompletionVideoUrlObject.getOrThrow( + "chatCompletionVideoUrlObject" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionVideoUrlObject != null -> + visitor.visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): VideoUrl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: + ChatCompletionVideoUrlObject + ) { + chatCompletionVideoUrlObject.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: + ChatCompletionVideoUrlObject + ) = chatCompletionVideoUrlObject.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoUrl && + string == other.string && + chatCompletionVideoUrlObject == + other.chatCompletionVideoUrlObject + } + + override fun hashCode(): Int = + Objects.hash(string, chatCompletionVideoUrlObject) + + override fun toString(): String = + when { + string != null -> "VideoUrl{string=$string}" + chatCompletionVideoUrlObject != null -> + "VideoUrl{chatCompletionVideoUrlObject=$chatCompletionVideoUrlObject}" + _json != null -> "VideoUrl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid VideoUrl") + } + + companion object { + + @JvmStatic fun ofString(string: String) = VideoUrl(string = string) + + @JvmStatic + fun ofChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: ChatCompletionVideoUrlObject + ) = + VideoUrl( + chatCompletionVideoUrlObject = chatCompletionVideoUrlObject + ) + } + + /** + * An interface that defines how to map each variant of [VideoUrl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: ChatCompletionVideoUrlObject + ): T + + /** + * Maps an unknown variant of [VideoUrl] to a value of type [T]. + * + * An instance of [VideoUrl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown VideoUrl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(VideoUrl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): VideoUrl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef< + ChatCompletionVideoUrlObject + >(), + ) + ?.let { + VideoUrl( + chatCompletionVideoUrlObject = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { VideoUrl(string = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> VideoUrl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(VideoUrl::class) { + + override fun serialize( + value: VideoUrl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionVideoUrlObject != null -> + generator.writeObject( + value.chatCompletionVideoUrlObject + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid VideoUrl") + } + } + } + + class ChatCompletionVideoUrlObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") + @ExcludeMissing + url: JsonField = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(url, detail, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionVideoUrlObject]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionVideoUrlObject]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionVideoUrlObject: ChatCompletionVideoUrlObject + ) = apply { + url = chatCompletionVideoUrlObject.url + detail = chatCompletionVideoUrlObject.detail + additionalProperties = + chatCompletionVideoUrlObject.additionalProperties + .toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [ChatCompletionVideoUrlObject]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionVideoUrlObject = + ChatCompletionVideoUrlObject( + checkRequired("url", url), + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionVideoUrlObject = apply { + if (validated) { + return@apply + } + + url() + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionVideoUrlObject && + url == other.url && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionVideoUrlObject{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionVideoObject && + type == other.type && + videoUrl == other.videoUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, videoUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionVideoObject{type=$type, videoUrl=$videoUrl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionFileObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val file: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file") + @ExcludeMissing + file: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(file, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun file(): File = file.getRequired("file") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("file") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [file]. + * + * Unlike [file], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): JsonField = file + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionFileObject]. + * + * The following fields are required: + * ```java + * .file() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionFileObject]. */ + class Builder internal constructor() { + + private var file: JsonField? = null + private var type: JsonValue = JsonValue.from("file") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionFileObject: ChatCompletionFileObject) = + apply { + file = chatCompletionFileObject.file + type = chatCompletionFileObject.type + additionalProperties = + chatCompletionFileObject.additionalProperties.toMutableMap() + } + + fun file(file: File) = file(JsonField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary JSON value. + * + * You should usually call [Builder.file] with a well-typed [File] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun file(file: JsonField) = apply { this.file = file } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("file") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionFileObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .file() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionFileObject = + ChatCompletionFileObject( + checkRequired("file", file), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionFileObject = apply { + if (validated) { + return@apply + } + + file().validate() + _type().let { + if (it != JsonValue.from("file")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (file.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("file")) 1 else 0 } + + class File + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileData: JsonField, + private val fileId: JsonField, + private val filename: JsonField, + private val format: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_data") + @ExcludeMissing + fileData: JsonField = JsonMissing.of(), + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + ) : this(fileData, fileId, filename, format, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun fileData(): Optional = fileData.getOptional("file_data") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("file_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun filename(): Optional = filename.getOptional("filename") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Returns the raw JSON value of [fileData]. + * + * Unlike [fileData], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("file_data") + @ExcludeMissing + fun _fileData(): JsonField = fileData + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("file_id") + @ExcludeMissing + fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filename") + @ExcludeMissing + fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("format") + @ExcludeMissing + fun _format(): JsonField = format + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [File]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [File]. */ + class Builder internal constructor() { + + private var fileData: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filename: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(file: File) = apply { + fileData = file.fileData + fileId = file.fileId + filename = file.filename + format = file.format + additionalProperties = file.additionalProperties.toMutableMap() + } + + fun fileData(fileData: String) = fileData(JsonField.of(fileData)) + + /** + * Sets [Builder.fileData] to an arbitrary JSON value. + * + * You should usually call [Builder.fileData] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun fileData(fileData: JsonField) = apply { + this.fileData = fileData + } + + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { + this.fileId = fileId + } + + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filename(filename: JsonField) = apply { + this.filename = filename + } + + fun format(format: String) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { + this.format = format + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [File]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): File = + File( + fileData, + fileId, + filename, + format, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): File = apply { + if (validated) { + return@apply + } + + fileData() + fileId() + filename() + format() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileData.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (format.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is File && + fileData == other.fileData && + fileId == other.fileId && + filename == other.filename && + format == other.format && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + fileData, + fileId, + filename, + format, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "File{fileData=$fileData, fileId=$fileId, filename=$filename, format=$format, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionFileObject && + file == other.file && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(file, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionFileObject{file=$file, type=$type, additionalProperties=$additionalProperties}" + } + } + } + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionUserMessage && + content == other.content && + role == other.role && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionUserMessage{content=$content, role=$role, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionAssistantMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val role: JsonValue, + private val cacheControl: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val reasoningContent: JsonField, + private val thinkingBlocks: JsonField>, + private val toolCalls: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_content") + @ExcludeMissing + reasoningContent: JsonField = JsonMissing.of(), + @JsonProperty("thinking_blocks") + @ExcludeMissing + thinkingBlocks: JsonField> = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + toolCalls: JsonField> = JsonMissing.of(), + ) : this( + role, + cacheControl, + content, + functionCall, + name, + reasoningContent, + thinkingBlocks, + toolCalls, + mutableMapOf(), + ) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("assistant") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun functionCall(): Optional = functionCall.getOptional("function_call") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reasoningContent(): Optional = + reasoningContent.getOptional("reasoning_content") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thinkingBlocks(): Optional> = + thinkingBlocks.getOptional("thinking_blocks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolCalls(): Optional> = toolCalls.getOptional("tool_calls") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall(): JsonField = functionCall + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [reasoningContent]. + * + * Unlike [reasoningContent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reasoning_content") + @ExcludeMissing + fun _reasoningContent(): JsonField = reasoningContent + + /** + * Returns the raw JSON value of [thinkingBlocks]. + * + * Unlike [thinkingBlocks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thinking_blocks") + @ExcludeMissing + fun _thinkingBlocks(): JsonField> = thinkingBlocks + + /** + * Returns the raw JSON value of [toolCalls]. + * + * Unlike [toolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls(): JsonField> = toolCalls + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionAssistantMessage]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionAssistantMessage]. */ + class Builder internal constructor() { + + private var role: JsonValue = JsonValue.from("assistant") + private var cacheControl: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var reasoningContent: JsonField = JsonMissing.of() + private var thinkingBlocks: JsonField>? = null + private var toolCalls: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionAssistantMessage: ChatCompletionAssistantMessage) = + apply { + role = chatCompletionAssistantMessage.role + cacheControl = chatCompletionAssistantMessage.cacheControl + content = chatCompletionAssistantMessage.content + functionCall = chatCompletionAssistantMessage.functionCall + name = chatCompletionAssistantMessage.name + reasoningContent = chatCompletionAssistantMessage.reasoningContent + thinkingBlocks = + chatCompletionAssistantMessage.thinkingBlocks.map { it.toMutableList() } + toolCalls = + chatCompletionAssistantMessage.toolCalls.map { it.toMutableList() } + additionalProperties = + chatCompletionAssistantMessage.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("assistant") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun content(content: Content?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List + ) = + content( + Content.ofUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s) + ) + + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) + + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) + + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun reasoningContent(reasoningContent: String?) = + reasoningContent(JsonField.ofNullable(reasoningContent)) + + /** + * Alias for calling [Builder.reasoningContent] with + * `reasoningContent.orElse(null)`. + */ + fun reasoningContent(reasoningContent: Optional) = + reasoningContent(reasoningContent.getOrNull()) + + /** + * Sets [Builder.reasoningContent] to an arbitrary JSON value. + * + * You should usually call [Builder.reasoningContent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun reasoningContent(reasoningContent: JsonField) = apply { + this.reasoningContent = reasoningContent + } + + fun thinkingBlocks(thinkingBlocks: List?) = + thinkingBlocks(JsonField.ofNullable(thinkingBlocks)) + + /** + * Alias for calling [Builder.thinkingBlocks] with `thinkingBlocks.orElse(null)`. + */ + fun thinkingBlocks(thinkingBlocks: Optional>) = + thinkingBlocks(thinkingBlocks.getOrNull()) + + /** + * Sets [Builder.thinkingBlocks] to an arbitrary JSON value. + * + * You should usually call [Builder.thinkingBlocks] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thinkingBlocks(thinkingBlocks: JsonField>) = apply { + this.thinkingBlocks = thinkingBlocks.map { it.toMutableList() } + } + + /** + * Adds a single [ThinkingBlock] to [thinkingBlocks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThinkingBlock(thinkingBlock: ThinkingBlock) = apply { + thinkingBlocks = + (thinkingBlocks ?: JsonField.of(mutableListOf())).also { + checkKnown("thinkingBlocks", it).add(thinkingBlock) + } + } + + /** + * Alias for calling [addThinkingBlock] with + * `ThinkingBlock.ofChatCompletion(chatCompletion)`. + */ + fun addThinkingBlock(chatCompletion: ThinkingBlock.ChatCompletionThinkingBlock) = + addThinkingBlock(ThinkingBlock.ofChatCompletion(chatCompletion)) + + /** + * Alias for calling [addThinkingBlock] with + * `ThinkingBlock.ofChatCompletionRedacted(chatCompletionRedacted)`. + */ + fun addThinkingBlock( + chatCompletionRedacted: ThinkingBlock.ChatCompletionRedactedThinkingBlock + ) = addThinkingBlock(ThinkingBlock.ofChatCompletionRedacted(chatCompletionRedacted)) + + fun toolCalls(toolCalls: List?) = + toolCalls(JsonField.ofNullable(toolCalls)) + + /** Alias for calling [Builder.toolCalls] with `toolCalls.orElse(null)`. */ + fun toolCalls(toolCalls: Optional>) = + toolCalls(toolCalls.getOrNull()) + + /** + * Sets [Builder.toolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCalls] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun toolCalls(toolCalls: JsonField>) = apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [ToolCall] to [toolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addToolCall(toolCall: ToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCalls", it).add(toolCall) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionAssistantMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChatCompletionAssistantMessage = + ChatCompletionAssistantMessage( + role, + cacheControl, + content, + functionCall, + name, + reasoningContent, + (thinkingBlocks ?: JsonMissing.of()).map { it.toImmutable() }, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionAssistantMessage = apply { + if (validated) { + return@apply + } + + _role().let { + if (it != JsonValue.from("assistant")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + content().ifPresent { it.validate() } + functionCall().ifPresent { it.validate() } + name() + reasoningContent() + thinkingBlocks().ifPresent { it.forEach { it.validate() } } + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + role.let { if (it == JsonValue.from("assistant")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + (functionCall.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (reasoningContent.asKnown().isPresent) 1 else 0) + + (thinkingBlocks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (toolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent5s: List? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent5s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent5s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent5s(): Boolean = + unnamedSchemaWithArrayParent5s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent5s(): List = + unnamedSchemaWithArrayParent5s.getOrThrow("unnamedSchemaWithArrayParent5s") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent5s != null -> + visitor.visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List + ) { + unnamedSchemaWithArrayParent5s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List + ) = unnamedSchemaWithArrayParent5s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent5s == other.unnamedSchemaWithArrayParent5s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent5s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent5s != null -> + "Content{unnamedSchemaWithArrayParent5s=$unnamedSchemaWithArrayParent5s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List + ) = + Content( + unnamedSchemaWithArrayParent5s = + unnamedSchemaWithArrayParent5s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent5s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent5s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent5s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent5.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent5.Serializer::class) + class UnnamedSchemaWithArrayParent5 + private constructor( + private val chatCompletionTextObject: ChatCompletionTextObject? = null, + private val chatCompletionThinkingBlock: ChatCompletionThinkingBlock? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletionTextObject(): Optional = + Optional.ofNullable(chatCompletionTextObject) + + fun chatCompletionThinkingBlock(): Optional = + Optional.ofNullable(chatCompletionThinkingBlock) + + fun isChatCompletionTextObject(): Boolean = chatCompletionTextObject != null + + fun isChatCompletionThinkingBlock(): Boolean = + chatCompletionThinkingBlock != null + + fun asChatCompletionTextObject(): ChatCompletionTextObject = + chatCompletionTextObject.getOrThrow("chatCompletionTextObject") + + fun asChatCompletionThinkingBlock(): ChatCompletionThinkingBlock = + chatCompletionThinkingBlock.getOrThrow("chatCompletionThinkingBlock") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletionTextObject != null -> + visitor.visitChatCompletionTextObject(chatCompletionTextObject) + chatCompletionThinkingBlock != null -> + visitor.visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent5 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) { + chatCompletionTextObject.validate() + } + + override fun visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) { + chatCompletionThinkingBlock.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = chatCompletionTextObject.validity() + + override fun visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = chatCompletionThinkingBlock.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent5 && + chatCompletionTextObject == other.chatCompletionTextObject && + chatCompletionThinkingBlock == other.chatCompletionThinkingBlock + } + + override fun hashCode(): Int = + Objects.hash(chatCompletionTextObject, chatCompletionThinkingBlock) + + override fun toString(): String = + when { + chatCompletionTextObject != null -> + "UnnamedSchemaWithArrayParent5{chatCompletionTextObject=$chatCompletionTextObject}" + chatCompletionThinkingBlock != null -> + "UnnamedSchemaWithArrayParent5{chatCompletionThinkingBlock=$chatCompletionThinkingBlock}" + _json != null -> "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent5") + } + + companion object { + + @JvmStatic + fun ofChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = + UnnamedSchemaWithArrayParent5( + chatCompletionTextObject = chatCompletionTextObject + ) + + @JvmStatic + fun ofChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = + UnnamedSchemaWithArrayParent5( + chatCompletionThinkingBlock = chatCompletionThinkingBlock + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + */ + interface Visitor { + + fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ): T + + fun visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent5] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent5] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent5 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + chatCompletionTextObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + chatCompletionThinkingBlock = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from boolean). + 0 -> UnnamedSchemaWithArrayParent5(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletionTextObject != null -> + generator.writeObject(value.chatCompletionTextObject) + value.chatCompletionThinkingBlock != null -> + generator.writeObject(value.chatCompletionThinkingBlock) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if + * the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionThinkingBlock + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val cacheControl: JsonField, + private val signature: JsonField, + private val thinking: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("signature") + @ExcludeMissing + signature: JsonField = JsonMissing.of(), + @JsonProperty("thinking") + @ExcludeMissing + thinking: JsonField = JsonMissing.of(), + ) : this(type, cacheControl, signature, thinking, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.getOptional("signature") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun thinking(): Optional = thinking.getOptional("thinking") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [signature]. + * + * Unlike [signature], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): JsonField = signature + + /** + * Returns the raw JSON value of [thinking]. + * + * Unlike [thinking], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thinking") + @ExcludeMissing + fun _thinking(): JsonField = thinking + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionThinkingBlock]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionThinkingBlock]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("thinking") + private var cacheControl: JsonField = JsonMissing.of() + private var signature: JsonField = JsonMissing.of() + private var thinking: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = apply { + type = chatCompletionThinkingBlock.type + cacheControl = chatCompletionThinkingBlock.cacheControl + signature = chatCompletionThinkingBlock.signature + thinking = chatCompletionThinkingBlock.thinking + additionalProperties = + chatCompletionThinkingBlock.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl?) = + cacheControl(JsonField.ofNullable(cacheControl)) + + /** + * Alias for calling [Builder.cacheControl] with + * `cacheControl.orElse(null)`. + */ + fun cacheControl(cacheControl: Optional) = + cacheControl(cacheControl.getOrNull()) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofUnionMember0(unionMember0)`. + */ + fun cacheControl(unionMember0: CacheControl.UnionMember0) = + cacheControl(CacheControl.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofChatCompletionCachedContent()`. + */ + fun cacheControlChatCompletionCachedContent() = + cacheControl(CacheControl.ofChatCompletionCachedContent()) + + fun signature(signature: String) = signature(JsonField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary JSON value. + * + * You should usually call [Builder.signature] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun signature(signature: JsonField) = apply { + this.signature = signature + } + + fun thinking(thinking: String) = thinking(JsonField.of(thinking)) + + /** + * Sets [Builder.thinking] to an arbitrary JSON value. + * + * You should usually call [Builder.thinking] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun thinking(thinking: JsonField) = apply { + this.thinking = thinking + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionThinkingBlock]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): ChatCompletionThinkingBlock = + ChatCompletionThinkingBlock( + type, + cacheControl, + signature, + thinking, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionThinkingBlock = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("thinking")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + cacheControl().ifPresent { it.validate() } + signature() + thinking() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("thinking")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (signature.asKnown().isPresent) 1 else 0) + + (if (thinking.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = CacheControl.Deserializer::class) + @JsonSerialize(using = CacheControl.Serializer::class) + class CacheControl + private constructor( + private val unionMember0: UnionMember0? = null, + private val chatCompletionCachedContent: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun chatCompletionCachedContent(): Optional = + Optional.ofNullable(chatCompletionCachedContent) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isChatCompletionCachedContent(): Boolean = + chatCompletionCachedContent != null + + fun asUnionMember0(): UnionMember0 = + unionMember0.getOrThrow("unionMember0") + + fun asChatCompletionCachedContent(): JsonValue = + chatCompletionCachedContent.getOrThrow( + "chatCompletionCachedContent" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + chatCompletionCachedContent != null -> + visitor.visitChatCompletionCachedContent( + chatCompletionCachedContent + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) { + chatCompletionCachedContent.let { + if ( + it != + JsonValue.from(mapOf("type" to "ephemeral")) + ) { + throw HanzoInvalidDataException( + "'chatCompletionCachedContent' is invalid, received $it" + ) + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) = + chatCompletionCachedContent.let { + if ( + it == + JsonValue.from(mapOf("type" to "ephemeral")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + unionMember0 == other.unionMember0 && + chatCompletionCachedContent == other.chatCompletionCachedContent + } + + override fun hashCode(): Int = + Objects.hash(unionMember0, chatCompletionCachedContent) + + override fun toString(): String = + when { + unionMember0 != null -> + "CacheControl{unionMember0=$unionMember0}" + chatCompletionCachedContent != null -> + "CacheControl{chatCompletionCachedContent=$chatCompletionCachedContent}" + _json != null -> "CacheControl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CacheControl") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + CacheControl(unionMember0 = unionMember0) + + @JvmStatic + fun ofChatCompletionCachedContent() = + CacheControl( + chatCompletionCachedContent = + JsonValue.from(mapOf("type" to "ephemeral")) + ) + } + + /** + * An interface that defines how to map each variant of [CacheControl] + * to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ): T + + /** + * Maps an unknown variant of [CacheControl] to a value of type [T]. + * + * An instance of [CacheControl] can contain an unknown variant if + * it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the + * API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CacheControl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CacheControl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CacheControl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + chatCompletionCachedContent = it, + _json = json, + ) + } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + unionMember0 = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> CacheControl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CacheControl::class) { + + override fun serialize( + value: CacheControl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.chatCompletionCachedContent != null -> + generator.writeObject(value.chatCompletionCachedContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CacheControl") + } + } + } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + */ + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionThinkingBlock && + type == other.type && + cacheControl == other.cacheControl && + signature == other.signature && + thinking == other.thinking && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + type, + cacheControl, + signature, + thinking, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionThinkingBlock{type=$type, cacheControl=$cacheControl, signature=$signature, thinking=$thinking, additionalProperties=$additionalProperties}" + } + } + } + + class FunctionCall + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val providerSpecificFields: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("provider_specific_fields") + @ExcludeMissing + providerSpecificFields: JsonField = JsonMissing.of(), + ) : this(arguments, name, providerSpecificFields, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun arguments(): Optional = arguments.getOptional("arguments") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun providerSpecificFields(): Optional = + providerSpecificFields.getOptional("provider_specific_fields") + + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [providerSpecificFields]. + * + * Unlike [providerSpecificFields], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("provider_specific_fields") + @ExcludeMissing + fun _providerSpecificFields(): JsonField = + providerSpecificFields + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FunctionCall]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FunctionCall]. */ + class Builder internal constructor() { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var providerSpecificFields: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionCall: FunctionCall) = apply { + arguments = functionCall.arguments + name = functionCall.name + providerSpecificFields = functionCall.providerSpecificFields + additionalProperties = functionCall.additionalProperties.toMutableMap() + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun providerSpecificFields(providerSpecificFields: ProviderSpecificFields?) = + providerSpecificFields(JsonField.ofNullable(providerSpecificFields)) + + /** + * Alias for calling [Builder.providerSpecificFields] with + * `providerSpecificFields.orElse(null)`. + */ + fun providerSpecificFields( + providerSpecificFields: Optional + ) = providerSpecificFields(providerSpecificFields.getOrNull()) + + /** + * Sets [Builder.providerSpecificFields] to an arbitrary JSON value. + * + * You should usually call [Builder.providerSpecificFields] with a well-typed + * [ProviderSpecificFields] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun providerSpecificFields( + providerSpecificFields: JsonField + ) = apply { this.providerSpecificFields = providerSpecificFields } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FunctionCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + providerSpecificFields, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FunctionCall = apply { + if (validated) { + return@apply + } + + arguments() + name() + providerSpecificFields().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arguments.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (providerSpecificFields.asKnown().getOrNull()?.validity() ?: 0) + + class ProviderSpecificFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ProviderSpecificFields]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderSpecificFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(providerSpecificFields: ProviderSpecificFields) = apply { + additionalProperties = + providerSpecificFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderSpecificFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProviderSpecificFields = + ProviderSpecificFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ProviderSpecificFields = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderSpecificFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionCall && + arguments == other.arguments && + name == other.name && + providerSpecificFields == other.providerSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(arguments, name, providerSpecificFields, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, providerSpecificFields=$providerSpecificFields, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = ThinkingBlock.Deserializer::class) + @JsonSerialize(using = ThinkingBlock.Serializer::class) + class ThinkingBlock + private constructor( + private val chatCompletion: ChatCompletionThinkingBlock? = null, + private val chatCompletionRedacted: ChatCompletionRedactedThinkingBlock? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletion(): Optional = + Optional.ofNullable(chatCompletion) + + fun chatCompletionRedacted(): Optional = + Optional.ofNullable(chatCompletionRedacted) + + fun isChatCompletion(): Boolean = chatCompletion != null + + fun isChatCompletionRedacted(): Boolean = chatCompletionRedacted != null + + fun asChatCompletion(): ChatCompletionThinkingBlock = + chatCompletion.getOrThrow("chatCompletion") + + fun asChatCompletionRedacted(): ChatCompletionRedactedThinkingBlock = + chatCompletionRedacted.getOrThrow("chatCompletionRedacted") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletion != null -> visitor.visitChatCompletion(chatCompletion) + chatCompletionRedacted != null -> + visitor.visitChatCompletionRedacted(chatCompletionRedacted) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ThinkingBlock = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletion( + chatCompletion: ChatCompletionThinkingBlock + ) { + chatCompletion.validate() + } + + override fun visitChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ) { + chatCompletionRedacted.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletion( + chatCompletion: ChatCompletionThinkingBlock + ) = chatCompletion.validity() + + override fun visitChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ) = chatCompletionRedacted.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThinkingBlock && + chatCompletion == other.chatCompletion && + chatCompletionRedacted == other.chatCompletionRedacted + } + + override fun hashCode(): Int = Objects.hash(chatCompletion, chatCompletionRedacted) + + override fun toString(): String = + when { + chatCompletion != null -> "ThinkingBlock{chatCompletion=$chatCompletion}" + chatCompletionRedacted != null -> + "ThinkingBlock{chatCompletionRedacted=$chatCompletionRedacted}" + _json != null -> "ThinkingBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ThinkingBlock") + } + + companion object { + + @JvmStatic + fun ofChatCompletion(chatCompletion: ChatCompletionThinkingBlock) = + ThinkingBlock(chatCompletion = chatCompletion) + + @JvmStatic + fun ofChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ) = ThinkingBlock(chatCompletionRedacted = chatCompletionRedacted) + } + + /** + * An interface that defines how to map each variant of [ThinkingBlock] to a value + * of type [T]. + */ + interface Visitor { + + fun visitChatCompletion(chatCompletion: ChatCompletionThinkingBlock): T + + fun visitChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ): T + + /** + * Maps an unknown variant of [ThinkingBlock] to a value of type [T]. + * + * An instance of [ThinkingBlock] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown ThinkingBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ThinkingBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ThinkingBlock { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { ThinkingBlock(chatCompletion = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ThinkingBlock(chatCompletionRedacted = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> ThinkingBlock(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ThinkingBlock::class) { + + override fun serialize( + value: ThinkingBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletion != null -> + generator.writeObject(value.chatCompletion) + value.chatCompletionRedacted != null -> + generator.writeObject(value.chatCompletionRedacted) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ThinkingBlock") + } + } + } + + class ChatCompletionThinkingBlock + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val cacheControl: JsonField, + private val signature: JsonField, + private val thinking: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("signature") + @ExcludeMissing + signature: JsonField = JsonMissing.of(), + @JsonProperty("thinking") + @ExcludeMissing + thinking: JsonField = JsonMissing.of(), + ) : this(type, cacheControl, signature, thinking, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.getOptional("signature") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thinking(): Optional = thinking.getOptional("thinking") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [signature]. + * + * Unlike [signature], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): JsonField = signature + + /** + * Returns the raw JSON value of [thinking]. + * + * Unlike [thinking], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thinking") + @ExcludeMissing + fun _thinking(): JsonField = thinking + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionThinkingBlock]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionThinkingBlock]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("thinking") + private var cacheControl: JsonField = JsonMissing.of() + private var signature: JsonField = JsonMissing.of() + private var thinking: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = apply { + type = chatCompletionThinkingBlock.type + cacheControl = chatCompletionThinkingBlock.cacheControl + signature = chatCompletionThinkingBlock.signature + thinking = chatCompletionThinkingBlock.thinking + additionalProperties = + chatCompletionThinkingBlock.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl?) = + cacheControl(JsonField.ofNullable(cacheControl)) + + /** + * Alias for calling [Builder.cacheControl] with + * `cacheControl.orElse(null)`. + */ + fun cacheControl(cacheControl: Optional) = + cacheControl(cacheControl.getOrNull()) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofUnionMember0(unionMember0)`. + */ + fun cacheControl(unionMember0: CacheControl.UnionMember0) = + cacheControl(CacheControl.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofChatCompletionCachedContent()`. + */ + fun cacheControlChatCompletionCachedContent() = + cacheControl(CacheControl.ofChatCompletionCachedContent()) + + fun signature(signature: String) = signature(JsonField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary JSON value. + * + * You should usually call [Builder.signature] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun signature(signature: JsonField) = apply { + this.signature = signature + } + + fun thinking(thinking: String) = thinking(JsonField.of(thinking)) + + /** + * Sets [Builder.thinking] to an arbitrary JSON value. + * + * You should usually call [Builder.thinking] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun thinking(thinking: JsonField) = apply { + this.thinking = thinking + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionThinkingBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChatCompletionThinkingBlock = + ChatCompletionThinkingBlock( + type, + cacheControl, + signature, + thinking, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionThinkingBlock = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("thinking")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + signature() + thinking() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("thinking")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (signature.asKnown().isPresent) 1 else 0) + + (if (thinking.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = CacheControl.Deserializer::class) + @JsonSerialize(using = CacheControl.Serializer::class) + class CacheControl + private constructor( + private val unionMember0: UnionMember0? = null, + private val chatCompletionCachedContent: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun chatCompletionCachedContent(): Optional = + Optional.ofNullable(chatCompletionCachedContent) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isChatCompletionCachedContent(): Boolean = + chatCompletionCachedContent != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asChatCompletionCachedContent(): JsonValue = + chatCompletionCachedContent.getOrThrow("chatCompletionCachedContent") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + chatCompletionCachedContent != null -> + visitor.visitChatCompletionCachedContent( + chatCompletionCachedContent + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) { + chatCompletionCachedContent.let { + if ( + it != JsonValue.from(mapOf("type" to "ephemeral")) + ) { + throw HanzoInvalidDataException( + "'chatCompletionCachedContent' is invalid, received $it" + ) + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) = + chatCompletionCachedContent.let { + if (it == JsonValue.from(mapOf("type" to "ephemeral"))) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + unionMember0 == other.unionMember0 && + chatCompletionCachedContent == other.chatCompletionCachedContent + } + + override fun hashCode(): Int = + Objects.hash(unionMember0, chatCompletionCachedContent) + + override fun toString(): String = + when { + unionMember0 != null -> "CacheControl{unionMember0=$unionMember0}" + chatCompletionCachedContent != null -> + "CacheControl{chatCompletionCachedContent=$chatCompletionCachedContent}" + _json != null -> "CacheControl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CacheControl") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + CacheControl(unionMember0 = unionMember0) + + @JvmStatic + fun ofChatCompletionCachedContent() = + CacheControl( + chatCompletionCachedContent = + JsonValue.from(mapOf("type" to "ephemeral")) + ) + } + + /** + * An interface that defines how to map each variant of [CacheControl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ): T + + /** + * Maps an unknown variant of [CacheControl] to a value of type [T]. + * + * An instance of [CacheControl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CacheControl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CacheControl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CacheControl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + chatCompletionCachedContent = it, + _json = json, + ) + } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl(unionMember0 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> CacheControl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CacheControl::class) { + + override fun serialize( + value: CacheControl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.chatCompletionCachedContent != null -> + generator.writeObject(value.chatCompletionCachedContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CacheControl") + } + } + } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionThinkingBlock && + type == other.type && + cacheControl == other.cacheControl && + signature == other.signature && + thinking == other.thinking && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, cacheControl, signature, thinking, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionThinkingBlock{type=$type, cacheControl=$cacheControl, signature=$signature, thinking=$thinking, additionalProperties=$additionalProperties}" + } + + class ChatCompletionRedactedThinkingBlock + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val cacheControl: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + ) : this(type, cacheControl, data, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("redacted_thinking") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionRedactedThinkingBlock]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionRedactedThinkingBlock]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("redacted_thinking") + private var cacheControl: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionRedactedThinkingBlock: ChatCompletionRedactedThinkingBlock + ) = apply { + type = chatCompletionRedactedThinkingBlock.type + cacheControl = chatCompletionRedactedThinkingBlock.cacheControl + data = chatCompletionRedactedThinkingBlock.data + additionalProperties = + chatCompletionRedactedThinkingBlock.additionalProperties + .toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("redacted_thinking") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl?) = + cacheControl(JsonField.ofNullable(cacheControl)) + + /** + * Alias for calling [Builder.cacheControl] with + * `cacheControl.orElse(null)`. + */ + fun cacheControl(cacheControl: Optional) = + cacheControl(cacheControl.getOrNull()) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofUnionMember0(unionMember0)`. + */ + fun cacheControl(unionMember0: CacheControl.UnionMember0) = + cacheControl(CacheControl.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofChatCompletionCachedContent()`. + */ + fun cacheControlChatCompletionCachedContent() = + cacheControl(CacheControl.ofChatCompletionCachedContent()) + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionRedactedThinkingBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChatCompletionRedactedThinkingBlock = + ChatCompletionRedactedThinkingBlock( + type, + cacheControl, + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionRedactedThinkingBlock = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("redacted_thinking")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + data() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("redacted_thinking")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (data.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = CacheControl.Deserializer::class) + @JsonSerialize(using = CacheControl.Serializer::class) + class CacheControl + private constructor( + private val unionMember0: UnionMember0? = null, + private val chatCompletionCachedContent: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun chatCompletionCachedContent(): Optional = + Optional.ofNullable(chatCompletionCachedContent) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isChatCompletionCachedContent(): Boolean = + chatCompletionCachedContent != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asChatCompletionCachedContent(): JsonValue = + chatCompletionCachedContent.getOrThrow("chatCompletionCachedContent") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + chatCompletionCachedContent != null -> + visitor.visitChatCompletionCachedContent( + chatCompletionCachedContent + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) { + chatCompletionCachedContent.let { + if ( + it != JsonValue.from(mapOf("type" to "ephemeral")) + ) { + throw HanzoInvalidDataException( + "'chatCompletionCachedContent' is invalid, received $it" + ) + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) = + chatCompletionCachedContent.let { + if (it == JsonValue.from(mapOf("type" to "ephemeral"))) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + unionMember0 == other.unionMember0 && + chatCompletionCachedContent == other.chatCompletionCachedContent + } + + override fun hashCode(): Int = + Objects.hash(unionMember0, chatCompletionCachedContent) + + override fun toString(): String = + when { + unionMember0 != null -> "CacheControl{unionMember0=$unionMember0}" + chatCompletionCachedContent != null -> + "CacheControl{chatCompletionCachedContent=$chatCompletionCachedContent}" + _json != null -> "CacheControl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CacheControl") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + CacheControl(unionMember0 = unionMember0) + + @JvmStatic + fun ofChatCompletionCachedContent() = + CacheControl( + chatCompletionCachedContent = + JsonValue.from(mapOf("type" to "ephemeral")) + ) + } + + /** + * An interface that defines how to map each variant of [CacheControl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ): T + + /** + * Maps an unknown variant of [CacheControl] to a value of type [T]. + * + * An instance of [CacheControl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CacheControl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CacheControl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CacheControl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + chatCompletionCachedContent = it, + _json = json, + ) + } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl(unionMember0 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> CacheControl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CacheControl::class) { + + override fun serialize( + value: CacheControl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.chatCompletionCachedContent != null -> + generator.writeObject(value.chatCompletionCachedContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CacheControl") + } + } + } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionRedactedThinkingBlock && + type == other.type && + cacheControl == other.cacheControl && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, cacheControl, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionRedactedThinkingBlock{type=$type, cacheControl=$cacheControl, data=$data, additionalProperties=$additionalProperties}" + } + } + + class ToolCall + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("function") + @ExcludeMissing + function: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, function, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun function(): Function = function.getRequired("function") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("function") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [function]. + * + * Unlike [function], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("function") + @ExcludeMissing + fun _function(): JsonField = function + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ToolCall]. + * + * The following fields are required: + * ```java + * .id() + * .function() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ToolCall]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var function: JsonField? = null + private var type: JsonValue = JsonValue.from("function") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(toolCall: ToolCall) = apply { + id = toolCall.id + function = toolCall.function + type = toolCall.type + additionalProperties = toolCall.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun function(function: Function) = function(JsonField.of(function)) + + /** + * Sets [Builder.function] to an arbitrary JSON value. + * + * You should usually call [Builder.function] with a well-typed [Function] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun function(function: JsonField) = apply { this.function = function } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("function") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ToolCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .function() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ToolCall = + ToolCall( + checkRequired("id", id), + checkRequired("function", function), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ToolCall = apply { + if (validated) { + return@apply + } + + id() + function().validate() + _type().let { + if (it != JsonValue.from("function")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (function.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("function")) 1 else 0 } + + class Function + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val providerSpecificFields: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("provider_specific_fields") + @ExcludeMissing + providerSpecificFields: JsonField = JsonMissing.of(), + ) : this(arguments, name, providerSpecificFields, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun arguments(): Optional = arguments.getOptional("arguments") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun providerSpecificFields(): Optional = + providerSpecificFields.getOptional("provider_specific_fields") + + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [providerSpecificFields]. + * + * Unlike [providerSpecificFields], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("provider_specific_fields") + @ExcludeMissing + fun _providerSpecificFields(): JsonField = + providerSpecificFields + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Function]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Function]. */ + class Builder internal constructor() { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var providerSpecificFields: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + arguments = function.arguments + name = function.name + providerSpecificFields = function.providerSpecificFields + additionalProperties = function.additionalProperties.toMutableMap() + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun providerSpecificFields( + providerSpecificFields: ProviderSpecificFields? + ) = providerSpecificFields(JsonField.ofNullable(providerSpecificFields)) + + /** + * Alias for calling [Builder.providerSpecificFields] with + * `providerSpecificFields.orElse(null)`. + */ + fun providerSpecificFields( + providerSpecificFields: Optional + ) = providerSpecificFields(providerSpecificFields.getOrNull()) + + /** + * Sets [Builder.providerSpecificFields] to an arbitrary JSON value. + * + * You should usually call [Builder.providerSpecificFields] with a + * well-typed [ProviderSpecificFields] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun providerSpecificFields( + providerSpecificFields: JsonField + ) = apply { this.providerSpecificFields = providerSpecificFields } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Function = + Function( + arguments, + name, + providerSpecificFields, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Function = apply { + if (validated) { + return@apply + } + + arguments() + name() + providerSpecificFields().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arguments.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (providerSpecificFields.asKnown().getOrNull()?.validity() ?: 0) + + class ProviderSpecificFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ProviderSpecificFields]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderSpecificFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(providerSpecificFields: ProviderSpecificFields) = + apply { + additionalProperties = + providerSpecificFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderSpecificFields]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): ProviderSpecificFields = + ProviderSpecificFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ProviderSpecificFields = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderSpecificFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Function && + arguments == other.arguments && + name == other.name && + providerSpecificFields == other.providerSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(arguments, name, providerSpecificFields, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Function{arguments=$arguments, name=$name, providerSpecificFields=$providerSpecificFields, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolCall && + id == other.id && + function == other.function && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, function, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionAssistantMessage && + role == other.role && + cacheControl == other.cacheControl && + content == other.content && + functionCall == other.functionCall && + name == other.name && + reasoningContent == other.reasoningContent && + thinkingBlocks == other.thinkingBlocks && + toolCalls == other.toolCalls && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + role, + cacheControl, + content, + functionCall, + name, + reasoningContent, + thinkingBlocks, + toolCalls, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionAssistantMessage{role=$role, cacheControl=$cacheControl, content=$content, functionCall=$functionCall, name=$name, reasoningContent=$reasoningContent, thinkingBlocks=$thinkingBlocks, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + } + + class ChatCompletionToolMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val toolCallId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + toolCallId: JsonField = JsonMissing.of(), + ) : this(content, role, toolCallId, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun toolCallId(): String = toolCallId.getRequired("tool_call_id") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField = toolCallId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionToolMessage]. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionToolMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("tool") + private var toolCallId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionToolMessage: ChatCompletionToolMessage) = apply { + content = chatCompletionToolMessage.content + role = chatCompletionToolMessage.role + toolCallId = chatCompletionToolMessage.toolCallId + additionalProperties = + chatCompletionToolMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofChatCompletionTextObjects(chatCompletionTextObjects)`. + */ + fun contentOfChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = content(Content.ofChatCompletionTextObjects(chatCompletionTextObjects)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionToolMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionToolMessage = + ChatCompletionToolMessage( + checkRequired("content", content), + role, + checkRequired("toolCallId", toolCallId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionToolMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("tool")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + toolCallId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("tool")) 1 else 0 } + + (if (toolCallId.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val chatCompletionTextObjects: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionTextObjects(): Optional> = + Optional.ofNullable(chatCompletionTextObjects) + + fun isString(): Boolean = string != null + + fun isChatCompletionTextObjects(): Boolean = chatCompletionTextObjects != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionTextObjects(): List = + chatCompletionTextObjects.getOrThrow("chatCompletionTextObjects") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionTextObjects != null -> + visitor.visitChatCompletionTextObjects(chatCompletionTextObjects) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) { + chatCompletionTextObjects.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = chatCompletionTextObjects.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + chatCompletionTextObjects == other.chatCompletionTextObjects + } + + override fun hashCode(): Int = Objects.hash(string, chatCompletionTextObjects) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + chatCompletionTextObjects != null -> + "Content{chatCompletionTextObjects=$chatCompletionTextObjects}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = Content(chatCompletionTextObjects = chatCompletionTextObjects.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content(chatCompletionTextObjects = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionTextObjects != null -> + generator.writeObject(value.chatCompletionTextObjects) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionToolMessage && + content == other.content && + role == other.role && + toolCallId == other.toolCallId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, toolCallId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionToolMessage{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + class ChatCompletionSystemMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val cacheControl: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(content, role, cacheControl, name, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("system") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionSystemMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionSystemMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("system") + private var cacheControl: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionSystemMessage: ChatCompletionSystemMessage) = + apply { + content = chatCompletionSystemMessage.content + role = chatCompletionSystemMessage.role + cacheControl = chatCompletionSystemMessage.cacheControl + name = chatCompletionSystemMessage.name + additionalProperties = + chatCompletionSystemMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** Alias for calling [content] with `Content.ofJsonValues(jsonValues)`. */ + fun contentOfJsonValues(jsonValues: List) = + content(Content.ofJsonValues(jsonValues)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("system") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionSystemMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionSystemMessage = + ChatCompletionSystemMessage( + checkRequired("content", content), + role, + cacheControl, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionSystemMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("system")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("system")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) + + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitJsonValues(jsonValues: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = + jsonValues.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + jsonValues == other.jsonValues + } + + override fun hashCode(): Int = Objects.hash(string, jsonValues) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + jsonValues != null -> "Content{jsonValues=$jsonValues}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = + Content(jsonValues = jsonValues.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitJsonValues(jsonValues: List): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Content(jsonValues = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + } + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionSystemMessage && + content == other.content && + role == other.role && + cacheControl == other.cacheControl && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, cacheControl, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionSystemMessage{content=$content, role=$role, cacheControl=$cacheControl, name=$name, additionalProperties=$additionalProperties}" + } + + class ChatCompletionFunctionMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonValue, + private val toolCallId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + toolCallId: JsonField = JsonMissing.of(), + ) : this(content, name, role, toolCallId, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("function") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolCallId(): Optional = toolCallId.getOptional("tool_call_id") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField = toolCallId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionFunctionMessage]. + * + * The following fields are required: + * ```java + * .content() + * .name() + * .toolCallId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionFunctionMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var name: JsonField? = null + private var role: JsonValue = JsonValue.from("function") + private var toolCallId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionFunctionMessage: ChatCompletionFunctionMessage) = + apply { + content = chatCompletionFunctionMessage.content + name = chatCompletionFunctionMessage.name + role = chatCompletionFunctionMessage.role + toolCallId = chatCompletionFunctionMessage.toolCallId + additionalProperties = + chatCompletionFunctionMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofChatCompletionTextObjects(chatCompletionTextObjects)`. + */ + fun contentOfChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = content(Content.ofChatCompletionTextObjects(chatCompletionTextObjects)) + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("function") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun toolCallId(toolCallId: String?) = toolCallId(JsonField.ofNullable(toolCallId)) + + /** Alias for calling [Builder.toolCallId] with `toolCallId.orElse(null)`. */ + fun toolCallId(toolCallId: Optional) = toolCallId(toolCallId.getOrNull()) + + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionFunctionMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .name() + * .toolCallId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionFunctionMessage = + ChatCompletionFunctionMessage( + checkRequired("content", content), + checkRequired("name", name), + role, + checkRequired("toolCallId", toolCallId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionFunctionMessage = apply { + if (validated) { + return@apply + } + + content().ifPresent { it.validate() } + name() + _role().let { + if (it != JsonValue.from("function")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + toolCallId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + role.let { if (it == JsonValue.from("function")) 1 else 0 } + + (if (toolCallId.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val chatCompletionTextObjects: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionTextObjects(): Optional> = + Optional.ofNullable(chatCompletionTextObjects) + + fun isString(): Boolean = string != null + + fun isChatCompletionTextObjects(): Boolean = chatCompletionTextObjects != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionTextObjects(): List = + chatCompletionTextObjects.getOrThrow("chatCompletionTextObjects") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionTextObjects != null -> + visitor.visitChatCompletionTextObjects(chatCompletionTextObjects) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) { + chatCompletionTextObjects.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = chatCompletionTextObjects.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + chatCompletionTextObjects == other.chatCompletionTextObjects + } + + override fun hashCode(): Int = Objects.hash(string, chatCompletionTextObjects) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + chatCompletionTextObjects != null -> + "Content{chatCompletionTextObjects=$chatCompletionTextObjects}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = Content(chatCompletionTextObjects = chatCompletionTextObjects.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content(chatCompletionTextObjects = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionTextObjects != null -> + generator.writeObject(value.chatCompletionTextObjects) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionFunctionMessage && + content == other.content && + name == other.name && + role == other.role && + toolCallId == other.toolCallId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, name, role, toolCallId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionFunctionMessage{content=$content, name=$name, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + class ChatCompletionDeveloperMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val cacheControl: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(content, role, cacheControl, name, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("developer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionDeveloperMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionDeveloperMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("developer") + private var cacheControl: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionDeveloperMessage: ChatCompletionDeveloperMessage) = + apply { + content = chatCompletionDeveloperMessage.content + role = chatCompletionDeveloperMessage.role + cacheControl = chatCompletionDeveloperMessage.cacheControl + name = chatCompletionDeveloperMessage.name + additionalProperties = + chatCompletionDeveloperMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** Alias for calling [content] with `Content.ofJsonValues(jsonValues)`. */ + fun contentOfJsonValues(jsonValues: List) = + content(Content.ofJsonValues(jsonValues)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("developer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionDeveloperMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionDeveloperMessage = + ChatCompletionDeveloperMessage( + checkRequired("content", content), + role, + cacheControl, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionDeveloperMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("developer")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("developer")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) + + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitJsonValues(jsonValues: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = + jsonValues.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + jsonValues == other.jsonValues + } + + override fun hashCode(): Int = Objects.hash(string, jsonValues) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + jsonValues != null -> "Content{jsonValues=$jsonValues}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = + Content(jsonValues = jsonValues.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitJsonValues(jsonValues: List): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Content(jsonValues = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + } + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionDeveloperMessage && + content == other.content && + role == other.role && + cacheControl == other.cacheControl && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, cacheControl, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionDeveloperMessage{content=$content, role=$role, cacheControl=$cacheControl, name=$name, additionalProperties=$additionalProperties}" + } + } + + class ContextWindowFallbackDict + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContextWindowFallbackDict]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContextWindowFallbackDict]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contextWindowFallbackDict: ContextWindowFallbackDict) = apply { + additionalProperties = contextWindowFallbackDict.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContextWindowFallbackDict]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContextWindowFallbackDict = + ContextWindowFallbackDict(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ContextWindowFallbackDict = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContextWindowFallbackDict && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContextWindowFallbackDict{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = FunctionCall.Deserializer::class) + @JsonSerialize(using = FunctionCall.Serializer::class) + class FunctionCall + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): FunctionCall = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionCall && + string == other.string && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "FunctionCall{string=$string}" + unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } + + companion object { + + @JvmStatic fun ofString(string: String) = FunctionCall(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + FunctionCall(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [FunctionCall] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [FunctionCall] to a value of type [T]. + * + * An instance of [FunctionCall] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown FunctionCall: $json") + } + } + + internal class Deserializer : BaseDeserializer(FunctionCall::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + FunctionCall(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + FunctionCall(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> FunctionCall(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(FunctionCall::class) { + + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + class Function + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Function]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Function]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + additionalProperties = function.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Function = Function(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Function = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Function && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Function{additionalProperties=$additionalProperties}" + } + + class LogitBias + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogitBias]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogitBias]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logitBias: LogitBias) = apply { + additionalProperties = logitBias.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogitBias]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogitBias = LogitBias(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LogitBias = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogitBias && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LogitBias{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ResponseFormat + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ResponseFormat]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseFormat]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseFormat: ResponseFormat) = apply { + additionalProperties = responseFormat.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponseFormat]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ResponseFormat = ResponseFormat(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ResponseFormat = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseFormat && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ResponseFormat{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Stop.Deserializer::class) + @JsonSerialize(using = Stop.Serializer::class) + class Stop + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Stop = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitStrings(strings: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Stop && string == other.string && strings == other.strings + } + + override fun hashCode(): Int = Objects.hash(string, strings) + + override fun toString(): String = + when { + string != null -> "Stop{string=$string}" + strings != null -> "Stop{strings=$strings}" + _json != null -> "Stop{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Stop") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Stop(string = string) + + @JvmStatic fun ofStrings(strings: List) = Stop(strings = strings.toImmutable()) + } + + /** An interface that defines how to map each variant of [Stop] to a value of type [T]. */ + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + /** + * Maps an unknown variant of [Stop] to a value of type [T]. + * + * An instance of [Stop] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Stop: $json") + } + } + + internal class Deserializer : BaseDeserializer(Stop::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Stop { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Stop(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Stop(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Stop(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Stop::class) { + + override fun serialize( + value: Stop, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Stop") + } + } + } + } + + class StreamOptions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StreamOptions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StreamOptions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(streamOptions: StreamOptions) = apply { + additionalProperties = streamOptions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StreamOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StreamOptions = StreamOptions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): StreamOptions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StreamOptions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "StreamOptions{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = ToolChoice.Deserializer::class) + @JsonSerialize(using = ToolChoice.Serializer::class) + class ToolChoice + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ToolChoice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolChoice && + string == other.string && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "ToolChoice{string=$string}" + unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ToolChoice(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [ToolChoice] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [ToolChoice] to a value of type [T]. + * + * An instance of [ToolChoice] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown ToolChoice: $json") + } + } + + internal class Deserializer : BaseDeserializer(ToolChoice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ToolChoice(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ToolChoice(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> ToolChoice(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ToolChoice::class) { + + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + class Tool + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Tool]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tool]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tool: Tool) = apply { + additionalProperties = tool.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tool]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Tool = Tool(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Tool = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tool && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Tool{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -234,15 +16903,13 @@ private constructor( } return other is CompletionCreateParams && - model == other.model && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = - Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "CompletionCreateParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "CompletionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt index 9524a867..cfea61a4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereCreateParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/cohere) */ class CohereCreateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt index 65078b07..2a94d983 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereDeleteParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/cohere) */ class CohereDeleteParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt index 7e831cb8..d6dcdaaf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereModifyParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/cohere) */ class CohereModifyParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt index 62356755..44b2f103 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereRetrieveParams.kt @@ -9,7 +9,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/cohere) */ class CohereRetrieveParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt index 7384e986..5641c67c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/cohere/CohereUpdateParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/cohere) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/cohere) */ class CohereUpdateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt index fd85bf0a..286abbb6 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointDeleteParams.kt @@ -12,7 +12,7 @@ import java.util.Objects import java.util.Optional /** - * Delete a pass-through endpoint + * Delete a pass-through endpoint by ID. * * Returns - the deleted endpoint */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt index f1b556f7..99e6f70a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointListParams.kt @@ -17,12 +17,15 @@ import kotlin.jvm.optionals.getOrNull class PassThroughEndpointListParams private constructor( private val endpointId: String?, + private val teamId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun endpointId(): Optional = Optional.ofNullable(endpointId) + fun teamId(): Optional = Optional.ofNullable(teamId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -46,12 +49,14 @@ private constructor( class Builder internal constructor() { private var endpointId: String? = null + private var teamId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(passThroughEndpointListParams: PassThroughEndpointListParams) = apply { endpointId = passThroughEndpointListParams.endpointId + teamId = passThroughEndpointListParams.teamId additionalHeaders = passThroughEndpointListParams.additionalHeaders.toBuilder() additionalQueryParams = passThroughEndpointListParams.additionalQueryParams.toBuilder() } @@ -61,6 +66,11 @@ private constructor( /** Alias for calling [Builder.endpointId] with `endpointId.orElse(null)`. */ fun endpointId(endpointId: Optional) = endpointId(endpointId.getOrNull()) + fun teamId(teamId: String?) = apply { this.teamId = teamId } + + /** Alias for calling [Builder.teamId] with `teamId.orElse(null)`. */ + fun teamId(teamId: Optional) = teamId(teamId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -167,6 +177,7 @@ private constructor( fun build(): PassThroughEndpointListParams = PassThroughEndpointListParams( endpointId, + teamId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -178,6 +189,7 @@ private constructor( QueryParams.builder() .apply { endpointId?.let { put("endpoint_id", it) } + teamId?.let { put("team_id", it) } putAll(additionalQueryParams) } .build() @@ -189,13 +201,14 @@ private constructor( return other is PassThroughEndpointListParams && endpointId == other.endpointId && + teamId == other.teamId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(endpointId, additionalHeaders, additionalQueryParams) + Objects.hash(endpointId, teamId, additionalHeaders, additionalQueryParams) override fun toString() = - "PassThroughEndpointListParams{endpointId=$endpointId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "PassThroughEndpointListParams{endpointId=$endpointId, teamId=$teamId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt index aab89b1f..5c0c9d41 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughEndpointUpdateParams.kt @@ -4,26 +4,28 @@ package ai.hanzo.api.models.config.passthroughendpoint import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams -import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Update a pass-through endpoint */ +/** Update a pass-through endpoint by ID. */ class PassThroughEndpointUpdateParams private constructor( private val endpointId: String?, + private val passThroughGenericEndpoint: PassThroughGenericEndpoint, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { fun endpointId(): Optional = Optional.ofNullable(endpointId) - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + fun passThroughGenericEndpoint(): PassThroughGenericEndpoint = passThroughGenericEndpoint + + fun _additionalBodyProperties(): Map = + passThroughGenericEndpoint._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -35,11 +37,14 @@ private constructor( companion object { - @JvmStatic fun none(): PassThroughEndpointUpdateParams = builder().build() - /** * Returns a mutable builder for constructing an instance of * [PassThroughEndpointUpdateParams]. + * + * The following fields are required: + * ```java + * .passThroughGenericEndpoint() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -48,19 +53,19 @@ private constructor( class Builder internal constructor() { private var endpointId: String? = null + private var passThroughGenericEndpoint: PassThroughGenericEndpoint? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(passThroughEndpointUpdateParams: PassThroughEndpointUpdateParams) = apply { endpointId = passThroughEndpointUpdateParams.endpointId + passThroughGenericEndpoint = + passThroughEndpointUpdateParams.passThroughGenericEndpoint additionalHeaders = passThroughEndpointUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = passThroughEndpointUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - passThroughEndpointUpdateParams.additionalBodyProperties.toMutableMap() } fun endpointId(endpointId: String?) = apply { this.endpointId = endpointId } @@ -68,6 +73,11 @@ private constructor( /** Alias for calling [Builder.endpointId] with `endpointId.orElse(null)`. */ fun endpointId(endpointId: Optional) = endpointId(endpointId.getOrNull()) + fun passThroughGenericEndpoint(passThroughGenericEndpoint: PassThroughGenericEndpoint) = + apply { + this.passThroughGenericEndpoint = passThroughGenericEndpoint + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -166,44 +176,28 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - /** * Returns an immutable instance of [PassThroughEndpointUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .passThroughGenericEndpoint() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PassThroughEndpointUpdateParams = PassThroughEndpointUpdateParams( endpointId, + checkRequired("passThroughGenericEndpoint", passThroughGenericEndpoint), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + fun _body(): PassThroughGenericEndpoint = passThroughGenericEndpoint fun _pathParam(index: Int): String = when (index) { @@ -222,14 +216,19 @@ private constructor( return other is PassThroughEndpointUpdateParams && endpointId == other.endpointId && + passThroughGenericEndpoint == other.passThroughGenericEndpoint && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(endpointId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash( + endpointId, + passThroughGenericEndpoint, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "PassThroughEndpointUpdateParams{endpointId=$endpointId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "PassThroughEndpointUpdateParams{endpointId=$endpointId, passThroughGenericEndpoint=$passThroughGenericEndpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt index 12cea4fb..c8498cb3 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/config/passthroughendpoint/PassThroughGenericEndpoint.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -14,31 +15,53 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class PassThroughGenericEndpoint @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val headers: JsonValue, private val path: JsonField, private val target: JsonField, + private val id: JsonField, + private val auth: JsonField, + private val costPerRequest: JsonField, + private val guardrails: JsonField, + private val headers: JsonField, + private val includeSubpath: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), @JsonProperty("target") @ExcludeMissing target: JsonField = JsonMissing.of(), - ) : this(headers, path, target, mutableMapOf()) + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("auth") @ExcludeMissing auth: JsonField = JsonMissing.of(), + @JsonProperty("cost_per_request") + @ExcludeMissing + costPerRequest: JsonField = JsonMissing.of(), + @JsonProperty("guardrails") + @ExcludeMissing + guardrails: JsonField = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), + @JsonProperty("include_subpath") + @ExcludeMissing + includeSubpath: JsonField = JsonMissing.of(), + ) : this( + path, + target, + id, + auth, + costPerRequest, + guardrails, + headers, + includeSubpath, + mutableMapOf(), + ) /** - * Key-value pairs of headers to be forwarded with the request. You can set any key value pair - * here and it will be forwarded to your target endpoint - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers - - /** - * The route to be added to the LLM Proxy Server. + * The route to be added to the LiteLLM Proxy Server. * * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -53,6 +76,62 @@ private constructor( */ fun target(): String = target.getRequired("target") + /** + * Optional unique identifier for the pass-through endpoint. If not provided, endpoints will be + * identified by path for backwards compatibility. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Whether authentication is required for the pass-through endpoint. If True, requests to the + * endpoint will require a valid LiteLLM API key. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun auth(): Optional = auth.getOptional("auth") + + /** + * The USD cost per request to the target endpoint. This is used to calculate the cost of the + * request to the target endpoint. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun costPerRequest(): Optional = costPerRequest.getOptional("cost_per_request") + + /** + * Guardrails configuration for this passthrough endpoint. Dict keys are guardrail names, values + * are optional settings for field targeting. When set, all org/team/key level guardrails will + * also execute. Defaults to None (no guardrails execute). + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrails(): Optional = guardrails.getOptional("guardrails") + + /** + * Key-value pairs of headers to be forwarded with the request. You can set any key value pair + * here and it will be forwarded to your target endpoint + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * If True, requests to subpaths of the path will be forwarded to the target endpoint. For + * example, if the path is /bria and include_subpath is True, requests to + * /bria/v1/text-to-image/base/2.3 will be forwarded to the target endpoint. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeSubpath(): Optional = includeSubpath.getOptional("include_subpath") + /** * Returns the raw JSON value of [path]. * @@ -67,6 +146,54 @@ private constructor( */ @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [auth]. + * + * Unlike [auth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auth") @ExcludeMissing fun _auth(): JsonField = auth + + /** + * Returns the raw JSON value of [costPerRequest]. + * + * Unlike [costPerRequest], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_per_request") + @ExcludeMissing + fun _costPerRequest(): JsonField = costPerRequest + + /** + * Returns the raw JSON value of [guardrails]. + * + * Unlike [guardrails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("guardrails") + @ExcludeMissing + fun _guardrails(): JsonField = guardrails + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [includeSubpath]. + * + * Unlike [includeSubpath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("include_subpath") + @ExcludeMissing + fun _includeSubpath(): JsonField = includeSubpath + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -86,7 +213,6 @@ private constructor( * * The following fields are required: * ```java - * .headers() * .path() * .target() * ``` @@ -97,26 +223,30 @@ private constructor( /** A builder for [PassThroughGenericEndpoint]. */ class Builder internal constructor() { - private var headers: JsonValue? = null private var path: JsonField? = null private var target: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var auth: JsonField = JsonMissing.of() + private var costPerRequest: JsonField = JsonMissing.of() + private var guardrails: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var includeSubpath: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(passThroughGenericEndpoint: PassThroughGenericEndpoint) = apply { - headers = passThroughGenericEndpoint.headers path = passThroughGenericEndpoint.path target = passThroughGenericEndpoint.target + id = passThroughGenericEndpoint.id + auth = passThroughGenericEndpoint.auth + costPerRequest = passThroughGenericEndpoint.costPerRequest + guardrails = passThroughGenericEndpoint.guardrails + headers = passThroughGenericEndpoint.headers + includeSubpath = passThroughGenericEndpoint.includeSubpath additionalProperties = passThroughGenericEndpoint.additionalProperties.toMutableMap() } - /** - * Key-value pairs of headers to be forwarded with the request. You can set any key value - * pair here and it will be forwarded to your target endpoint - */ - fun headers(headers: JsonValue) = apply { this.headers = headers } - - /** The route to be added to the LLM Proxy Server. */ + /** The route to be added to the LiteLLM Proxy Server. */ fun path(path: String) = path(JsonField.of(path)) /** @@ -138,6 +268,105 @@ private constructor( */ fun target(target: JsonField) = apply { this.target = target } + /** + * Optional unique identifier for the pass-through endpoint. If not provided, endpoints will + * be identified by path for backwards compatibility. + */ + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * Whether authentication is required for the pass-through endpoint. If True, requests to + * the endpoint will require a valid LiteLLM API key. + */ + fun auth(auth: Boolean) = auth(JsonField.of(auth)) + + /** + * Sets [Builder.auth] to an arbitrary JSON value. + * + * You should usually call [Builder.auth] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun auth(auth: JsonField) = apply { this.auth = auth } + + /** + * The USD cost per request to the target endpoint. This is used to calculate the cost of + * the request to the target endpoint. + */ + fun costPerRequest(costPerRequest: Double) = costPerRequest(JsonField.of(costPerRequest)) + + /** + * Sets [Builder.costPerRequest] to an arbitrary JSON value. + * + * You should usually call [Builder.costPerRequest] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun costPerRequest(costPerRequest: JsonField) = apply { + this.costPerRequest = costPerRequest + } + + /** + * Guardrails configuration for this passthrough endpoint. Dict keys are guardrail names, + * values are optional settings for field targeting. When set, all org/team/key level + * guardrails will also execute. Defaults to None (no guardrails execute). + */ + fun guardrails(guardrails: Guardrails?) = guardrails(JsonField.ofNullable(guardrails)) + + /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */ + fun guardrails(guardrails: Optional) = guardrails(guardrails.getOrNull()) + + /** + * Sets [Builder.guardrails] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrails] with a well-typed [Guardrails] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun guardrails(guardrails: JsonField) = apply { this.guardrails = guardrails } + + /** + * Key-value pairs of headers to be forwarded with the request. You can set any key value + * pair here and it will be forwarded to your target endpoint + */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** + * If True, requests to subpaths of the path will be forwarded to the target endpoint. For + * example, if the path is /bria and include_subpath is True, requests to + * /bria/v1/text-to-image/base/2.3 will be forwarded to the target endpoint. + */ + fun includeSubpath(includeSubpath: Boolean) = includeSubpath(JsonField.of(includeSubpath)) + + /** + * Sets [Builder.includeSubpath] to an arbitrary JSON value. + * + * You should usually call [Builder.includeSubpath] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeSubpath(includeSubpath: JsonField) = apply { + this.includeSubpath = includeSubpath + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -164,7 +393,6 @@ private constructor( * * The following fields are required: * ```java - * .headers() * .path() * .target() * ``` @@ -173,9 +401,14 @@ private constructor( */ fun build(): PassThroughGenericEndpoint = PassThroughGenericEndpoint( - checkRequired("headers", headers), checkRequired("path", path), checkRequired("target", target), + id, + auth, + costPerRequest, + guardrails, + headers, + includeSubpath, additionalProperties.toMutableMap(), ) } @@ -189,6 +422,12 @@ private constructor( path() target() + id() + auth() + costPerRequest() + guardrails().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + includeSubpath() validated = true } @@ -207,7 +446,221 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (path.asKnown().isPresent) 1 else 0) + (if (target.asKnown().isPresent) 1 else 0) + (if (path.asKnown().isPresent) 1 else 0) + + (if (target.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (auth.asKnown().isPresent) 1 else 0) + + (if (costPerRequest.asKnown().isPresent) 1 else 0) + + (guardrails.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (if (includeSubpath.asKnown().isPresent) 1 else 0) + + /** + * Guardrails configuration for this passthrough endpoint. Dict keys are guardrail names, values + * are optional settings for field targeting. When set, all org/team/key level guardrails will + * also execute. Defaults to None (no guardrails execute). + */ + class Guardrails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Guardrails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Guardrails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(guardrails: Guardrails) = apply { + additionalProperties = guardrails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Guardrails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Guardrails = Guardrails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Guardrails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Guardrails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Guardrails{additionalProperties=$additionalProperties}" + } + + /** + * Key-value pairs of headers to be forwarded with the request. You can set any key value pair + * here and it will be forwarded to your target endpoint + */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -215,16 +668,33 @@ private constructor( } return other is PassThroughGenericEndpoint && - headers == other.headers && path == other.path && target == other.target && + id == other.id && + auth == other.auth && + costPerRequest == other.costPerRequest && + guardrails == other.guardrails && + headers == other.headers && + includeSubpath == other.includeSubpath && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(headers, path, target, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + path, + target, + id, + auth, + costPerRequest, + guardrails, + headers, + includeSubpath, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "PassThroughGenericEndpoint{headers=$headers, path=$path, target=$target, additionalProperties=$additionalProperties}" + "PassThroughGenericEndpoint{path=$path, target=$target, id=$id, auth=$auth, costPerRequest=$costPerRequest, guardrails=$guardrails, headers=$headers, includeSubpath=$includeSubpath, additionalProperties=$additionalProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt index 9f168c35..f6af6cf2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialCreateParams.kt @@ -10,6 +10,7 @@ import ai.hanzo.api.core.Params import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams +import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -31,7 +32,11 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun _credentialInfo(): JsonValue = body._credentialInfo() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun credentialInfo(): CredentialInfo = body.credentialInfo() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -39,7 +44,11 @@ private constructor( */ fun credentialName(): String = body.credentialName() - fun _credentialValues(): JsonValue = body._credentialValues() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun credentialValues(): Optional = body.credentialValues() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -47,6 +56,13 @@ private constructor( */ fun modelId(): Optional = body.modelId() + /** + * Returns the raw JSON value of [credentialInfo]. + * + * Unlike [credentialInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _credentialInfo(): JsonField = body._credentialInfo() + /** * Returns the raw JSON value of [credentialName]. * @@ -54,6 +70,14 @@ private constructor( */ fun _credentialName(): JsonField = body._credentialName() + /** + * Returns the raw JSON value of [credentialValues]. + * + * Unlike [credentialValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _credentialValues(): JsonField = body._credentialValues() + /** * Returns the raw JSON value of [modelId]. * @@ -111,7 +135,18 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - fun credentialInfo(credentialInfo: JsonValue) = apply { + fun credentialInfo(credentialInfo: CredentialInfo) = apply { + body.credentialInfo(credentialInfo) + } + + /** + * Sets [Builder.credentialInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialInfo] with a well-typed [CredentialInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credentialInfo(credentialInfo: JsonField) = apply { body.credentialInfo(credentialInfo) } @@ -128,7 +163,22 @@ private constructor( body.credentialName(credentialName) } - fun credentialValues(credentialValues: JsonValue) = apply { + fun credentialValues(credentialValues: CredentialValues?) = apply { + body.credentialValues(credentialValues) + } + + /** Alias for calling [Builder.credentialValues] with `credentialValues.orElse(null)`. */ + fun credentialValues(credentialValues: Optional) = + credentialValues(credentialValues.getOrNull()) + + /** + * Sets [Builder.credentialValues] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialValues] with a well-typed [CredentialValues] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun credentialValues(credentialValues: JsonField) = apply { body.credentialValues(credentialValues) } @@ -292,9 +342,9 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val credentialInfo: JsonValue, + private val credentialInfo: JsonField, private val credentialName: JsonField, - private val credentialValues: JsonValue, + private val credentialValues: JsonField, private val modelId: JsonField, private val additionalProperties: MutableMap, ) { @@ -303,19 +353,21 @@ private constructor( private constructor( @JsonProperty("credential_info") @ExcludeMissing - credentialInfo: JsonValue = JsonMissing.of(), + credentialInfo: JsonField = JsonMissing.of(), @JsonProperty("credential_name") @ExcludeMissing credentialName: JsonField = JsonMissing.of(), @JsonProperty("credential_values") @ExcludeMissing - credentialValues: JsonValue = JsonMissing.of(), + credentialValues: JsonField = JsonMissing.of(), @JsonProperty("model_id") @ExcludeMissing modelId: JsonField = JsonMissing.of(), ) : this(credentialInfo, credentialName, credentialValues, modelId, mutableMapOf()) - @JsonProperty("credential_info") - @ExcludeMissing - fun _credentialInfo(): JsonValue = credentialInfo + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun credentialInfo(): CredentialInfo = credentialInfo.getRequired("credential_info") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is @@ -323,9 +375,12 @@ private constructor( */ fun credentialName(): String = credentialName.getRequired("credential_name") - @JsonProperty("credential_values") - @ExcludeMissing - fun _credentialValues(): JsonValue = credentialValues + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun credentialValues(): Optional = + credentialValues.getOptional("credential_values") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -333,6 +388,16 @@ private constructor( */ fun modelId(): Optional = modelId.getOptional("model_id") + /** + * Returns the raw JSON value of [credentialInfo]. + * + * Unlike [credentialInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credential_info") + @ExcludeMissing + fun _credentialInfo(): JsonField = credentialInfo + /** * Returns the raw JSON value of [credentialName]. * @@ -343,6 +408,16 @@ private constructor( @ExcludeMissing fun _credentialName(): JsonField = credentialName + /** + * Returns the raw JSON value of [credentialValues]. + * + * Unlike [credentialValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credential_values") + @ExcludeMissing + fun _credentialValues(): JsonField = credentialValues + /** * Returns the raw JSON value of [modelId]. * @@ -379,9 +454,9 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var credentialInfo: JsonValue? = null + private var credentialInfo: JsonField? = null private var credentialName: JsonField? = null - private var credentialValues: JsonValue = JsonMissing.of() + private var credentialValues: JsonField = JsonMissing.of() private var modelId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -394,7 +469,17 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - fun credentialInfo(credentialInfo: JsonValue) = apply { + fun credentialInfo(credentialInfo: CredentialInfo) = + credentialInfo(JsonField.of(credentialInfo)) + + /** + * Sets [Builder.credentialInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialInfo] with a well-typed [CredentialInfo] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun credentialInfo(credentialInfo: JsonField) = apply { this.credentialInfo = credentialInfo } @@ -412,7 +497,23 @@ private constructor( this.credentialName = credentialName } - fun credentialValues(credentialValues: JsonValue) = apply { + fun credentialValues(credentialValues: CredentialValues?) = + credentialValues(JsonField.ofNullable(credentialValues)) + + /** + * Alias for calling [Builder.credentialValues] with `credentialValues.orElse(null)`. + */ + fun credentialValues(credentialValues: Optional) = + credentialValues(credentialValues.getOrNull()) + + /** + * Sets [Builder.credentialValues] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialValues] with a well-typed + * [CredentialValues] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun credentialValues(credentialValues: JsonField) = apply { this.credentialValues = credentialValues } @@ -479,7 +580,9 @@ private constructor( return@apply } + credentialInfo().validate() credentialName() + credentialValues().ifPresent { it.validate() } modelId() validated = true } @@ -500,7 +603,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (credentialName.asKnown().isPresent) 1 else 0) + + (credentialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (credentialName.asKnown().isPresent) 1 else 0) + + (credentialValues.asKnown().getOrNull()?.validity() ?: 0) + (if (modelId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -532,6 +637,204 @@ private constructor( "Body{credentialInfo=$credentialInfo, credentialName=$credentialName, credentialValues=$credentialValues, modelId=$modelId, additionalProperties=$additionalProperties}" } + class CredentialInfo + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CredentialInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CredentialInfo]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(credentialInfo: CredentialInfo) = apply { + additionalProperties = credentialInfo.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CredentialInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CredentialInfo = CredentialInfo(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CredentialInfo = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CredentialInfo && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CredentialInfo{additionalProperties=$additionalProperties}" + } + + class CredentialValues + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CredentialValues]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CredentialValues]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(credentialValues: CredentialValues) = apply { + additionalProperties = credentialValues.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CredentialValues]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CredentialValues = CredentialValues(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CredentialValues = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CredentialValues && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CredentialValues{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt index deb6a07e..c9764d7e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialDeleteParams.kt @@ -20,6 +20,7 @@ private constructor( private val additionalBodyProperties: Map, ) : Params { + /** The credential name, percent-decoded; may contain slashes */ fun credentialName(): Optional = Optional.ofNullable(credentialName) /** Additional body properties to send with the request. */ @@ -58,6 +59,7 @@ private constructor( credentialDeleteParams.additionalBodyProperties.toMutableMap() } + /** The credential name, percent-decoded; may contain slashes */ fun credentialName(credentialName: String?) = apply { this.credentialName = credentialName } /** Alias for calling [Builder.credentialName] with `credentialName.orElse(null)`. */ diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt index 8dd9f0a8..80768513 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/credentials/CredentialItem.kt @@ -7,6 +7,7 @@ import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -14,13 +15,14 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class CredentialItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val credentialInfo: JsonValue, + private val credentialInfo: JsonField, private val credentialName: JsonField, - private val credentialValues: JsonValue, + private val credentialValues: JsonField, private val additionalProperties: MutableMap, ) { @@ -28,18 +30,20 @@ private constructor( private constructor( @JsonProperty("credential_info") @ExcludeMissing - credentialInfo: JsonValue = JsonMissing.of(), + credentialInfo: JsonField = JsonMissing.of(), @JsonProperty("credential_name") @ExcludeMissing credentialName: JsonField = JsonMissing.of(), @JsonProperty("credential_values") @ExcludeMissing - credentialValues: JsonValue = JsonMissing.of(), + credentialValues: JsonField = JsonMissing.of(), ) : this(credentialInfo, credentialName, credentialValues, mutableMapOf()) - @JsonProperty("credential_info") - @ExcludeMissing - fun _credentialInfo(): JsonValue = credentialInfo + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun credentialInfo(): CredentialInfo = credentialInfo.getRequired("credential_info") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -47,9 +51,20 @@ private constructor( */ fun credentialName(): String = credentialName.getRequired("credential_name") - @JsonProperty("credential_values") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun credentialValues(): CredentialValues = credentialValues.getRequired("credential_values") + + /** + * Returns the raw JSON value of [credentialInfo]. + * + * Unlike [credentialInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credential_info") @ExcludeMissing - fun _credentialValues(): JsonValue = credentialValues + fun _credentialInfo(): JsonField = credentialInfo /** * Returns the raw JSON value of [credentialName]. @@ -60,6 +75,16 @@ private constructor( @ExcludeMissing fun _credentialName(): JsonField = credentialName + /** + * Returns the raw JSON value of [credentialValues]. + * + * Unlike [credentialValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credential_values") + @ExcludeMissing + fun _credentialValues(): JsonField = credentialValues + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -90,9 +115,9 @@ private constructor( /** A builder for [CredentialItem]. */ class Builder internal constructor() { - private var credentialInfo: JsonValue? = null + private var credentialInfo: JsonField? = null private var credentialName: JsonField? = null - private var credentialValues: JsonValue? = null + private var credentialValues: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,7 +128,17 @@ private constructor( additionalProperties = credentialItem.additionalProperties.toMutableMap() } - fun credentialInfo(credentialInfo: JsonValue) = apply { + fun credentialInfo(credentialInfo: CredentialInfo) = + credentialInfo(JsonField.of(credentialInfo)) + + /** + * Sets [Builder.credentialInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialInfo] with a well-typed [CredentialInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credentialInfo(credentialInfo: JsonField) = apply { this.credentialInfo = credentialInfo } @@ -120,7 +155,17 @@ private constructor( this.credentialName = credentialName } - fun credentialValues(credentialValues: JsonValue) = apply { + fun credentialValues(credentialValues: CredentialValues) = + credentialValues(JsonField.of(credentialValues)) + + /** + * Sets [Builder.credentialValues] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialValues] with a well-typed [CredentialValues] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun credentialValues(credentialValues: JsonField) = apply { this.credentialValues = credentialValues } @@ -173,7 +218,9 @@ private constructor( return@apply } + credentialInfo().validate() credentialName() + credentialValues().validate() validated = true } @@ -190,7 +237,209 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (credentialName.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (credentialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (credentialName.asKnown().isPresent) 1 else 0) + + (credentialValues.asKnown().getOrNull()?.validity() ?: 0) + + class CredentialInfo + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CredentialInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CredentialInfo]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(credentialInfo: CredentialInfo) = apply { + additionalProperties = credentialInfo.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CredentialInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CredentialInfo = CredentialInfo(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CredentialInfo = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CredentialInfo && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CredentialInfo{additionalProperties=$additionalProperties}" + } + + class CredentialValues + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CredentialValues]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CredentialValues]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(credentialValues: CredentialValues) = apply { + additionalProperties = credentialValues.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CredentialValues]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CredentialValues = CredentialValues(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CredentialValues = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CredentialValues && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CredentialValues{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt index ba8a227f..0c1f6c7f 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerCreateParams.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -52,13 +53,15 @@ import kotlin.jvm.optionals.getOrNull * a given customer. * - soft_budget: Optional[float] - [Not Implemented Yet] Get alerts when customer crosses given * budget, doesn't block requests. + * - spend: Optional[float] - Specify initial spend for a given customer. + * - budget_reset_at: Optional[str] - Specify the date and time when the budget should be reset. * - Allow specifying allowed regions * - Allow specifying default model * * Example curl: * ``` * curl --location 'http://0.0.0.0:4000/customer/new' --header 'Authorization: Bearer sk-1234' --header 'Content-Type: application/json' --data '{ - * "user_id" : "z-jaff-3", + * "user_id" : "ishaan-jaff-3", * "allowed_region": "eu", * "budget_id": "free_tier", * "default_model": "azure/gpt-3.5-turbo-eu" <- all calls from this user, use this model? @@ -115,6 +118,14 @@ private constructor( */ fun budgetId(): Optional = body.budgetId() + /** + * Datetime when the budget is reset + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun budgetResetAt(): Optional = body.budgetResetAt() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -162,6 +173,12 @@ private constructor( */ fun softBudget(): Optional = body.softBudget() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun spend(): Optional = body.spend() + /** * Max tokens per minute, allowed for this budget id. * @@ -213,6 +230,13 @@ private constructor( */ fun _budgetId(): JsonField = body._budgetId() + /** + * Returns the raw JSON value of [budgetResetAt]. + * + * Unlike [budgetResetAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _budgetResetAt(): JsonField = body._budgetResetAt() + /** * Returns the raw JSON value of [defaultModel]. * @@ -256,6 +280,13 @@ private constructor( */ fun _softBudget(): JsonField = body._softBudget() + /** + * Returns the raw JSON value of [spend]. + * + * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _spend(): JsonField = body._spend() + /** * Returns the raw JSON value of [tpmLimit]. * @@ -399,6 +430,26 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { body.budgetId(budgetId) } + /** Datetime when the budget is reset */ + fun budgetResetAt(budgetResetAt: OffsetDateTime?) = apply { + body.budgetResetAt(budgetResetAt) + } + + /** Alias for calling [Builder.budgetResetAt] with `budgetResetAt.orElse(null)`. */ + fun budgetResetAt(budgetResetAt: Optional) = + budgetResetAt(budgetResetAt.getOrNull()) + + /** + * Sets [Builder.budgetResetAt] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetResetAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun budgetResetAt(budgetResetAt: JsonField) = apply { + body.budgetResetAt(budgetResetAt) + } + fun defaultModel(defaultModel: String?) = apply { body.defaultModel(defaultModel) } /** Alias for calling [Builder.defaultModel] with `defaultModel.orElse(null)`. */ @@ -533,6 +584,26 @@ private constructor( */ fun softBudget(softBudget: JsonField) = apply { body.softBudget(softBudget) } + fun spend(spend: Double?) = apply { body.spend(spend) } + + /** + * Alias for [Builder.spend]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun spend(spend: Double) = spend(spend as Double?) + + /** Alias for calling [Builder.spend] with `spend.orElse(null)`. */ + fun spend(spend: Optional) = spend(spend.getOrNull()) + + /** + * Sets [Builder.spend] to an arbitrary JSON value. + * + * You should usually call [Builder.spend] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun spend(spend: JsonField) = apply { body.spend(spend) } + /** Max tokens per minute, allowed for this budget id. */ fun tpmLimit(tpmLimit: Long?) = apply { body.tpmLimit(tpmLimit) } @@ -707,12 +778,14 @@ private constructor( private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetId: JsonField, + private val budgetResetAt: JsonField, private val defaultModel: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, private val modelMaxBudget: JsonField, private val rpmLimit: JsonField, private val softBudget: JsonField, + private val spend: JsonField, private val tpmLimit: JsonField, private val additionalProperties: MutableMap, ) { @@ -731,6 +804,9 @@ private constructor( @JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(), + @JsonProperty("budget_reset_at") + @ExcludeMissing + budgetResetAt: JsonField = JsonMissing.of(), @JsonProperty("default_model") @ExcludeMissing defaultModel: JsonField = JsonMissing.of(), @@ -747,6 +823,7 @@ private constructor( @JsonProperty("soft_budget") @ExcludeMissing softBudget: JsonField = JsonMissing.of(), + @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), ) : this( userId, @@ -755,12 +832,14 @@ private constructor( blocked, budgetDuration, budgetId, + budgetResetAt, defaultModel, maxBudget, maxParallelRequests, modelMaxBudget, rpmLimit, softBudget, + spend, tpmLimit, mutableMapOf(), ) @@ -804,6 +883,14 @@ private constructor( */ fun budgetId(): Optional = budgetId.getOptional("budget_id") + /** + * Datetime when the budget is reset + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -853,6 +940,12 @@ private constructor( */ fun softBudget(): Optional = softBudget.getOptional("soft_budget") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun spend(): Optional = spend.getOptional("spend") + /** * Max tokens per minute, allowed for this budget id. * @@ -909,6 +1002,16 @@ private constructor( */ @JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId + /** + * Returns the raw JSON value of [budgetResetAt]. + * + * Unlike [budgetResetAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("budget_reset_at") + @ExcludeMissing + fun _budgetResetAt(): JsonField = budgetResetAt + /** * Returns the raw JSON value of [defaultModel]. * @@ -962,6 +1065,13 @@ private constructor( @ExcludeMissing fun _softBudget(): JsonField = softBudget + /** + * Returns the raw JSON value of [spend]. + * + * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend + /** * Returns the raw JSON value of [tpmLimit]. * @@ -1003,12 +1113,14 @@ private constructor( private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetId: JsonField = JsonMissing.of() + private var budgetResetAt: JsonField = JsonMissing.of() private var defaultModel: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() private var modelMaxBudget: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() private var softBudget: JsonField = JsonMissing.of() + private var spend: JsonField = JsonMissing.of() private var tpmLimit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1020,12 +1132,14 @@ private constructor( blocked = body.blocked budgetDuration = body.budgetDuration budgetId = body.budgetId + budgetResetAt = body.budgetResetAt defaultModel = body.defaultModel maxBudget = body.maxBudget maxParallelRequests = body.maxParallelRequests modelMaxBudget = body.modelMaxBudget rpmLimit = body.rpmLimit softBudget = body.softBudget + spend = body.spend tpmLimit = body.tpmLimit additionalProperties = body.additionalProperties.toMutableMap() } @@ -1120,6 +1234,25 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } + /** Datetime when the budget is reset */ + fun budgetResetAt(budgetResetAt: OffsetDateTime?) = + budgetResetAt(JsonField.ofNullable(budgetResetAt)) + + /** Alias for calling [Builder.budgetResetAt] with `budgetResetAt.orElse(null)`. */ + fun budgetResetAt(budgetResetAt: Optional) = + budgetResetAt(budgetResetAt.getOrNull()) + + /** + * Sets [Builder.budgetResetAt] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetResetAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun budgetResetAt(budgetResetAt: JsonField) = apply { + this.budgetResetAt = budgetResetAt + } + fun defaultModel(defaultModel: String?) = defaultModel(JsonField.ofNullable(defaultModel)) @@ -1256,6 +1389,27 @@ private constructor( */ fun softBudget(softBudget: JsonField) = apply { this.softBudget = softBudget } + fun spend(spend: Double?) = spend(JsonField.ofNullable(spend)) + + /** + * Alias for [Builder.spend]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun spend(spend: Double) = spend(spend as Double?) + + /** Alias for calling [Builder.spend] with `spend.orElse(null)`. */ + fun spend(spend: Optional) = spend(spend.getOrNull()) + + /** + * Sets [Builder.spend] to an arbitrary JSON value. + * + * You should usually call [Builder.spend] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun spend(spend: JsonField) = apply { this.spend = spend } + /** Max tokens per minute, allowed for this budget id. */ fun tpmLimit(tpmLimit: Long?) = tpmLimit(JsonField.ofNullable(tpmLimit)) @@ -1317,12 +1471,14 @@ private constructor( blocked, budgetDuration, budgetId, + budgetResetAt, defaultModel, maxBudget, maxParallelRequests, modelMaxBudget, rpmLimit, softBudget, + spend, tpmLimit, additionalProperties.toMutableMap(), ) @@ -1341,12 +1497,14 @@ private constructor( blocked() budgetDuration() budgetId() + budgetResetAt() defaultModel() maxBudget() maxParallelRequests() modelMaxBudget().ifPresent { it.validate() } rpmLimit() softBudget() + spend() tpmLimit() validated = true } @@ -1373,12 +1531,14 @@ private constructor( (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetId.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + (if (defaultModel.asKnown().isPresent) 1 else 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + (if (softBudget.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + (if (tpmLimit.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -1393,12 +1553,14 @@ private constructor( blocked == other.blocked && budgetDuration == other.budgetDuration && budgetId == other.budgetId && + budgetResetAt == other.budgetResetAt && defaultModel == other.defaultModel && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && modelMaxBudget == other.modelMaxBudget && rpmLimit == other.rpmLimit && softBudget == other.softBudget && + spend == other.spend && tpmLimit == other.tpmLimit && additionalProperties == other.additionalProperties } @@ -1411,12 +1573,14 @@ private constructor( blocked, budgetDuration, budgetId, + budgetResetAt, defaultModel, maxBudget, maxParallelRequests, modelMaxBudget, rpmLimit, softBudget, + spend, tpmLimit, additionalProperties, ) @@ -1425,7 +1589,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{userId=$userId, alias=$alias, allowedModelRegion=$allowedModelRegion, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, defaultModel=$defaultModel, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}" + "Body{userId=$userId, alias=$alias, allowedModelRegion=$allowedModelRegion, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, budgetResetAt=$budgetResetAt, defaultModel=$defaultModel, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, spend=$spend, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}" } class AllowedModelRegion diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt index 59f3fa99..2746cb24 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerDeleteParams.kt @@ -30,7 +30,7 @@ import kotlin.jvm.optionals.getOrNull * Example curl: * ``` * curl --location 'http://0.0.0.0:4000/customer/delete' --header 'Authorization: Bearer sk-1234' --header 'Content-Type: application/json' --data '{ - * "user_ids" :["z-jaff-5"] + * "user_ids" :["ishaan-jaff-5"] * }' * * See below for all params diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt deleted file mode 100644 index 2e1acc5a..00000000 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerListResponse.kt +++ /dev/null @@ -1,979 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.hanzo.api.models.customer - -import ai.hanzo.api.core.Enum -import ai.hanzo.api.core.ExcludeMissing -import ai.hanzo.api.core.JsonField -import ai.hanzo.api.core.JsonMissing -import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.core.checkRequired -import ai.hanzo.api.errors.HanzoInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class CustomerListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val blocked: JsonField, - private val userId: JsonField, - private val alias: JsonField, - private val allowedModelRegion: JsonField, - private val defaultModel: JsonField, - private val llmBudgetTable: JsonField, - private val spend: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("allowed_model_region") - @ExcludeMissing - allowedModelRegion: JsonField = JsonMissing.of(), - @JsonProperty("default_model") - @ExcludeMissing - defaultModel: JsonField = JsonMissing.of(), - @JsonProperty("llm_budget_table") - @ExcludeMissing - llmBudgetTable: JsonField = JsonMissing.of(), - @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), - ) : this( - blocked, - userId, - alias, - allowedModelRegion, - defaultModel, - llmBudgetTable, - spend, - mutableMapOf(), - ) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun blocked(): Boolean = blocked.getRequired("blocked") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun userId(): String = userId.getRequired("user_id") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun alias(): Optional = alias.getOptional("alias") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allowedModelRegion(): Optional = - allowedModelRegion.getOptional("allowed_model_region") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun defaultModel(): Optional = defaultModel.getOptional("default_model") - - /** - * Represents user-controllable params for a LLM_BudgetTable record - * - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun spend(): Optional = spend.getOptional("spend") - - /** - * Returns the raw JSON value of [blocked]. - * - * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("blocked") @ExcludeMissing fun _blocked(): JsonField = blocked - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - - /** - * Returns the raw JSON value of [allowedModelRegion]. - * - * Unlike [allowedModelRegion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allowed_model_region") - @ExcludeMissing - fun _allowedModelRegion(): JsonField = allowedModelRegion - - /** - * Returns the raw JSON value of [defaultModel]. - * - * Unlike [defaultModel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("default_model") - @ExcludeMissing - fun _defaultModel(): JsonField = defaultModel - - /** - * Returns the raw JSON value of [llmBudgetTable]. - * - * Unlike [llmBudgetTable], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("llm_budget_table") - @ExcludeMissing - fun _llmBudgetTable(): JsonField = llmBudgetTable - - /** - * Returns the raw JSON value of [spend]. - * - * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CustomerListResponse]. - * - * The following fields are required: - * ```java - * .blocked() - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerListResponse]. */ - class Builder internal constructor() { - - private var blocked: JsonField? = null - private var userId: JsonField? = null - private var alias: JsonField = JsonMissing.of() - private var allowedModelRegion: JsonField = JsonMissing.of() - private var defaultModel: JsonField = JsonMissing.of() - private var llmBudgetTable: JsonField = JsonMissing.of() - private var spend: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerListResponse: CustomerListResponse) = apply { - blocked = customerListResponse.blocked - userId = customerListResponse.userId - alias = customerListResponse.alias - allowedModelRegion = customerListResponse.allowedModelRegion - defaultModel = customerListResponse.defaultModel - llmBudgetTable = customerListResponse.llmBudgetTable - spend = customerListResponse.spend - additionalProperties = customerListResponse.additionalProperties.toMutableMap() - } - - fun blocked(blocked: Boolean) = blocked(JsonField.of(blocked)) - - /** - * Sets [Builder.blocked] to an arbitrary JSON value. - * - * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun blocked(blocked: JsonField) = apply { this.blocked = blocked } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun alias(alias: String?) = alias(JsonField.ofNullable(alias)) - - /** Alias for calling [Builder.alias] with `alias.orElse(null)`. */ - fun alias(alias: Optional) = alias(alias.getOrNull()) - - /** - * Sets [Builder.alias] to an arbitrary JSON value. - * - * You should usually call [Builder.alias] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun alias(alias: JsonField) = apply { this.alias = alias } - - fun allowedModelRegion(allowedModelRegion: AllowedModelRegion?) = - allowedModelRegion(JsonField.ofNullable(allowedModelRegion)) - - /** - * Alias for calling [Builder.allowedModelRegion] with `allowedModelRegion.orElse(null)`. - */ - fun allowedModelRegion(allowedModelRegion: Optional) = - allowedModelRegion(allowedModelRegion.getOrNull()) - - /** - * Sets [Builder.allowedModelRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.allowedModelRegion] with a well-typed - * [AllowedModelRegion] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun allowedModelRegion(allowedModelRegion: JsonField) = apply { - this.allowedModelRegion = allowedModelRegion - } - - fun defaultModel(defaultModel: String?) = defaultModel(JsonField.ofNullable(defaultModel)) - - /** Alias for calling [Builder.defaultModel] with `defaultModel.orElse(null)`. */ - fun defaultModel(defaultModel: Optional) = defaultModel(defaultModel.getOrNull()) - - /** - * Sets [Builder.defaultModel] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultModel] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun defaultModel(defaultModel: JsonField) = apply { - this.defaultModel = defaultModel - } - - /** Represents user-controllable params for a LLM_BudgetTable record */ - fun llmBudgetTable(llmBudgetTable: LlmBudgetTable?) = - llmBudgetTable(JsonField.ofNullable(llmBudgetTable)) - - /** Alias for calling [Builder.llmBudgetTable] with `llmBudgetTable.orElse(null)`. */ - fun llmBudgetTable(llmBudgetTable: Optional) = - llmBudgetTable(llmBudgetTable.getOrNull()) - - /** - * Sets [Builder.llmBudgetTable] to an arbitrary JSON value. - * - * You should usually call [Builder.llmBudgetTable] with a well-typed [LlmBudgetTable] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun llmBudgetTable(llmBudgetTable: JsonField) = apply { - this.llmBudgetTable = llmBudgetTable - } - - fun spend(spend: Double) = spend(JsonField.of(spend)) - - /** - * Sets [Builder.spend] to an arbitrary JSON value. - * - * You should usually call [Builder.spend] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun spend(spend: JsonField) = apply { this.spend = spend } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomerListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .blocked() - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CustomerListResponse = - CustomerListResponse( - checkRequired("blocked", blocked), - checkRequired("userId", userId), - alias, - allowedModelRegion, - defaultModel, - llmBudgetTable, - spend, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CustomerListResponse = apply { - if (validated) { - return@apply - } - - blocked() - userId() - alias() - allowedModelRegion().ifPresent { it.validate() } - defaultModel() - llmBudgetTable().ifPresent { it.validate() } - spend() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (blocked.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) + - (if (alias.asKnown().isPresent) 1 else 0) + - (allowedModelRegion.asKnown().getOrNull()?.validity() ?: 0) + - (if (defaultModel.asKnown().isPresent) 1 else 0) + - (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + - (if (spend.asKnown().isPresent) 1 else 0) - - class AllowedModelRegion - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EU = of("eu") - - @JvmField val US = of("us") - - @JvmStatic fun of(value: String) = AllowedModelRegion(JsonField.of(value)) - } - - /** An enum containing [AllowedModelRegion]'s known values. */ - enum class Known { - EU, - US, - } - - /** - * An enum containing [AllowedModelRegion]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AllowedModelRegion] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EU, - US, - /** - * An enum member indicating that [AllowedModelRegion] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EU -> Value.EU - US -> Value.US - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws HanzoInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - EU -> Known.EU - US -> Known.US - else -> throw HanzoInvalidDataException("Unknown AllowedModelRegion: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws HanzoInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AllowedModelRegion = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AllowedModelRegion && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Represents user-controllable params for a LLM_BudgetTable record */ - class LlmBudgetTable - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val budgetDuration: JsonField, - private val maxBudget: JsonField, - private val maxParallelRequests: JsonField, - private val modelMaxBudget: JsonValue, - private val rpmLimit: JsonField, - private val softBudget: JsonField, - private val tpmLimit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("budget_duration") - @ExcludeMissing - budgetDuration: JsonField = JsonMissing.of(), - @JsonProperty("max_budget") - @ExcludeMissing - maxBudget: JsonField = JsonMissing.of(), - @JsonProperty("max_parallel_requests") - @ExcludeMissing - maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("model_max_budget") - @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), - @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), - @JsonProperty("soft_budget") - @ExcludeMissing - softBudget: JsonField = JsonMissing.of(), - @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), - ) : this( - budgetDuration, - maxBudget, - maxParallelRequests, - modelMaxBudget, - rpmLimit, - softBudget, - tpmLimit, - mutableMapOf(), - ) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun maxBudget(): Optional = maxBudget.getOptional("max_budget") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun maxParallelRequests(): Optional = - maxParallelRequests.getOptional("max_parallel_requests") - - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun softBudget(): Optional = softBudget.getOptional("soft_budget") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") - - /** - * Returns the raw JSON value of [budgetDuration]. - * - * Unlike [budgetDuration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("budget_duration") - @ExcludeMissing - fun _budgetDuration(): JsonField = budgetDuration - - /** - * Returns the raw JSON value of [maxBudget]. - * - * Unlike [maxBudget], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("max_budget") @ExcludeMissing fun _maxBudget(): JsonField = maxBudget - - /** - * Returns the raw JSON value of [maxParallelRequests]. - * - * Unlike [maxParallelRequests], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_parallel_requests") - @ExcludeMissing - fun _maxParallelRequests(): JsonField = maxParallelRequests - - /** - * Returns the raw JSON value of [rpmLimit]. - * - * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit - - /** - * Returns the raw JSON value of [softBudget]. - * - * Unlike [softBudget], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("soft_budget") - @ExcludeMissing - fun _softBudget(): JsonField = softBudget - - /** - * Returns the raw JSON value of [tpmLimit]. - * - * Unlike [tpmLimit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [LlmBudgetTable]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LlmBudgetTable]. */ - class Builder internal constructor() { - - private var budgetDuration: JsonField = JsonMissing.of() - private var maxBudget: JsonField = JsonMissing.of() - private var maxParallelRequests: JsonField = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var rpmLimit: JsonField = JsonMissing.of() - private var softBudget: JsonField = JsonMissing.of() - private var tpmLimit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(llmBudgetTable: LlmBudgetTable) = apply { - budgetDuration = llmBudgetTable.budgetDuration - maxBudget = llmBudgetTable.maxBudget - maxParallelRequests = llmBudgetTable.maxParallelRequests - modelMaxBudget = llmBudgetTable.modelMaxBudget - rpmLimit = llmBudgetTable.rpmLimit - softBudget = llmBudgetTable.softBudget - tpmLimit = llmBudgetTable.tpmLimit - additionalProperties = llmBudgetTable.additionalProperties.toMutableMap() - } - - fun budgetDuration(budgetDuration: String?) = - budgetDuration(JsonField.ofNullable(budgetDuration)) - - /** Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. */ - fun budgetDuration(budgetDuration: Optional) = - budgetDuration(budgetDuration.getOrNull()) - - /** - * Sets [Builder.budgetDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.budgetDuration] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun budgetDuration(budgetDuration: JsonField) = apply { - this.budgetDuration = budgetDuration - } - - fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) - - /** - * Alias for [Builder.maxBudget]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxBudget(maxBudget: Double) = maxBudget(maxBudget as Double?) - - /** Alias for calling [Builder.maxBudget] with `maxBudget.orElse(null)`. */ - fun maxBudget(maxBudget: Optional) = maxBudget(maxBudget.getOrNull()) - - /** - * Sets [Builder.maxBudget] to an arbitrary JSON value. - * - * You should usually call [Builder.maxBudget] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxBudget(maxBudget: JsonField) = apply { this.maxBudget = maxBudget } - - fun maxParallelRequests(maxParallelRequests: Long?) = - maxParallelRequests(JsonField.ofNullable(maxParallelRequests)) - - /** - * Alias for [Builder.maxParallelRequests]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxParallelRequests(maxParallelRequests: Long) = - maxParallelRequests(maxParallelRequests as Long?) - - /** - * Alias for calling [Builder.maxParallelRequests] with - * `maxParallelRequests.orElse(null)`. - */ - fun maxParallelRequests(maxParallelRequests: Optional) = - maxParallelRequests(maxParallelRequests.getOrNull()) - - /** - * Sets [Builder.maxParallelRequests] to an arbitrary JSON value. - * - * You should usually call [Builder.maxParallelRequests] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxParallelRequests(maxParallelRequests: JsonField) = apply { - this.maxParallelRequests = maxParallelRequests - } - - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { - this.modelMaxBudget = modelMaxBudget - } - - fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) - - /** - * Alias for [Builder.rpmLimit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rpmLimit(rpmLimit: Long) = rpmLimit(rpmLimit as Long?) - - /** Alias for calling [Builder.rpmLimit] with `rpmLimit.orElse(null)`. */ - fun rpmLimit(rpmLimit: Optional) = rpmLimit(rpmLimit.getOrNull()) - - /** - * Sets [Builder.rpmLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.rpmLimit] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } - - fun softBudget(softBudget: Double?) = softBudget(JsonField.ofNullable(softBudget)) - - /** - * Alias for [Builder.softBudget]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun softBudget(softBudget: Double) = softBudget(softBudget as Double?) - - /** Alias for calling [Builder.softBudget] with `softBudget.orElse(null)`. */ - fun softBudget(softBudget: Optional) = softBudget(softBudget.getOrNull()) - - /** - * Sets [Builder.softBudget] to an arbitrary JSON value. - * - * You should usually call [Builder.softBudget] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun softBudget(softBudget: JsonField) = apply { this.softBudget = softBudget } - - fun tpmLimit(tpmLimit: Long?) = tpmLimit(JsonField.ofNullable(tpmLimit)) - - /** - * Alias for [Builder.tpmLimit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun tpmLimit(tpmLimit: Long) = tpmLimit(tpmLimit as Long?) - - /** Alias for calling [Builder.tpmLimit] with `tpmLimit.orElse(null)`. */ - fun tpmLimit(tpmLimit: Optional) = tpmLimit(tpmLimit.getOrNull()) - - /** - * Sets [Builder.tpmLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.tpmLimit] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LlmBudgetTable]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LlmBudgetTable = - LlmBudgetTable( - budgetDuration, - maxBudget, - maxParallelRequests, - modelMaxBudget, - rpmLimit, - softBudget, - tpmLimit, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): LlmBudgetTable = apply { - if (validated) { - return@apply - } - - budgetDuration() - maxBudget() - maxParallelRequests() - rpmLimit() - softBudget() - tpmLimit() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (budgetDuration.asKnown().isPresent) 1 else 0) + - (if (maxBudget.asKnown().isPresent) 1 else 0) + - (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + - (if (rpmLimit.asKnown().isPresent) 1 else 0) + - (if (softBudget.asKnown().isPresent) 1 else 0) + - (if (tpmLimit.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LlmBudgetTable && - budgetDuration == other.budgetDuration && - maxBudget == other.maxBudget && - maxParallelRequests == other.maxParallelRequests && - modelMaxBudget == other.modelMaxBudget && - rpmLimit == other.rpmLimit && - softBudget == other.softBudget && - tpmLimit == other.tpmLimit && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - budgetDuration, - maxBudget, - maxParallelRequests, - modelMaxBudget, - rpmLimit, - softBudget, - tpmLimit, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LlmBudgetTable{budgetDuration=$budgetDuration, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomerListResponse && - blocked == other.blocked && - userId == other.userId && - alias == other.alias && - allowedModelRegion == other.allowedModelRegion && - defaultModel == other.defaultModel && - llmBudgetTable == other.llmBudgetTable && - spend == other.spend && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - blocked, - userId, - alias, - allowedModelRegion, - defaultModel, - llmBudgetTable, - spend, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerListResponse{blocked=$blocked, userId=$userId, alias=$alias, allowedModelRegion=$allowedModelRegion, defaultModel=$defaultModel, llmBudgetTable=$llmBudgetTable, spend=$spend, additionalProperties=$additionalProperties}" -} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParams.kt index ee882e03..7fed74cd 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoParams.kt @@ -16,7 +16,7 @@ import java.util.Objects * * Example curl: * ``` - * curl -X GET 'http://localhost:4000/customer/info?end_user_id=test-llm-user-4' -H 'Authorization: Bearer sk-1234' + * curl -X GET 'http://localhost:4000/customer/info?end_user_id=test-litellm-user-4' -H 'Authorization: Bearer sk-1234' * ``` */ class CustomerRetrieveInfoParams diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt deleted file mode 100644 index 087fdb73..00000000 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerRetrieveInfoResponse.kt +++ /dev/null @@ -1,979 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.hanzo.api.models.customer - -import ai.hanzo.api.core.Enum -import ai.hanzo.api.core.ExcludeMissing -import ai.hanzo.api.core.JsonField -import ai.hanzo.api.core.JsonMissing -import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.core.checkRequired -import ai.hanzo.api.errors.HanzoInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class CustomerRetrieveInfoResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val blocked: JsonField, - private val userId: JsonField, - private val alias: JsonField, - private val allowedModelRegion: JsonField, - private val defaultModel: JsonField, - private val llmBudgetTable: JsonField, - private val spend: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("allowed_model_region") - @ExcludeMissing - allowedModelRegion: JsonField = JsonMissing.of(), - @JsonProperty("default_model") - @ExcludeMissing - defaultModel: JsonField = JsonMissing.of(), - @JsonProperty("llm_budget_table") - @ExcludeMissing - llmBudgetTable: JsonField = JsonMissing.of(), - @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), - ) : this( - blocked, - userId, - alias, - allowedModelRegion, - defaultModel, - llmBudgetTable, - spend, - mutableMapOf(), - ) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun blocked(): Boolean = blocked.getRequired("blocked") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun userId(): String = userId.getRequired("user_id") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun alias(): Optional = alias.getOptional("alias") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allowedModelRegion(): Optional = - allowedModelRegion.getOptional("allowed_model_region") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun defaultModel(): Optional = defaultModel.getOptional("default_model") - - /** - * Represents user-controllable params for a LLM_BudgetTable record - * - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun llmBudgetTable(): Optional = llmBudgetTable.getOptional("llm_budget_table") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun spend(): Optional = spend.getOptional("spend") - - /** - * Returns the raw JSON value of [blocked]. - * - * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("blocked") @ExcludeMissing fun _blocked(): JsonField = blocked - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - - /** - * Returns the raw JSON value of [allowedModelRegion]. - * - * Unlike [allowedModelRegion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allowed_model_region") - @ExcludeMissing - fun _allowedModelRegion(): JsonField = allowedModelRegion - - /** - * Returns the raw JSON value of [defaultModel]. - * - * Unlike [defaultModel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("default_model") - @ExcludeMissing - fun _defaultModel(): JsonField = defaultModel - - /** - * Returns the raw JSON value of [llmBudgetTable]. - * - * Unlike [llmBudgetTable], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("llm_budget_table") - @ExcludeMissing - fun _llmBudgetTable(): JsonField = llmBudgetTable - - /** - * Returns the raw JSON value of [spend]. - * - * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CustomerRetrieveInfoResponse]. - * - * The following fields are required: - * ```java - * .blocked() - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerRetrieveInfoResponse]. */ - class Builder internal constructor() { - - private var blocked: JsonField? = null - private var userId: JsonField? = null - private var alias: JsonField = JsonMissing.of() - private var allowedModelRegion: JsonField = JsonMissing.of() - private var defaultModel: JsonField = JsonMissing.of() - private var llmBudgetTable: JsonField = JsonMissing.of() - private var spend: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerRetrieveInfoResponse: CustomerRetrieveInfoResponse) = apply { - blocked = customerRetrieveInfoResponse.blocked - userId = customerRetrieveInfoResponse.userId - alias = customerRetrieveInfoResponse.alias - allowedModelRegion = customerRetrieveInfoResponse.allowedModelRegion - defaultModel = customerRetrieveInfoResponse.defaultModel - llmBudgetTable = customerRetrieveInfoResponse.llmBudgetTable - spend = customerRetrieveInfoResponse.spend - additionalProperties = customerRetrieveInfoResponse.additionalProperties.toMutableMap() - } - - fun blocked(blocked: Boolean) = blocked(JsonField.of(blocked)) - - /** - * Sets [Builder.blocked] to an arbitrary JSON value. - * - * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun blocked(blocked: JsonField) = apply { this.blocked = blocked } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun alias(alias: String?) = alias(JsonField.ofNullable(alias)) - - /** Alias for calling [Builder.alias] with `alias.orElse(null)`. */ - fun alias(alias: Optional) = alias(alias.getOrNull()) - - /** - * Sets [Builder.alias] to an arbitrary JSON value. - * - * You should usually call [Builder.alias] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun alias(alias: JsonField) = apply { this.alias = alias } - - fun allowedModelRegion(allowedModelRegion: AllowedModelRegion?) = - allowedModelRegion(JsonField.ofNullable(allowedModelRegion)) - - /** - * Alias for calling [Builder.allowedModelRegion] with `allowedModelRegion.orElse(null)`. - */ - fun allowedModelRegion(allowedModelRegion: Optional) = - allowedModelRegion(allowedModelRegion.getOrNull()) - - /** - * Sets [Builder.allowedModelRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.allowedModelRegion] with a well-typed - * [AllowedModelRegion] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun allowedModelRegion(allowedModelRegion: JsonField) = apply { - this.allowedModelRegion = allowedModelRegion - } - - fun defaultModel(defaultModel: String?) = defaultModel(JsonField.ofNullable(defaultModel)) - - /** Alias for calling [Builder.defaultModel] with `defaultModel.orElse(null)`. */ - fun defaultModel(defaultModel: Optional) = defaultModel(defaultModel.getOrNull()) - - /** - * Sets [Builder.defaultModel] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultModel] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun defaultModel(defaultModel: JsonField) = apply { - this.defaultModel = defaultModel - } - - /** Represents user-controllable params for a LLM_BudgetTable record */ - fun llmBudgetTable(llmBudgetTable: LlmBudgetTable?) = - llmBudgetTable(JsonField.ofNullable(llmBudgetTable)) - - /** Alias for calling [Builder.llmBudgetTable] with `llmBudgetTable.orElse(null)`. */ - fun llmBudgetTable(llmBudgetTable: Optional) = - llmBudgetTable(llmBudgetTable.getOrNull()) - - /** - * Sets [Builder.llmBudgetTable] to an arbitrary JSON value. - * - * You should usually call [Builder.llmBudgetTable] with a well-typed [LlmBudgetTable] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun llmBudgetTable(llmBudgetTable: JsonField) = apply { - this.llmBudgetTable = llmBudgetTable - } - - fun spend(spend: Double) = spend(JsonField.of(spend)) - - /** - * Sets [Builder.spend] to an arbitrary JSON value. - * - * You should usually call [Builder.spend] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun spend(spend: JsonField) = apply { this.spend = spend } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomerRetrieveInfoResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .blocked() - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CustomerRetrieveInfoResponse = - CustomerRetrieveInfoResponse( - checkRequired("blocked", blocked), - checkRequired("userId", userId), - alias, - allowedModelRegion, - defaultModel, - llmBudgetTable, - spend, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CustomerRetrieveInfoResponse = apply { - if (validated) { - return@apply - } - - blocked() - userId() - alias() - allowedModelRegion().ifPresent { it.validate() } - defaultModel() - llmBudgetTable().ifPresent { it.validate() } - spend() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (blocked.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) + - (if (alias.asKnown().isPresent) 1 else 0) + - (allowedModelRegion.asKnown().getOrNull()?.validity() ?: 0) + - (if (defaultModel.asKnown().isPresent) 1 else 0) + - (llmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + - (if (spend.asKnown().isPresent) 1 else 0) - - class AllowedModelRegion - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EU = of("eu") - - @JvmField val US = of("us") - - @JvmStatic fun of(value: String) = AllowedModelRegion(JsonField.of(value)) - } - - /** An enum containing [AllowedModelRegion]'s known values. */ - enum class Known { - EU, - US, - } - - /** - * An enum containing [AllowedModelRegion]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AllowedModelRegion] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EU, - US, - /** - * An enum member indicating that [AllowedModelRegion] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EU -> Value.EU - US -> Value.US - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws HanzoInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - EU -> Known.EU - US -> Known.US - else -> throw HanzoInvalidDataException("Unknown AllowedModelRegion: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws HanzoInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AllowedModelRegion = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AllowedModelRegion && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Represents user-controllable params for a LLM_BudgetTable record */ - class LlmBudgetTable - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val budgetDuration: JsonField, - private val maxBudget: JsonField, - private val maxParallelRequests: JsonField, - private val modelMaxBudget: JsonValue, - private val rpmLimit: JsonField, - private val softBudget: JsonField, - private val tpmLimit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("budget_duration") - @ExcludeMissing - budgetDuration: JsonField = JsonMissing.of(), - @JsonProperty("max_budget") - @ExcludeMissing - maxBudget: JsonField = JsonMissing.of(), - @JsonProperty("max_parallel_requests") - @ExcludeMissing - maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("model_max_budget") - @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), - @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), - @JsonProperty("soft_budget") - @ExcludeMissing - softBudget: JsonField = JsonMissing.of(), - @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), - ) : this( - budgetDuration, - maxBudget, - maxParallelRequests, - modelMaxBudget, - rpmLimit, - softBudget, - tpmLimit, - mutableMapOf(), - ) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun maxBudget(): Optional = maxBudget.getOptional("max_budget") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun maxParallelRequests(): Optional = - maxParallelRequests.getOptional("max_parallel_requests") - - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun softBudget(): Optional = softBudget.getOptional("soft_budget") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") - - /** - * Returns the raw JSON value of [budgetDuration]. - * - * Unlike [budgetDuration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("budget_duration") - @ExcludeMissing - fun _budgetDuration(): JsonField = budgetDuration - - /** - * Returns the raw JSON value of [maxBudget]. - * - * Unlike [maxBudget], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("max_budget") @ExcludeMissing fun _maxBudget(): JsonField = maxBudget - - /** - * Returns the raw JSON value of [maxParallelRequests]. - * - * Unlike [maxParallelRequests], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_parallel_requests") - @ExcludeMissing - fun _maxParallelRequests(): JsonField = maxParallelRequests - - /** - * Returns the raw JSON value of [rpmLimit]. - * - * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit - - /** - * Returns the raw JSON value of [softBudget]. - * - * Unlike [softBudget], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("soft_budget") - @ExcludeMissing - fun _softBudget(): JsonField = softBudget - - /** - * Returns the raw JSON value of [tpmLimit]. - * - * Unlike [tpmLimit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [LlmBudgetTable]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LlmBudgetTable]. */ - class Builder internal constructor() { - - private var budgetDuration: JsonField = JsonMissing.of() - private var maxBudget: JsonField = JsonMissing.of() - private var maxParallelRequests: JsonField = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var rpmLimit: JsonField = JsonMissing.of() - private var softBudget: JsonField = JsonMissing.of() - private var tpmLimit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(llmBudgetTable: LlmBudgetTable) = apply { - budgetDuration = llmBudgetTable.budgetDuration - maxBudget = llmBudgetTable.maxBudget - maxParallelRequests = llmBudgetTable.maxParallelRequests - modelMaxBudget = llmBudgetTable.modelMaxBudget - rpmLimit = llmBudgetTable.rpmLimit - softBudget = llmBudgetTable.softBudget - tpmLimit = llmBudgetTable.tpmLimit - additionalProperties = llmBudgetTable.additionalProperties.toMutableMap() - } - - fun budgetDuration(budgetDuration: String?) = - budgetDuration(JsonField.ofNullable(budgetDuration)) - - /** Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. */ - fun budgetDuration(budgetDuration: Optional) = - budgetDuration(budgetDuration.getOrNull()) - - /** - * Sets [Builder.budgetDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.budgetDuration] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun budgetDuration(budgetDuration: JsonField) = apply { - this.budgetDuration = budgetDuration - } - - fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) - - /** - * Alias for [Builder.maxBudget]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxBudget(maxBudget: Double) = maxBudget(maxBudget as Double?) - - /** Alias for calling [Builder.maxBudget] with `maxBudget.orElse(null)`. */ - fun maxBudget(maxBudget: Optional) = maxBudget(maxBudget.getOrNull()) - - /** - * Sets [Builder.maxBudget] to an arbitrary JSON value. - * - * You should usually call [Builder.maxBudget] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxBudget(maxBudget: JsonField) = apply { this.maxBudget = maxBudget } - - fun maxParallelRequests(maxParallelRequests: Long?) = - maxParallelRequests(JsonField.ofNullable(maxParallelRequests)) - - /** - * Alias for [Builder.maxParallelRequests]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxParallelRequests(maxParallelRequests: Long) = - maxParallelRequests(maxParallelRequests as Long?) - - /** - * Alias for calling [Builder.maxParallelRequests] with - * `maxParallelRequests.orElse(null)`. - */ - fun maxParallelRequests(maxParallelRequests: Optional) = - maxParallelRequests(maxParallelRequests.getOrNull()) - - /** - * Sets [Builder.maxParallelRequests] to an arbitrary JSON value. - * - * You should usually call [Builder.maxParallelRequests] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxParallelRequests(maxParallelRequests: JsonField) = apply { - this.maxParallelRequests = maxParallelRequests - } - - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { - this.modelMaxBudget = modelMaxBudget - } - - fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) - - /** - * Alias for [Builder.rpmLimit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rpmLimit(rpmLimit: Long) = rpmLimit(rpmLimit as Long?) - - /** Alias for calling [Builder.rpmLimit] with `rpmLimit.orElse(null)`. */ - fun rpmLimit(rpmLimit: Optional) = rpmLimit(rpmLimit.getOrNull()) - - /** - * Sets [Builder.rpmLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.rpmLimit] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } - - fun softBudget(softBudget: Double?) = softBudget(JsonField.ofNullable(softBudget)) - - /** - * Alias for [Builder.softBudget]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun softBudget(softBudget: Double) = softBudget(softBudget as Double?) - - /** Alias for calling [Builder.softBudget] with `softBudget.orElse(null)`. */ - fun softBudget(softBudget: Optional) = softBudget(softBudget.getOrNull()) - - /** - * Sets [Builder.softBudget] to an arbitrary JSON value. - * - * You should usually call [Builder.softBudget] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun softBudget(softBudget: JsonField) = apply { this.softBudget = softBudget } - - fun tpmLimit(tpmLimit: Long?) = tpmLimit(JsonField.ofNullable(tpmLimit)) - - /** - * Alias for [Builder.tpmLimit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun tpmLimit(tpmLimit: Long) = tpmLimit(tpmLimit as Long?) - - /** Alias for calling [Builder.tpmLimit] with `tpmLimit.orElse(null)`. */ - fun tpmLimit(tpmLimit: Optional) = tpmLimit(tpmLimit.getOrNull()) - - /** - * Sets [Builder.tpmLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.tpmLimit] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LlmBudgetTable]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LlmBudgetTable = - LlmBudgetTable( - budgetDuration, - maxBudget, - maxParallelRequests, - modelMaxBudget, - rpmLimit, - softBudget, - tpmLimit, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): LlmBudgetTable = apply { - if (validated) { - return@apply - } - - budgetDuration() - maxBudget() - maxParallelRequests() - rpmLimit() - softBudget() - tpmLimit() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (budgetDuration.asKnown().isPresent) 1 else 0) + - (if (maxBudget.asKnown().isPresent) 1 else 0) + - (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + - (if (rpmLimit.asKnown().isPresent) 1 else 0) + - (if (softBudget.asKnown().isPresent) 1 else 0) + - (if (tpmLimit.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LlmBudgetTable && - budgetDuration == other.budgetDuration && - maxBudget == other.maxBudget && - maxParallelRequests == other.maxParallelRequests && - modelMaxBudget == other.modelMaxBudget && - rpmLimit == other.rpmLimit && - softBudget == other.softBudget && - tpmLimit == other.tpmLimit && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - budgetDuration, - maxBudget, - maxParallelRequests, - modelMaxBudget, - rpmLimit, - softBudget, - tpmLimit, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LlmBudgetTable{budgetDuration=$budgetDuration, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, modelMaxBudget=$modelMaxBudget, rpmLimit=$rpmLimit, softBudget=$softBudget, tpmLimit=$tpmLimit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomerRetrieveInfoResponse && - blocked == other.blocked && - userId == other.userId && - alias == other.alias && - allowedModelRegion == other.allowedModelRegion && - defaultModel == other.defaultModel && - llmBudgetTable == other.llmBudgetTable && - spend == other.spend && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - blocked, - userId, - alias, - allowedModelRegion, - defaultModel, - llmBudgetTable, - spend, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerRetrieveInfoResponse{blocked=$blocked, userId=$userId, alias=$alias, allowedModelRegion=$allowedModelRegion, defaultModel=$defaultModel, llmBudgetTable=$llmBudgetTable, spend=$spend, additionalProperties=$additionalProperties}" -} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt index 03eba673..70a99ac8 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/CustomerUpdateParams.kt @@ -38,7 +38,7 @@ import kotlin.jvm.optionals.getOrNull * Example curl: * ``` * curl --location 'http://0.0.0.0:4000/customer/update' --header 'Authorization: Bearer sk-1234' --header 'Content-Type: application/json' --data '{ - * "user_id": "test-llm-user-4", + * "user_id": "test-litellm-user-4", * "budget_id": "paid_tier" * }' * diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/LiteLlmEndUserTable.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/LiteLlmEndUserTable.kt new file mode 100644 index 00000000..1ff936ed --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/customer/LiteLlmEndUserTable.kt @@ -0,0 +1,561 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.hanzo.api.models.customer + +import ai.hanzo.api.core.Enum +import ai.hanzo.api.core.ExcludeMissing +import ai.hanzo.api.core.JsonField +import ai.hanzo.api.core.JsonMissing +import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.errors.HanzoInvalidDataException +import ai.hanzo.api.models.organization.BudgetTable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LiteLlmEndUserTable +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val blocked: JsonField, + private val userId: JsonField, + private val alias: JsonField, + private val allowedModelRegion: JsonField, + private val defaultModel: JsonField, + private val litellmBudgetTable: JsonField, + private val spend: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("allowed_model_region") + @ExcludeMissing + allowedModelRegion: JsonField = JsonMissing.of(), + @JsonProperty("default_model") + @ExcludeMissing + defaultModel: JsonField = JsonMissing.of(), + @JsonProperty("litellm_budget_table") + @ExcludeMissing + litellmBudgetTable: JsonField = JsonMissing.of(), + @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), + ) : this( + blocked, + userId, + alias, + allowedModelRegion, + defaultModel, + litellmBudgetTable, + spend, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun blocked(): Boolean = blocked.getRequired("blocked") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alias(): Optional = alias.getOptional("alias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedModelRegion(): Optional = + allowedModelRegion.getOptional("allowed_model_region") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultModel(): Optional = defaultModel.getOptional("default_model") + + /** + * Represents user-controllable params for a LiteLLM_BudgetTable record + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmBudgetTable(): Optional = + litellmBudgetTable.getOptional("litellm_budget_table") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun spend(): Optional = spend.getOptional("spend") + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") @ExcludeMissing fun _blocked(): JsonField = blocked + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + + /** + * Returns the raw JSON value of [allowedModelRegion]. + * + * Unlike [allowedModelRegion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_model_region") + @ExcludeMissing + fun _allowedModelRegion(): JsonField = allowedModelRegion + + /** + * Returns the raw JSON value of [defaultModel]. + * + * Unlike [defaultModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("default_model") + @ExcludeMissing + fun _defaultModel(): JsonField = defaultModel + + /** + * Returns the raw JSON value of [litellmBudgetTable]. + * + * Unlike [litellmBudgetTable], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_budget_table") + @ExcludeMissing + fun _litellmBudgetTable(): JsonField = litellmBudgetTable + + /** + * Returns the raw JSON value of [spend]. + * + * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LiteLlmEndUserTable]. + * + * The following fields are required: + * ```java + * .blocked() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LiteLlmEndUserTable]. */ + class Builder internal constructor() { + + private var blocked: JsonField? = null + private var userId: JsonField? = null + private var alias: JsonField = JsonMissing.of() + private var allowedModelRegion: JsonField = JsonMissing.of() + private var defaultModel: JsonField = JsonMissing.of() + private var litellmBudgetTable: JsonField = JsonMissing.of() + private var spend: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(liteLlmEndUserTable: LiteLlmEndUserTable) = apply { + blocked = liteLlmEndUserTable.blocked + userId = liteLlmEndUserTable.userId + alias = liteLlmEndUserTable.alias + allowedModelRegion = liteLlmEndUserTable.allowedModelRegion + defaultModel = liteLlmEndUserTable.defaultModel + litellmBudgetTable = liteLlmEndUserTable.litellmBudgetTable + spend = liteLlmEndUserTable.spend + additionalProperties = liteLlmEndUserTable.additionalProperties.toMutableMap() + } + + fun blocked(blocked: Boolean) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun blocked(blocked: JsonField) = apply { this.blocked = blocked } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun alias(alias: String?) = alias(JsonField.ofNullable(alias)) + + /** Alias for calling [Builder.alias] with `alias.orElse(null)`. */ + fun alias(alias: Optional) = alias(alias.getOrNull()) + + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun alias(alias: JsonField) = apply { this.alias = alias } + + fun allowedModelRegion(allowedModelRegion: AllowedModelRegion?) = + allowedModelRegion(JsonField.ofNullable(allowedModelRegion)) + + /** + * Alias for calling [Builder.allowedModelRegion] with `allowedModelRegion.orElse(null)`. + */ + fun allowedModelRegion(allowedModelRegion: Optional) = + allowedModelRegion(allowedModelRegion.getOrNull()) + + /** + * Sets [Builder.allowedModelRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedModelRegion] with a well-typed + * [AllowedModelRegion] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedModelRegion(allowedModelRegion: JsonField) = apply { + this.allowedModelRegion = allowedModelRegion + } + + fun defaultModel(defaultModel: String?) = defaultModel(JsonField.ofNullable(defaultModel)) + + /** Alias for calling [Builder.defaultModel] with `defaultModel.orElse(null)`. */ + fun defaultModel(defaultModel: Optional) = defaultModel(defaultModel.getOrNull()) + + /** + * Sets [Builder.defaultModel] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun defaultModel(defaultModel: JsonField) = apply { + this.defaultModel = defaultModel + } + + /** Represents user-controllable params for a LiteLLM_BudgetTable record */ + fun litellmBudgetTable(litellmBudgetTable: BudgetTable?) = + litellmBudgetTable(JsonField.ofNullable(litellmBudgetTable)) + + /** + * Alias for calling [Builder.litellmBudgetTable] with `litellmBudgetTable.orElse(null)`. + */ + fun litellmBudgetTable(litellmBudgetTable: Optional) = + litellmBudgetTable(litellmBudgetTable.getOrNull()) + + /** + * Sets [Builder.litellmBudgetTable] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmBudgetTable] with a well-typed [BudgetTable] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun litellmBudgetTable(litellmBudgetTable: JsonField) = apply { + this.litellmBudgetTable = litellmBudgetTable + } + + fun spend(spend: Double) = spend(JsonField.of(spend)) + + /** + * Sets [Builder.spend] to an arbitrary JSON value. + * + * You should usually call [Builder.spend] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun spend(spend: JsonField) = apply { this.spend = spend } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LiteLlmEndUserTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .blocked() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LiteLlmEndUserTable = + LiteLlmEndUserTable( + checkRequired("blocked", blocked), + checkRequired("userId", userId), + alias, + allowedModelRegion, + defaultModel, + litellmBudgetTable, + spend, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LiteLlmEndUserTable = apply { + if (validated) { + return@apply + } + + blocked() + userId() + alias() + allowedModelRegion().ifPresent { it.validate() } + defaultModel() + litellmBudgetTable().ifPresent { it.validate() } + spend() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (alias.asKnown().isPresent) 1 else 0) + + (allowedModelRegion.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultModel.asKnown().isPresent) 1 else 0) + + (litellmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + class AllowedModelRegion + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EU = of("eu") + + @JvmField val US = of("us") + + @JvmStatic fun of(value: String) = AllowedModelRegion(JsonField.of(value)) + } + + /** An enum containing [AllowedModelRegion]'s known values. */ + enum class Known { + EU, + US, + } + + /** + * An enum containing [AllowedModelRegion]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AllowedModelRegion] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EU, + US, + /** + * An enum member indicating that [AllowedModelRegion] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + EU -> Value.EU + US -> Value.US + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + EU -> Known.EU + US -> Known.US + else -> throw HanzoInvalidDataException("Unknown AllowedModelRegion: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): AllowedModelRegion = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedModelRegion && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LiteLlmEndUserTable && + blocked == other.blocked && + userId == other.userId && + alias == other.alias && + allowedModelRegion == other.allowedModelRegion && + defaultModel == other.defaultModel && + litellmBudgetTable == other.litellmBudgetTable && + spend == other.spend && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + blocked, + userId, + alias, + allowedModelRegion, + defaultModel, + litellmBudgetTable, + spend, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LiteLlmEndUserTable{blocked=$blocked, userId=$userId, alias=$alias, allowedModelRegion=$allowedModelRegion, defaultModel=$defaultModel, litellmBudgetTable=$litellmBudgetTable, spend=$spend, additionalProperties=$additionalProperties}" +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt index 4e05feb8..351c93d4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/embeddings/EmbeddingCreateParams.kt @@ -2,11 +2,33 @@ package ai.hanzo.api.models.embeddings +import ai.hanzo.api.core.BaseDeserializer +import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.ExcludeMissing +import ai.hanzo.api.core.JsonField +import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.allMaxBy +import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable +import ai.hanzo.api.errors.HanzoInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -27,16 +49,183 @@ import kotlin.jvm.optionals.getOrNull */ class EmbeddingCreateParams private constructor( - private val model: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { - fun model(): Optional = Optional.ofNullable(model) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun model(): String = body.model() - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiBase(): Optional = body.apiBase() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiKey(): Optional = body.apiKey() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiType(): Optional = body.apiType() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiVersion(): Optional = body.apiVersion() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = body.caching() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customLlmProvider(): Optional = body.customLlmProvider() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun input(): Optional> = body.input() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmCallId(): Optional = body.litellmCallId() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmLoggingObj(): Optional = body.litellmLoggingObj() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loggerFn(): Optional = body.loggerFn() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = body.timeout() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = body.user() + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _model(): JsonField = body._model() + + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiBase(): JsonField = body._apiBase() + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiKey(): JsonField = body._apiKey() + + /** + * Returns the raw JSON value of [apiType]. + * + * Unlike [apiType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiType(): JsonField = body._apiType() + + /** + * Returns the raw JSON value of [apiVersion]. + * + * Unlike [apiVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiVersion(): JsonField = body._apiVersion() + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _caching(): JsonField = body._caching() + + /** + * Returns the raw JSON value of [customLlmProvider]. + * + * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _customLlmProvider(): JsonField = body._customLlmProvider() + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _input(): JsonField> = body._input() + + /** + * Returns the raw JSON value of [litellmCallId]. + * + * Unlike [litellmCallId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _litellmCallId(): JsonField = body._litellmCallId() + + /** + * Returns the raw JSON value of [litellmLoggingObj]. + * + * Unlike [litellmLoggingObj], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _litellmLoggingObj(): JsonField = body._litellmLoggingObj() + + /** + * Returns the raw JSON value of [loggerFn]. + * + * Unlike [loggerFn], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _loggerFn(): JsonField = body._loggerFn() + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _timeout(): JsonField = body._timeout() + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _user(): JsonField = body._user() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -48,32 +237,256 @@ private constructor( companion object { - @JvmStatic fun none(): EmbeddingCreateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [EmbeddingCreateParams]. */ + /** + * Returns a mutable builder for constructing an instance of [EmbeddingCreateParams]. + * + * The following fields are required: + * ```java + * .model() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [EmbeddingCreateParams]. */ class Builder internal constructor() { - private var model: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(embeddingCreateParams: EmbeddingCreateParams) = apply { - model = embeddingCreateParams.model + body = embeddingCreateParams.body.toBuilder() additionalHeaders = embeddingCreateParams.additionalHeaders.toBuilder() additionalQueryParams = embeddingCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = embeddingCreateParams.additionalBodyProperties.toMutableMap() } - fun model(model: String?) = apply { this.model = model } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [model] + * - [apiBase] + * - [apiKey] + * - [apiType] + * - [apiVersion] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun model(model: String) = apply { body.model(model) } + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField) = apply { body.model(model) } + + fun apiBase(apiBase: String?) = apply { body.apiBase(apiBase) } + + /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ + fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun apiBase(apiBase: JsonField) = apply { body.apiBase(apiBase) } + + fun apiKey(apiKey: String?) = apply { body.apiKey(apiKey) } + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun apiKey(apiKey: JsonField) = apply { body.apiKey(apiKey) } + + fun apiType(apiType: String?) = apply { body.apiType(apiType) } + + /** Alias for calling [Builder.apiType] with `apiType.orElse(null)`. */ + fun apiType(apiType: Optional) = apiType(apiType.getOrNull()) + + /** + * Sets [Builder.apiType] to an arbitrary JSON value. + * + * You should usually call [Builder.apiType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun apiType(apiType: JsonField) = apply { body.apiType(apiType) } + + fun apiVersion(apiVersion: String?) = apply { body.apiVersion(apiVersion) } + + /** Alias for calling [Builder.apiVersion] with `apiVersion.orElse(null)`. */ + fun apiVersion(apiVersion: Optional) = apiVersion(apiVersion.getOrNull()) - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) + /** + * Sets [Builder.apiVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.apiVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun apiVersion(apiVersion: JsonField) = apply { body.apiVersion(apiVersion) } + + fun caching(caching: Boolean) = apply { body.caching(caching) } + + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun caching(caching: JsonField) = apply { body.caching(caching) } + + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = apply { + body.customLlmProvider(customLlmProvider) + } + + /** Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + + /** + * Sets [Builder.customLlmProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.customLlmProvider] with a well-typed [CustomLlmProvider] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customLlmProvider(customLlmProvider: JsonField) = apply { + body.customLlmProvider(customLlmProvider) + } + + /** Alias for calling [customLlmProvider] with `CustomLlmProvider.ofString(string)`. */ + fun customLlmProvider(string: String) = apply { body.customLlmProvider(string) } + + /** + * Alias for calling [customLlmProvider] with + * `CustomLlmProvider.ofUnionMember1(unionMember1)`. + */ + fun customLlmProvider(unionMember1: CustomLlmProvider.UnionMember1) = apply { + body.customLlmProvider(unionMember1) + } + + fun input(input: List) = apply { body.input(input) } + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun input(input: JsonField>) = apply { body.input(input) } + + /** + * Adds a single [String] to [Builder.input]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInput(input: String) = apply { body.addInput(input) } + + fun litellmCallId(litellmCallId: String?) = apply { body.litellmCallId(litellmCallId) } + + /** Alias for calling [Builder.litellmCallId] with `litellmCallId.orElse(null)`. */ + fun litellmCallId(litellmCallId: Optional) = + litellmCallId(litellmCallId.getOrNull()) + + /** + * Sets [Builder.litellmCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmCallId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun litellmCallId(litellmCallId: JsonField) = apply { + body.litellmCallId(litellmCallId) + } + + fun litellmLoggingObj(litellmLoggingObj: LitellmLoggingObj?) = apply { + body.litellmLoggingObj(litellmLoggingObj) + } + + /** Alias for calling [Builder.litellmLoggingObj] with `litellmLoggingObj.orElse(null)`. */ + fun litellmLoggingObj(litellmLoggingObj: Optional) = + litellmLoggingObj(litellmLoggingObj.getOrNull()) + + /** + * Sets [Builder.litellmLoggingObj] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmLoggingObj] with a well-typed [LitellmLoggingObj] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun litellmLoggingObj(litellmLoggingObj: JsonField) = apply { + body.litellmLoggingObj(litellmLoggingObj) + } + + fun loggerFn(loggerFn: String?) = apply { body.loggerFn(loggerFn) } + + /** Alias for calling [Builder.loggerFn] with `loggerFn.orElse(null)`. */ + fun loggerFn(loggerFn: Optional) = loggerFn(loggerFn.getOrNull()) + + /** + * Sets [Builder.loggerFn] to an arbitrary JSON value. + * + * You should usually call [Builder.loggerFn] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loggerFn(loggerFn: JsonField) = apply { body.loggerFn(loggerFn) } + + fun timeout(timeout: Long) = apply { body.timeout(timeout) } + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } + + fun user(user: String?) = apply { body.user(user) } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun user(user: JsonField) = apply { body.user(user) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -173,54 +586,1077 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) + /** + * Returns an immutable instance of [EmbeddingCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .model() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmbeddingCreateParams = + EmbeddingCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val model: JsonField, + private val apiBase: JsonField, + private val apiKey: JsonField, + private val apiType: JsonField, + private val apiVersion: JsonField, + private val caching: JsonField, + private val customLlmProvider: JsonField, + private val input: JsonField>, + private val litellmCallId: JsonField, + private val litellmLoggingObj: JsonField, + private val loggerFn: JsonField, + private val timeout: JsonField, + private val user: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("api_base") @ExcludeMissing apiBase: JsonField = JsonMissing.of(), + @JsonProperty("api_key") @ExcludeMissing apiKey: JsonField = JsonMissing.of(), + @JsonProperty("api_type") @ExcludeMissing apiType: JsonField = JsonMissing.of(), + @JsonProperty("api_version") + @ExcludeMissing + apiVersion: JsonField = JsonMissing.of(), + @JsonProperty("caching") @ExcludeMissing caching: JsonField = JsonMissing.of(), + @JsonProperty("custom_llm_provider") + @ExcludeMissing + customLlmProvider: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField> = JsonMissing.of(), + @JsonProperty("litellm_call_id") + @ExcludeMissing + litellmCallId: JsonField = JsonMissing.of(), + @JsonProperty("litellm_logging_obj") + @ExcludeMissing + litellmLoggingObj: JsonField = JsonMissing.of(), + @JsonProperty("logger_fn") + @ExcludeMissing + loggerFn: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonField = JsonMissing.of(), + ) : this( + model, + apiBase, + apiKey, + apiType, + apiVersion, + caching, + customLlmProvider, + input, + litellmCallId, + litellmLoggingObj, + loggerFn, + timeout, + user, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun model(): String = model.getRequired("model") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiBase(): Optional = apiBase.getOptional("api_base") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("api_key") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiType(): Optional = apiType.getOptional("api_type") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiVersion(): Optional = apiVersion.getOptional("api_version") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = caching.getOptional("caching") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customLlmProvider(): Optional = + customLlmProvider.getOptional("custom_llm_provider") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun input(): Optional> = input.getOptional("input") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmCallId(): Optional = litellmCallId.getOptional("litellm_call_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmLoggingObj(): Optional = + litellmLoggingObj.getOptional("litellm_logging_obj") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loggerFn(): Optional = loggerFn.getOptional("logger_fn") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = user.getOptional("user") + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_base") @ExcludeMissing fun _apiBase(): JsonField = apiBase + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [apiType]. + * + * Unlike [apiType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_type") @ExcludeMissing fun _apiType(): JsonField = apiType + + /** + * Returns the raw JSON value of [apiVersion]. + * + * Unlike [apiVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_version") + @ExcludeMissing + fun _apiVersion(): JsonField = apiVersion + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caching") @ExcludeMissing fun _caching(): JsonField = caching + + /** + * Returns the raw JSON value of [customLlmProvider]. + * + * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_llm_provider") + @ExcludeMissing + fun _customLlmProvider(): JsonField = customLlmProvider + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField> = input + + /** + * Returns the raw JSON value of [litellmCallId]. + * + * Unlike [litellmCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_call_id") + @ExcludeMissing + fun _litellmCallId(): JsonField = litellmCallId + + /** + * Returns the raw JSON value of [litellmLoggingObj]. + * + * Unlike [litellmLoggingObj], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_logging_obj") + @ExcludeMissing + fun _litellmLoggingObj(): JsonField = litellmLoggingObj + + /** + * Returns the raw JSON value of [loggerFn]. + * + * Unlike [loggerFn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logger_fn") @ExcludeMissing fun _loggerFn(): JsonField = loggerFn + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonField = user + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .model() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var model: JsonField? = null + private var apiBase: JsonField = JsonMissing.of() + private var apiKey: JsonField = JsonMissing.of() + private var apiType: JsonField = JsonMissing.of() + private var apiVersion: JsonField = JsonMissing.of() + private var caching: JsonField = JsonMissing.of() + private var customLlmProvider: JsonField = JsonMissing.of() + private var input: JsonField>? = null + private var litellmCallId: JsonField = JsonMissing.of() + private var litellmLoggingObj: JsonField = JsonMissing.of() + private var loggerFn: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var user: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + model = body.model + apiBase = body.apiBase + apiKey = body.apiKey + apiType = body.apiType + apiVersion = body.apiVersion + caching = body.caching + customLlmProvider = body.customLlmProvider + input = body.input.map { it.toMutableList() } + litellmCallId = body.litellmCallId + litellmLoggingObj = body.litellmLoggingObj + loggerFn = body.loggerFn + timeout = body.timeout + user = body.user + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun model(model: String) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + fun apiBase(apiBase: String?) = apiBase(JsonField.ofNullable(apiBase)) + + /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ + fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } + + fun apiKey(apiKey: String?) = apiKey(JsonField.ofNullable(apiKey)) + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + fun apiType(apiType: String?) = apiType(JsonField.ofNullable(apiType)) + + /** Alias for calling [Builder.apiType] with `apiType.orElse(null)`. */ + fun apiType(apiType: Optional) = apiType(apiType.getOrNull()) + + /** + * Sets [Builder.apiType] to an arbitrary JSON value. + * + * You should usually call [Builder.apiType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiType(apiType: JsonField) = apply { this.apiType = apiType } + + fun apiVersion(apiVersion: String?) = apiVersion(JsonField.ofNullable(apiVersion)) + + /** Alias for calling [Builder.apiVersion] with `apiVersion.orElse(null)`. */ + fun apiVersion(apiVersion: Optional) = apiVersion(apiVersion.getOrNull()) + + /** + * Sets [Builder.apiVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.apiVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiVersion(apiVersion: JsonField) = apply { this.apiVersion = apiVersion } + + fun caching(caching: Boolean) = caching(JsonField.of(caching)) + + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caching(caching: JsonField) = apply { this.caching = caching } + + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = + customLlmProvider(JsonField.ofNullable(customLlmProvider)) + + /** + * Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. + */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + + /** + * Sets [Builder.customLlmProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.customLlmProvider] with a well-typed + * [CustomLlmProvider] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customLlmProvider(customLlmProvider: JsonField) = apply { + this.customLlmProvider = customLlmProvider + } + + /** Alias for calling [customLlmProvider] with `CustomLlmProvider.ofString(string)`. */ + fun customLlmProvider(string: String) = + customLlmProvider(CustomLlmProvider.ofString(string)) + + /** + * Alias for calling [customLlmProvider] with + * `CustomLlmProvider.ofUnionMember1(unionMember1)`. + */ + fun customLlmProvider(unionMember1: CustomLlmProvider.UnionMember1) = + customLlmProvider(CustomLlmProvider.ofUnionMember1(unionMember1)) + + fun input(input: List) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField>) = apply { + this.input = input.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.input]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInput(input: String) = apply { + this.input = + (this.input ?: JsonField.of(mutableListOf())).also { + checkKnown("input", it).add(input) + } + } + + fun litellmCallId(litellmCallId: String?) = + litellmCallId(JsonField.ofNullable(litellmCallId)) + + /** Alias for calling [Builder.litellmCallId] with `litellmCallId.orElse(null)`. */ + fun litellmCallId(litellmCallId: Optional) = + litellmCallId(litellmCallId.getOrNull()) + + /** + * Sets [Builder.litellmCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun litellmCallId(litellmCallId: JsonField) = apply { + this.litellmCallId = litellmCallId + } + + fun litellmLoggingObj(litellmLoggingObj: LitellmLoggingObj?) = + litellmLoggingObj(JsonField.ofNullable(litellmLoggingObj)) + + /** + * Alias for calling [Builder.litellmLoggingObj] with `litellmLoggingObj.orElse(null)`. + */ + fun litellmLoggingObj(litellmLoggingObj: Optional) = + litellmLoggingObj(litellmLoggingObj.getOrNull()) + + /** + * Sets [Builder.litellmLoggingObj] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmLoggingObj] with a well-typed + * [LitellmLoggingObj] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun litellmLoggingObj(litellmLoggingObj: JsonField) = apply { + this.litellmLoggingObj = litellmLoggingObj + } + + fun loggerFn(loggerFn: String?) = loggerFn(JsonField.ofNullable(loggerFn)) + + /** Alias for calling [Builder.loggerFn] with `loggerFn.orElse(null)`. */ + fun loggerFn(loggerFn: Optional) = loggerFn(loggerFn.getOrNull()) + + /** + * Sets [Builder.loggerFn] to an arbitrary JSON value. + * + * You should usually call [Builder.loggerFn] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun loggerFn(loggerFn: JsonField) = apply { this.loggerFn = loggerFn } + + fun timeout(timeout: Long) = timeout(JsonField.of(timeout)) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun user(user: String?) = user(JsonField.ofNullable(user)) + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun user(user: JsonField) = apply { this.user = user } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .model() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("model", model), + apiBase, + apiKey, + apiType, + apiVersion, + caching, + customLlmProvider, + (input ?: JsonMissing.of()).map { it.toImmutable() }, + litellmCallId, + litellmLoggingObj, + loggerFn, + timeout, + user, + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + model() + apiBase() + apiKey() + apiType() + apiVersion() + caching() + customLlmProvider().ifPresent { it.validate() } + input() + litellmCallId() + litellmLoggingObj().ifPresent { it.validate() } + loggerFn() + timeout() + user() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + /** - * Returns an immutable instance of [EmbeddingCreateParams]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): EmbeddingCreateParams = - EmbeddingCreateParams( + @JvmSynthetic + internal fun validity(): Int = + (if (model.asKnown().isPresent) 1 else 0) + + (if (apiBase.asKnown().isPresent) 1 else 0) + + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (apiType.asKnown().isPresent) 1 else 0) + + (if (apiVersion.asKnown().isPresent) 1 else 0) + + (if (caching.asKnown().isPresent) 1 else 0) + + (customLlmProvider.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.size ?: 0) + + (if (litellmCallId.asKnown().isPresent) 1 else 0) + + (litellmLoggingObj.asKnown().getOrNull()?.validity() ?: 0) + + (if (loggerFn.asKnown().isPresent) 1 else 0) + + (if (timeout.asKnown().isPresent) 1 else 0) + + (if (user.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + model == other.model && + apiBase == other.apiBase && + apiKey == other.apiKey && + apiType == other.apiType && + apiVersion == other.apiVersion && + caching == other.caching && + customLlmProvider == other.customLlmProvider && + input == other.input && + litellmCallId == other.litellmCallId && + litellmLoggingObj == other.litellmLoggingObj && + loggerFn == other.loggerFn && + timeout == other.timeout && + user == other.user && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( model, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + apiBase, + apiKey, + apiType, + apiVersion, + caching, + customLlmProvider, + input, + litellmCallId, + litellmLoggingObj, + loggerFn, + timeout, + user, + additionalProperties, ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{model=$model, apiBase=$apiBase, apiKey=$apiKey, apiType=$apiType, apiVersion=$apiVersion, caching=$caching, customLlmProvider=$customLlmProvider, input=$input, litellmCallId=$litellmCallId, litellmLoggingObj=$litellmLoggingObj, loggerFn=$loggerFn, timeout=$timeout, user=$user, additionalProperties=$additionalProperties}" } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + @JsonDeserialize(using = CustomLlmProvider.Deserializer::class) + @JsonSerialize(using = CustomLlmProvider.Serializer::class) + class CustomLlmProvider + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { - override fun _headers(): Headers = additionalHeaders + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CustomLlmProvider = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomLlmProvider && + string == other.string && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "CustomLlmProvider{string=$string}" + unionMember1 != null -> "CustomLlmProvider{unionMember1=$unionMember1}" + _json != null -> "CustomLlmProvider{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CustomLlmProvider") + } + + companion object { + + @JvmStatic fun ofString(string: String) = CustomLlmProvider(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + CustomLlmProvider(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [CustomLlmProvider] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [CustomLlmProvider] to a value of type [T]. + * + * An instance of [CustomLlmProvider] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CustomLlmProvider: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CustomLlmProvider::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CustomLlmProvider { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + CustomLlmProvider(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + CustomLlmProvider(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> CustomLlmProvider(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(CustomLlmProvider::class) { + + override fun serialize( + value: CustomLlmProvider, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CustomLlmProvider") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - model?.let { put("model", it) } - putAll(additionalQueryParams) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + class LitellmLoggingObj + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LitellmLoggingObj]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LitellmLoggingObj]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(litellmLoggingObj: LitellmLoggingObj) = apply { + additionalProperties = litellmLoggingObj.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LitellmLoggingObj]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LitellmLoggingObj = LitellmLoggingObj(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LitellmLoggingObj = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - .build() + + return other is LitellmLoggingObj && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LitellmLoggingObj{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -228,15 +1664,13 @@ private constructor( } return other is EmbeddingCreateParams && - model == other.model && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = - Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "EmbeddingCreateParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EmbeddingCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt index 505e406a..ab7b67a4 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/EngineEmbedParams.kt @@ -2,11 +2,33 @@ package ai.hanzo.api.models.engines +import ai.hanzo.api.core.BaseDeserializer +import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.ExcludeMissing +import ai.hanzo.api.core.JsonField +import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.allMaxBy +import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable +import ai.hanzo.api.errors.HanzoInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -27,16 +49,186 @@ import kotlin.jvm.optionals.getOrNull */ class EngineEmbedParams private constructor( - private val model: String?, + private val pathModel: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { - fun model(): Optional = Optional.ofNullable(model) + fun pathModel(): Optional = Optional.ofNullable(pathModel) - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun bodyModel(): String = body.bodyModel() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiBase(): Optional = body.apiBase() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiKey(): Optional = body.apiKey() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiType(): Optional = body.apiType() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiVersion(): Optional = body.apiVersion() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = body.caching() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customLlmProvider(): Optional = body.customLlmProvider() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun input(): Optional> = body.input() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmCallId(): Optional = body.litellmCallId() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmLoggingObj(): Optional = body.litellmLoggingObj() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loggerFn(): Optional = body.loggerFn() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = body.timeout() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = body.user() + + /** + * Returns the raw JSON value of [bodyModel]. + * + * Unlike [bodyModel], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bodyModel(): JsonField = body._bodyModel() + + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiBase(): JsonField = body._apiBase() + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiKey(): JsonField = body._apiKey() + + /** + * Returns the raw JSON value of [apiType]. + * + * Unlike [apiType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiType(): JsonField = body._apiType() + + /** + * Returns the raw JSON value of [apiVersion]. + * + * Unlike [apiVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _apiVersion(): JsonField = body._apiVersion() + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _caching(): JsonField = body._caching() + + /** + * Returns the raw JSON value of [customLlmProvider]. + * + * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _customLlmProvider(): JsonField = body._customLlmProvider() + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _input(): JsonField> = body._input() + + /** + * Returns the raw JSON value of [litellmCallId]. + * + * Unlike [litellmCallId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _litellmCallId(): JsonField = body._litellmCallId() + + /** + * Returns the raw JSON value of [litellmLoggingObj]. + * + * Unlike [litellmLoggingObj], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _litellmLoggingObj(): JsonField = body._litellmLoggingObj() + + /** + * Returns the raw JSON value of [loggerFn]. + * + * Unlike [loggerFn], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _loggerFn(): JsonField = body._loggerFn() + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _timeout(): JsonField = body._timeout() + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _user(): JsonField = body._user() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -48,32 +240,264 @@ private constructor( companion object { - @JvmStatic fun none(): EngineEmbedParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [EngineEmbedParams]. */ + /** + * Returns a mutable builder for constructing an instance of [EngineEmbedParams]. + * + * The following fields are required: + * ```java + * .bodyModel() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [EngineEmbedParams]. */ class Builder internal constructor() { - private var model: String? = null + private var pathModel: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(engineEmbedParams: EngineEmbedParams) = apply { - model = engineEmbedParams.model + pathModel = engineEmbedParams.pathModel + body = engineEmbedParams.body.toBuilder() additionalHeaders = engineEmbedParams.additionalHeaders.toBuilder() additionalQueryParams = engineEmbedParams.additionalQueryParams.toBuilder() - additionalBodyProperties = engineEmbedParams.additionalBodyProperties.toMutableMap() } - fun model(model: String?) = apply { this.model = model } + fun pathModel(pathModel: String?) = apply { this.pathModel = pathModel } + + /** Alias for calling [Builder.pathModel] with `pathModel.orElse(null)`. */ + fun pathModel(pathModel: Optional) = pathModel(pathModel.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [bodyModel] + * - [apiBase] + * - [apiKey] + * - [apiType] + * - [apiVersion] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun bodyModel(bodyModel: String) = apply { body.bodyModel(bodyModel) } + + /** + * Sets [Builder.bodyModel] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bodyModel(bodyModel: JsonField) = apply { body.bodyModel(bodyModel) } + + fun apiBase(apiBase: String?) = apply { body.apiBase(apiBase) } + + /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ + fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun apiBase(apiBase: JsonField) = apply { body.apiBase(apiBase) } + + fun apiKey(apiKey: String?) = apply { body.apiKey(apiKey) } + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun apiKey(apiKey: JsonField) = apply { body.apiKey(apiKey) } + + fun apiType(apiType: String?) = apply { body.apiType(apiType) } + + /** Alias for calling [Builder.apiType] with `apiType.orElse(null)`. */ + fun apiType(apiType: Optional) = apiType(apiType.getOrNull()) + + /** + * Sets [Builder.apiType] to an arbitrary JSON value. + * + * You should usually call [Builder.apiType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun apiType(apiType: JsonField) = apply { body.apiType(apiType) } + + fun apiVersion(apiVersion: String?) = apply { body.apiVersion(apiVersion) } + + /** Alias for calling [Builder.apiVersion] with `apiVersion.orElse(null)`. */ + fun apiVersion(apiVersion: Optional) = apiVersion(apiVersion.getOrNull()) + + /** + * Sets [Builder.apiVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.apiVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun apiVersion(apiVersion: JsonField) = apply { body.apiVersion(apiVersion) } + + fun caching(caching: Boolean) = apply { body.caching(caching) } + + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun caching(caching: JsonField) = apply { body.caching(caching) } + + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = apply { + body.customLlmProvider(customLlmProvider) + } + + /** Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + + /** + * Sets [Builder.customLlmProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.customLlmProvider] with a well-typed [CustomLlmProvider] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customLlmProvider(customLlmProvider: JsonField) = apply { + body.customLlmProvider(customLlmProvider) + } + + /** Alias for calling [customLlmProvider] with `CustomLlmProvider.ofString(string)`. */ + fun customLlmProvider(string: String) = apply { body.customLlmProvider(string) } + + /** + * Alias for calling [customLlmProvider] with + * `CustomLlmProvider.ofUnionMember1(unionMember1)`. + */ + fun customLlmProvider(unionMember1: CustomLlmProvider.UnionMember1) = apply { + body.customLlmProvider(unionMember1) + } + + fun input(input: List) = apply { body.input(input) } + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun input(input: JsonField>) = apply { body.input(input) } + + /** + * Adds a single [String] to [Builder.input]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInput(input: String) = apply { body.addInput(input) } + + fun litellmCallId(litellmCallId: String?) = apply { body.litellmCallId(litellmCallId) } + + /** Alias for calling [Builder.litellmCallId] with `litellmCallId.orElse(null)`. */ + fun litellmCallId(litellmCallId: Optional) = + litellmCallId(litellmCallId.getOrNull()) + + /** + * Sets [Builder.litellmCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmCallId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun litellmCallId(litellmCallId: JsonField) = apply { + body.litellmCallId(litellmCallId) + } + + fun litellmLoggingObj(litellmLoggingObj: LitellmLoggingObj?) = apply { + body.litellmLoggingObj(litellmLoggingObj) + } + + /** Alias for calling [Builder.litellmLoggingObj] with `litellmLoggingObj.orElse(null)`. */ + fun litellmLoggingObj(litellmLoggingObj: Optional) = + litellmLoggingObj(litellmLoggingObj.getOrNull()) + + /** + * Sets [Builder.litellmLoggingObj] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmLoggingObj] with a well-typed [LitellmLoggingObj] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun litellmLoggingObj(litellmLoggingObj: JsonField) = apply { + body.litellmLoggingObj(litellmLoggingObj) + } + + fun loggerFn(loggerFn: String?) = apply { body.loggerFn(loggerFn) } + + /** Alias for calling [Builder.loggerFn] with `loggerFn.orElse(null)`. */ + fun loggerFn(loggerFn: Optional) = loggerFn(loggerFn.getOrNull()) + + /** + * Sets [Builder.loggerFn] to an arbitrary JSON value. + * + * You should usually call [Builder.loggerFn] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loggerFn(loggerFn: JsonField) = apply { body.loggerFn(loggerFn) } + + fun timeout(timeout: Long) = apply { body.timeout(timeout) } + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } + + fun user(user: String?) = apply { body.user(user) } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun user(user: JsonField) = apply { body.user(user) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -173,48 +597,32 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - /** * Returns an immutable instance of [EngineEmbedParams]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bodyModel() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): EngineEmbedParams = EngineEmbedParams( - model, + pathModel, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { - 0 -> model ?: "" + 0 -> pathModel ?: "" else -> "" } @@ -222,21 +630,1067 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bodyModel: JsonField, + private val apiBase: JsonField, + private val apiKey: JsonField, + private val apiType: JsonField, + private val apiVersion: JsonField, + private val caching: JsonField, + private val customLlmProvider: JsonField, + private val input: JsonField>, + private val litellmCallId: JsonField, + private val litellmLoggingObj: JsonField, + private val loggerFn: JsonField, + private val timeout: JsonField, + private val user: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("model") @ExcludeMissing bodyModel: JsonField = JsonMissing.of(), + @JsonProperty("api_base") @ExcludeMissing apiBase: JsonField = JsonMissing.of(), + @JsonProperty("api_key") @ExcludeMissing apiKey: JsonField = JsonMissing.of(), + @JsonProperty("api_type") @ExcludeMissing apiType: JsonField = JsonMissing.of(), + @JsonProperty("api_version") + @ExcludeMissing + apiVersion: JsonField = JsonMissing.of(), + @JsonProperty("caching") @ExcludeMissing caching: JsonField = JsonMissing.of(), + @JsonProperty("custom_llm_provider") + @ExcludeMissing + customLlmProvider: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField> = JsonMissing.of(), + @JsonProperty("litellm_call_id") + @ExcludeMissing + litellmCallId: JsonField = JsonMissing.of(), + @JsonProperty("litellm_logging_obj") + @ExcludeMissing + litellmLoggingObj: JsonField = JsonMissing.of(), + @JsonProperty("logger_fn") + @ExcludeMissing + loggerFn: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonField = JsonMissing.of(), + ) : this( + bodyModel, + apiBase, + apiKey, + apiType, + apiVersion, + caching, + customLlmProvider, + input, + litellmCallId, + litellmLoggingObj, + loggerFn, + timeout, + user, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bodyModel(): String = bodyModel.getRequired("model") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiBase(): Optional = apiBase.getOptional("api_base") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("api_key") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiType(): Optional = apiType.getOptional("api_type") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiVersion(): Optional = apiVersion.getOptional("api_version") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = caching.getOptional("caching") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customLlmProvider(): Optional = + customLlmProvider.getOptional("custom_llm_provider") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun input(): Optional> = input.getOptional("input") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmCallId(): Optional = litellmCallId.getOptional("litellm_call_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmLoggingObj(): Optional = + litellmLoggingObj.getOptional("litellm_logging_obj") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loggerFn(): Optional = loggerFn.getOptional("logger_fn") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = user.getOptional("user") + + /** + * Returns the raw JSON value of [bodyModel]. + * + * Unlike [bodyModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _bodyModel(): JsonField = bodyModel + + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_base") @ExcludeMissing fun _apiBase(): JsonField = apiBase + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [apiType]. + * + * Unlike [apiType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_type") @ExcludeMissing fun _apiType(): JsonField = apiType + + /** + * Returns the raw JSON value of [apiVersion]. + * + * Unlike [apiVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_version") + @ExcludeMissing + fun _apiVersion(): JsonField = apiVersion + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caching") @ExcludeMissing fun _caching(): JsonField = caching + + /** + * Returns the raw JSON value of [customLlmProvider]. + * + * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_llm_provider") + @ExcludeMissing + fun _customLlmProvider(): JsonField = customLlmProvider + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField> = input + + /** + * Returns the raw JSON value of [litellmCallId]. + * + * Unlike [litellmCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_call_id") + @ExcludeMissing + fun _litellmCallId(): JsonField = litellmCallId + + /** + * Returns the raw JSON value of [litellmLoggingObj]. + * + * Unlike [litellmLoggingObj], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_logging_obj") + @ExcludeMissing + fun _litellmLoggingObj(): JsonField = litellmLoggingObj + + /** + * Returns the raw JSON value of [loggerFn]. + * + * Unlike [loggerFn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logger_fn") @ExcludeMissing fun _loggerFn(): JsonField = loggerFn + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonField = user + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .bodyModel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var bodyModel: JsonField? = null + private var apiBase: JsonField = JsonMissing.of() + private var apiKey: JsonField = JsonMissing.of() + private var apiType: JsonField = JsonMissing.of() + private var apiVersion: JsonField = JsonMissing.of() + private var caching: JsonField = JsonMissing.of() + private var customLlmProvider: JsonField = JsonMissing.of() + private var input: JsonField>? = null + private var litellmCallId: JsonField = JsonMissing.of() + private var litellmLoggingObj: JsonField = JsonMissing.of() + private var loggerFn: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var user: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + bodyModel = body.bodyModel + apiBase = body.apiBase + apiKey = body.apiKey + apiType = body.apiType + apiVersion = body.apiVersion + caching = body.caching + customLlmProvider = body.customLlmProvider + input = body.input.map { it.toMutableList() } + litellmCallId = body.litellmCallId + litellmLoggingObj = body.litellmLoggingObj + loggerFn = body.loggerFn + timeout = body.timeout + user = body.user + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun bodyModel(bodyModel: String) = bodyModel(JsonField.of(bodyModel)) + + /** + * Sets [Builder.bodyModel] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bodyModel(bodyModel: JsonField) = apply { this.bodyModel = bodyModel } + + fun apiBase(apiBase: String?) = apiBase(JsonField.ofNullable(apiBase)) + + /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ + fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } + + fun apiKey(apiKey: String?) = apiKey(JsonField.ofNullable(apiKey)) + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + fun apiType(apiType: String?) = apiType(JsonField.ofNullable(apiType)) + + /** Alias for calling [Builder.apiType] with `apiType.orElse(null)`. */ + fun apiType(apiType: Optional) = apiType(apiType.getOrNull()) + + /** + * Sets [Builder.apiType] to an arbitrary JSON value. + * + * You should usually call [Builder.apiType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiType(apiType: JsonField) = apply { this.apiType = apiType } + + fun apiVersion(apiVersion: String?) = apiVersion(JsonField.ofNullable(apiVersion)) + + /** Alias for calling [Builder.apiVersion] with `apiVersion.orElse(null)`. */ + fun apiVersion(apiVersion: Optional) = apiVersion(apiVersion.getOrNull()) + + /** + * Sets [Builder.apiVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.apiVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiVersion(apiVersion: JsonField) = apply { this.apiVersion = apiVersion } + + fun caching(caching: Boolean) = caching(JsonField.of(caching)) + + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caching(caching: JsonField) = apply { this.caching = caching } + + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = + customLlmProvider(JsonField.ofNullable(customLlmProvider)) + + /** + * Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. + */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + + /** + * Sets [Builder.customLlmProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.customLlmProvider] with a well-typed + * [CustomLlmProvider] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customLlmProvider(customLlmProvider: JsonField) = apply { + this.customLlmProvider = customLlmProvider + } + + /** Alias for calling [customLlmProvider] with `CustomLlmProvider.ofString(string)`. */ + fun customLlmProvider(string: String) = + customLlmProvider(CustomLlmProvider.ofString(string)) + + /** + * Alias for calling [customLlmProvider] with + * `CustomLlmProvider.ofUnionMember1(unionMember1)`. + */ + fun customLlmProvider(unionMember1: CustomLlmProvider.UnionMember1) = + customLlmProvider(CustomLlmProvider.ofUnionMember1(unionMember1)) + + fun input(input: List) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField>) = apply { + this.input = input.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.input]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInput(input: String) = apply { + this.input = + (this.input ?: JsonField.of(mutableListOf())).also { + checkKnown("input", it).add(input) + } + } + + fun litellmCallId(litellmCallId: String?) = + litellmCallId(JsonField.ofNullable(litellmCallId)) + + /** Alias for calling [Builder.litellmCallId] with `litellmCallId.orElse(null)`. */ + fun litellmCallId(litellmCallId: Optional) = + litellmCallId(litellmCallId.getOrNull()) + + /** + * Sets [Builder.litellmCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun litellmCallId(litellmCallId: JsonField) = apply { + this.litellmCallId = litellmCallId + } + + fun litellmLoggingObj(litellmLoggingObj: LitellmLoggingObj?) = + litellmLoggingObj(JsonField.ofNullable(litellmLoggingObj)) + + /** + * Alias for calling [Builder.litellmLoggingObj] with `litellmLoggingObj.orElse(null)`. + */ + fun litellmLoggingObj(litellmLoggingObj: Optional) = + litellmLoggingObj(litellmLoggingObj.getOrNull()) + + /** + * Sets [Builder.litellmLoggingObj] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmLoggingObj] with a well-typed + * [LitellmLoggingObj] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun litellmLoggingObj(litellmLoggingObj: JsonField) = apply { + this.litellmLoggingObj = litellmLoggingObj + } + + fun loggerFn(loggerFn: String?) = loggerFn(JsonField.ofNullable(loggerFn)) + + /** Alias for calling [Builder.loggerFn] with `loggerFn.orElse(null)`. */ + fun loggerFn(loggerFn: Optional) = loggerFn(loggerFn.getOrNull()) + + /** + * Sets [Builder.loggerFn] to an arbitrary JSON value. + * + * You should usually call [Builder.loggerFn] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun loggerFn(loggerFn: JsonField) = apply { this.loggerFn = loggerFn } + + fun timeout(timeout: Long) = timeout(JsonField.of(timeout)) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun user(user: String?) = user(JsonField.ofNullable(user)) + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun user(user: JsonField) = apply { this.user = user } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bodyModel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("bodyModel", bodyModel), + apiBase, + apiKey, + apiType, + apiVersion, + caching, + customLlmProvider, + (input ?: JsonMissing.of()).map { it.toImmutable() }, + litellmCallId, + litellmLoggingObj, + loggerFn, + timeout, + user, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + bodyModel() + apiBase() + apiKey() + apiType() + apiVersion() + caching() + customLlmProvider().ifPresent { it.validate() } + input() + litellmCallId() + litellmLoggingObj().ifPresent { it.validate() } + loggerFn() + timeout() + user() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bodyModel.asKnown().isPresent) 1 else 0) + + (if (apiBase.asKnown().isPresent) 1 else 0) + + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (apiType.asKnown().isPresent) 1 else 0) + + (if (apiVersion.asKnown().isPresent) 1 else 0) + + (if (caching.asKnown().isPresent) 1 else 0) + + (customLlmProvider.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.size ?: 0) + + (if (litellmCallId.asKnown().isPresent) 1 else 0) + + (litellmLoggingObj.asKnown().getOrNull()?.validity() ?: 0) + + (if (loggerFn.asKnown().isPresent) 1 else 0) + + (if (timeout.asKnown().isPresent) 1 else 0) + + (if (user.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + bodyModel == other.bodyModel && + apiBase == other.apiBase && + apiKey == other.apiKey && + apiType == other.apiType && + apiVersion == other.apiVersion && + caching == other.caching && + customLlmProvider == other.customLlmProvider && + input == other.input && + litellmCallId == other.litellmCallId && + litellmLoggingObj == other.litellmLoggingObj && + loggerFn == other.loggerFn && + timeout == other.timeout && + user == other.user && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bodyModel, + apiBase, + apiKey, + apiType, + apiVersion, + caching, + customLlmProvider, + input, + litellmCallId, + litellmLoggingObj, + loggerFn, + timeout, + user, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{bodyModel=$bodyModel, apiBase=$apiBase, apiKey=$apiKey, apiType=$apiType, apiVersion=$apiVersion, caching=$caching, customLlmProvider=$customLlmProvider, input=$input, litellmCallId=$litellmCallId, litellmLoggingObj=$litellmLoggingObj, loggerFn=$loggerFn, timeout=$timeout, user=$user, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = CustomLlmProvider.Deserializer::class) + @JsonSerialize(using = CustomLlmProvider.Serializer::class) + class CustomLlmProvider + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CustomLlmProvider = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomLlmProvider && + string == other.string && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "CustomLlmProvider{string=$string}" + unionMember1 != null -> "CustomLlmProvider{unionMember1=$unionMember1}" + _json != null -> "CustomLlmProvider{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CustomLlmProvider") + } + + companion object { + + @JvmStatic fun ofString(string: String) = CustomLlmProvider(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + CustomLlmProvider(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [CustomLlmProvider] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [CustomLlmProvider] to a value of type [T]. + * + * An instance of [CustomLlmProvider] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CustomLlmProvider: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CustomLlmProvider::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CustomLlmProvider { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + CustomLlmProvider(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + CustomLlmProvider(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> CustomLlmProvider(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(CustomLlmProvider::class) { + + override fun serialize( + value: CustomLlmProvider, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CustomLlmProvider") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + class LitellmLoggingObj + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LitellmLoggingObj]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LitellmLoggingObj]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(litellmLoggingObj: LitellmLoggingObj) = apply { + additionalProperties = litellmLoggingObj.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LitellmLoggingObj]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LitellmLoggingObj = LitellmLoggingObj(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LitellmLoggingObj = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LitellmLoggingObj && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LitellmLoggingObj{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is EngineEmbedParams && - model == other.model && + pathModel == other.pathModel && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(pathModel, body, additionalHeaders, additionalQueryParams) override fun toString() = - "EngineEmbedParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EngineEmbedParams{pathModel=$pathModel, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt index 20f1218b..39f86b68 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/engines/chat/ChatCompleteParams.kt @@ -2,11 +2,34 @@ package ai.hanzo.api.models.engines.chat +import ai.hanzo.api.core.BaseDeserializer +import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.Enum +import ai.hanzo.api.core.ExcludeMissing +import ai.hanzo.api.core.JsonField +import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params +import ai.hanzo.api.core.allMaxBy +import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable +import ai.hanzo.api.errors.HanzoInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -32,16 +55,397 @@ import kotlin.jvm.optionals.getOrNull */ class ChatCompleteParams private constructor( - private val model: String?, + private val pathModel: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { - fun model(): Optional = Optional.ofNullable(model) + fun pathModel(): Optional = Optional.ofNullable(pathModel) - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List = body.messages() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun bodyModel(): String = body.bodyModel() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = body.caching() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbackDict(): Optional = + body.contextWindowFallbackDict() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = body.fallbacks() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun frequencyPenalty(): Optional = body.frequencyPenalty() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functionCall(): Optional = body.functionCall() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functions(): Optional> = body.functions() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrails(): Optional> = body.guardrails() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logitBias(): Optional = body.logitBias() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logprobs(): Optional = body.logprobs() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = body.maxTokens() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun n(): Optional = body.n() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = body.numRetries() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional = body.parallelToolCalls() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun presencePenalty(): Optional = body.presencePenalty() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFormat(): Optional = body.responseFormat() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun seed(): Optional = body.seed() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceTier(): Optional = body.serviceTier() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stop(): Optional = body.stop() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stream(): Optional = body.stream() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamOptions(): Optional = body.streamOptions() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = body.temperature() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun toolChoice(): Optional = body.toolChoice() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tools(): Optional> = body.tools() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topLogprobs(): Optional = body.topLogprobs() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topP(): Optional = body.topP() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = body.user() + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _messages(): JsonField> = body._messages() + + /** + * Returns the raw JSON value of [bodyModel]. + * + * Unlike [bodyModel], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bodyModel(): JsonField = body._bodyModel() + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _caching(): JsonField = body._caching() + + /** + * Returns the raw JSON value of [contextWindowFallbackDict]. + * + * Unlike [contextWindowFallbackDict], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _contextWindowFallbackDict(): JsonField = + body._contextWindowFallbackDict() + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fallbacks(): JsonField> = body._fallbacks() + + /** + * Returns the raw JSON value of [frequencyPenalty]. + * + * Unlike [frequencyPenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _frequencyPenalty(): JsonField = body._frequencyPenalty() + + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _functionCall(): JsonField = body._functionCall() + + /** + * Returns the raw JSON value of [functions]. + * + * Unlike [functions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _functions(): JsonField> = body._functions() + + /** + * Returns the raw JSON value of [guardrails]. + * + * Unlike [guardrails], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _guardrails(): JsonField> = body._guardrails() + + /** + * Returns the raw JSON value of [logitBias]. + * + * Unlike [logitBias], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _logitBias(): JsonField = body._logitBias() + + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _logprobs(): JsonField = body._logprobs() + + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _maxTokens(): JsonField = body._maxTokens() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [n]. + * + * Unlike [n], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _n(): JsonField = body._n() + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _numRetries(): JsonField = body._numRetries() + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _parallelToolCalls(): JsonField = body._parallelToolCalls() + + /** + * Returns the raw JSON value of [presencePenalty]. + * + * Unlike [presencePenalty], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _presencePenalty(): JsonField = body._presencePenalty() + + /** + * Returns the raw JSON value of [responseFormat]. + * + * Unlike [responseFormat], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _responseFormat(): JsonField = body._responseFormat() + + /** + * Returns the raw JSON value of [seed]. + * + * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _seed(): JsonField = body._seed() + + /** + * Returns the raw JSON value of [serviceTier]. + * + * Unlike [serviceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _serviceTier(): JsonField = body._serviceTier() + + /** + * Returns the raw JSON value of [stop]. + * + * Unlike [stop], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _stop(): JsonField = body._stop() + + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _stream(): JsonField = body._stream() + + /** + * Returns the raw JSON value of [streamOptions]. + * + * Unlike [streamOptions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _streamOptions(): JsonField = body._streamOptions() + + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _temperature(): JsonField = body._temperature() + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _toolChoice(): JsonField = body._toolChoice() + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tools(): JsonField> = body._tools() + + /** + * Returns the raw JSON value of [topLogprobs]. + * + * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topLogprobs(): JsonField = body._topLogprobs() + + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topP(): JsonField = body._topP() + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _user(): JsonField = body._user() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -53,179 +457,16463 @@ private constructor( companion object { - @JvmStatic fun none(): ChatCompleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ChatCompleteParams]. */ + /** + * Returns a mutable builder for constructing an instance of [ChatCompleteParams]. + * + * The following fields are required: + * ```java + * .messages() + * .bodyModel() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [ChatCompleteParams]. */ class Builder internal constructor() { - private var model: String? = null + private var pathModel: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(chatCompleteParams: ChatCompleteParams) = apply { - model = chatCompleteParams.model + pathModel = chatCompleteParams.pathModel + body = chatCompleteParams.body.toBuilder() additionalHeaders = chatCompleteParams.additionalHeaders.toBuilder() additionalQueryParams = chatCompleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = chatCompleteParams.additionalBodyProperties.toMutableMap() } - fun model(model: String?) = apply { this.model = model } + fun pathModel(pathModel: String?) = apply { this.pathModel = pathModel } - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) + /** Alias for calling [Builder.pathModel] with `pathModel.orElse(null)`. */ + fun pathModel(pathModel: Optional) = pathModel(pathModel.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [messages] + * - [bodyModel] + * - [caching] + * - [contextWindowFallbackDict] + * - [fallbacks] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun messages(messages: List) = apply { body.messages(messages) } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField>) = apply { body.messages(messages) } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { body.addMessage(message) } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) + /** + * Alias for calling [addMessage] with `Message.ofChatCompletionUser(chatCompletionUser)`. + */ + fun addMessage(chatCompletionUser: Message.ChatCompletionUserMessage) = apply { + body.addMessage(chatCompletionUser) } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionAssistant(chatCompletionAssistant)`. + */ + fun addMessage(chatCompletionAssistant: Message.ChatCompletionAssistantMessage) = apply { + body.addMessage(chatCompletionAssistant) } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) + /** + * Alias for calling [addMessage] with `Message.ofChatCompletionTool(chatCompletionTool)`. + */ + fun addMessage(chatCompletionTool: Message.ChatCompletionToolMessage) = apply { + body.addMessage(chatCompletionTool) } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionSystem(chatCompletionSystem)`. + */ + fun addMessage(chatCompletionSystem: Message.ChatCompletionSystemMessage) = apply { + body.addMessage(chatCompletionSystem) } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionFunction(chatCompletionFunction)`. + */ + fun addMessage(chatCompletionFunction: Message.ChatCompletionFunctionMessage) = apply { + body.addMessage(chatCompletionFunction) } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionDeveloper(chatCompletionDeveloper)`. + */ + fun addMessage(chatCompletionDeveloper: Message.ChatCompletionDeveloperMessage) = apply { + body.addMessage(chatCompletionDeveloper) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun bodyModel(bodyModel: String) = apply { body.bodyModel(bodyModel) } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Sets [Builder.bodyModel] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bodyModel(bodyModel: JsonField) = apply { body.bodyModel(bodyModel) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun caching(caching: Boolean?) = apply { body.caching(caching) } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + /** + * Alias for [Builder.caching]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun caching(caching: Boolean) = caching(caching as Boolean?) - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + /** Alias for calling [Builder.caching] with `caching.orElse(null)`. */ + fun caching(caching: Optional) = caching(caching.getOrNull()) - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun caching(caching: JsonField) = apply { body.caching(caching) } - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + fun contextWindowFallbackDict(contextWindowFallbackDict: ContextWindowFallbackDict?) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) + body.contextWindowFallbackDict(contextWindowFallbackDict) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + /** + * Alias for calling [Builder.contextWindowFallbackDict] with + * `contextWindowFallbackDict.orElse(null)`. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: Optional + ) = contextWindowFallbackDict(contextWindowFallbackDict.getOrNull()) - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + /** + * Sets [Builder.contextWindowFallbackDict] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbackDict] with a well-typed + * [ContextWindowFallbackDict] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: JsonField + ) = apply { body.contextWindowFallbackDict(contextWindowFallbackDict) } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun fallbacks(fallbacks: List?) = apply { body.fallbacks(fallbacks) } - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { body.fallbacks(fallbacks) } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + /** + * Adds a single [String] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: String) = apply { body.addFallback(fallback) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) + fun frequencyPenalty(frequencyPenalty: Double?) = apply { + body.frequencyPenalty(frequencyPenalty) } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) + /** + * Alias for [Builder.frequencyPenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(frequencyPenalty as Double?) + + /** Alias for calling [Builder.frequencyPenalty] with `frequencyPenalty.orElse(null)`. */ + fun frequencyPenalty(frequencyPenalty: Optional) = + frequencyPenalty(frequencyPenalty.getOrNull()) + + /** + * Sets [Builder.frequencyPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.frequencyPenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + body.frequencyPenalty(frequencyPenalty) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun functionCall(functionCall: FunctionCall?) = apply { body.functionCall(functionCall) } + + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun functionCall(functionCall: JsonField) = apply { + body.functionCall(functionCall) } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) + /** Alias for calling [functionCall] with `FunctionCall.ofString(string)`. */ + fun functionCall(string: String) = apply { body.functionCall(string) } + + /** Alias for calling [functionCall] with `FunctionCall.ofUnionMember1(unionMember1)`. */ + fun functionCall(unionMember1: FunctionCall.UnionMember1) = apply { + body.functionCall(unionMember1) } + fun functions(functions: List?) = apply { body.functions(functions) } + + /** Alias for calling [Builder.functions] with `functions.orElse(null)`. */ + fun functions(functions: Optional>) = functions(functions.getOrNull()) + /** - * Returns an immutable instance of [ChatCompleteParams]. + * Sets [Builder.functions] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * You should usually call [Builder.functions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun build(): ChatCompleteParams = - ChatCompleteParams( - model, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } + fun functions(functions: JsonField>) = apply { body.functions(functions) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + /** + * Adds a single [Function] to [functions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFunction(function: Function) = apply { body.addFunction(function) } - fun _pathParam(index: Int): String = - when (index) { - 0 -> model ?: "" - else -> "" - } + fun guardrails(guardrails: List?) = apply { body.guardrails(guardrails) } - override fun _headers(): Headers = additionalHeaders + /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */ + fun guardrails(guardrails: Optional>) = guardrails(guardrails.getOrNull()) - override fun _queryParams(): QueryParams = additionalQueryParams + /** + * Sets [Builder.guardrails] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun guardrails(guardrails: JsonField>) = apply { body.guardrails(guardrails) } + + /** + * Adds a single [String] to [guardrails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGuardrail(guardrail: String) = apply { body.addGuardrail(guardrail) } + + fun logitBias(logitBias: LogitBias?) = apply { body.logitBias(logitBias) } + + /** Alias for calling [Builder.logitBias] with `logitBias.orElse(null)`. */ + fun logitBias(logitBias: Optional) = logitBias(logitBias.getOrNull()) + + /** + * Sets [Builder.logitBias] to an arbitrary JSON value. + * + * You should usually call [Builder.logitBias] with a well-typed [LogitBias] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun logitBias(logitBias: JsonField) = apply { body.logitBias(logitBias) } + + fun logprobs(logprobs: Boolean?) = apply { body.logprobs(logprobs) } + + /** + * Alias for [Builder.logprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun logprobs(logprobs: Boolean) = logprobs(logprobs as Boolean?) + + /** Alias for calling [Builder.logprobs] with `logprobs.orElse(null)`. */ + fun logprobs(logprobs: Optional) = logprobs(logprobs.getOrNull()) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun logprobs(logprobs: JsonField) = apply { body.logprobs(logprobs) } + + fun maxTokens(maxTokens: Long?) = apply { body.maxTokens(maxTokens) } + + /** + * Alias for [Builder.maxTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxTokens(maxTokens: Long) = maxTokens(maxTokens as Long?) + + /** Alias for calling [Builder.maxTokens] with `maxTokens.orElse(null)`. */ + fun maxTokens(maxTokens: Optional) = maxTokens(maxTokens.getOrNull()) + + /** + * Sets [Builder.maxTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokens] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun maxTokens(maxTokens: JsonField) = apply { body.maxTokens(maxTokens) } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun n(n: Long?) = apply { body.n(n) } + + /** + * Alias for [Builder.n]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun n(n: Long) = n(n as Long?) + + /** Alias for calling [Builder.n] with `n.orElse(null)`. */ + fun n(n: Optional) = n(n.getOrNull()) + + /** + * Sets [Builder.n] to an arbitrary JSON value. + * + * You should usually call [Builder.n] with a well-typed [Long] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun n(n: JsonField) = apply { body.n(n) } + + fun numRetries(numRetries: Long?) = apply { body.numRetries(numRetries) } + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numRetries(numRetries: JsonField) = apply { body.numRetries(numRetries) } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. */ + fun parallelToolCalls(parallelToolCalls: Optional) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + fun presencePenalty(presencePenalty: Double?) = apply { + body.presencePenalty(presencePenalty) + } + + /** + * Alias for [Builder.presencePenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun presencePenalty(presencePenalty: Double) = presencePenalty(presencePenalty as Double?) + + /** Alias for calling [Builder.presencePenalty] with `presencePenalty.orElse(null)`. */ + fun presencePenalty(presencePenalty: Optional) = + presencePenalty(presencePenalty.getOrNull()) + + /** + * Sets [Builder.presencePenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.presencePenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun presencePenalty(presencePenalty: JsonField) = apply { + body.presencePenalty(presencePenalty) + } + + fun responseFormat(responseFormat: ResponseFormat?) = apply { + body.responseFormat(responseFormat) + } + + /** Alias for calling [Builder.responseFormat] with `responseFormat.orElse(null)`. */ + fun responseFormat(responseFormat: Optional) = + responseFormat(responseFormat.getOrNull()) + + /** + * Sets [Builder.responseFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.responseFormat] with a well-typed [ResponseFormat] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun responseFormat(responseFormat: JsonField) = apply { + body.responseFormat(responseFormat) + } + + fun seed(seed: Long?) = apply { body.seed(seed) } + + /** + * Alias for [Builder.seed]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun seed(seed: Long) = seed(seed as Long?) + + /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ + fun seed(seed: Optional) = seed(seed.getOrNull()) + + /** + * Sets [Builder.seed] to an arbitrary JSON value. + * + * You should usually call [Builder.seed] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun seed(seed: JsonField) = apply { body.seed(seed) } + + fun serviceTier(serviceTier: String?) = apply { body.serviceTier(serviceTier) } + + /** Alias for calling [Builder.serviceTier] with `serviceTier.orElse(null)`. */ + fun serviceTier(serviceTier: Optional) = serviceTier(serviceTier.getOrNull()) + + /** + * Sets [Builder.serviceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceTier] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun serviceTier(serviceTier: JsonField) = apply { body.serviceTier(serviceTier) } + + fun stop(stop: Stop?) = apply { body.stop(stop) } + + /** Alias for calling [Builder.stop] with `stop.orElse(null)`. */ + fun stop(stop: Optional) = stop(stop.getOrNull()) + + /** + * Sets [Builder.stop] to an arbitrary JSON value. + * + * You should usually call [Builder.stop] with a well-typed [Stop] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun stop(stop: JsonField) = apply { body.stop(stop) } + + /** Alias for calling [stop] with `Stop.ofString(string)`. */ + fun stop(string: String) = apply { body.stop(string) } + + /** Alias for calling [stop] with `Stop.ofStrings(strings)`. */ + fun stopOfStrings(strings: List) = apply { body.stopOfStrings(strings) } + + fun stream(stream: Boolean?) = apply { body.stream(stream) } + + /** + * Alias for [Builder.stream]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun stream(stream: Boolean) = stream(stream as Boolean?) + + /** Alias for calling [Builder.stream] with `stream.orElse(null)`. */ + fun stream(stream: Optional) = stream(stream.getOrNull()) + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun stream(stream: JsonField) = apply { body.stream(stream) } + + fun streamOptions(streamOptions: StreamOptions?) = apply { + body.streamOptions(streamOptions) + } + + /** Alias for calling [Builder.streamOptions] with `streamOptions.orElse(null)`. */ + fun streamOptions(streamOptions: Optional) = + streamOptions(streamOptions.getOrNull()) + + /** + * Sets [Builder.streamOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.streamOptions] with a well-typed [StreamOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streamOptions(streamOptions: JsonField) = apply { + body.streamOptions(streamOptions) + } + + fun temperature(temperature: Double?) = apply { body.temperature(temperature) } + + /** + * Alias for [Builder.temperature]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun temperature(temperature: Double) = temperature(temperature as Double?) + + /** Alias for calling [Builder.temperature] with `temperature.orElse(null)`. */ + fun temperature(temperature: Optional) = temperature(temperature.getOrNull()) + + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun temperature(temperature: JsonField) = apply { body.temperature(temperature) } + + fun toolChoice(toolChoice: ToolChoice?) = apply { body.toolChoice(toolChoice) } + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [ToolChoice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolChoice(toolChoice: JsonField) = apply { body.toolChoice(toolChoice) } + + /** Alias for calling [toolChoice] with `ToolChoice.ofString(string)`. */ + fun toolChoice(string: String) = apply { body.toolChoice(string) } + + /** Alias for calling [toolChoice] with `ToolChoice.ofUnionMember1(unionMember1)`. */ + fun toolChoice(unionMember1: ToolChoice.UnionMember1) = apply { + body.toolChoice(unionMember1) + } + + fun tools(tools: List?) = apply { body.tools(tools) } + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tools(tools: JsonField>) = apply { body.tools(tools) } + + /** + * Adds a single [Tool] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: Tool) = apply { body.addTool(tool) } + + fun topLogprobs(topLogprobs: Long?) = apply { body.topLogprobs(topLogprobs) } + + /** + * Alias for [Builder.topLogprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topLogprobs(topLogprobs: Long) = topLogprobs(topLogprobs as Long?) + + /** Alias for calling [Builder.topLogprobs] with `topLogprobs.orElse(null)`. */ + fun topLogprobs(topLogprobs: Optional) = topLogprobs(topLogprobs.getOrNull()) + + /** + * Sets [Builder.topLogprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.topLogprobs] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topLogprobs(topLogprobs: JsonField) = apply { body.topLogprobs(topLogprobs) } + + fun topP(topP: Double?) = apply { body.topP(topP) } + + /** + * Alias for [Builder.topP]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topP(topP: Double) = topP(topP as Double?) + + /** Alias for calling [Builder.topP] with `topP.orElse(null)`. */ + fun topP(topP: Optional) = topP(topP.getOrNull()) + + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topP(topP: JsonField) = apply { body.topP(topP) } + + fun user(user: String?) = apply { body.user(user) } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun user(user: JsonField) = apply { body.user(user) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ChatCompleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .bodyModel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompleteParams = + ChatCompleteParams( + pathModel, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> pathModel ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val messages: JsonField>, + private val bodyModel: JsonField, + private val caching: JsonField, + private val contextWindowFallbackDict: JsonField, + private val fallbacks: JsonField>, + private val frequencyPenalty: JsonField, + private val functionCall: JsonField, + private val functions: JsonField>, + private val guardrails: JsonField>, + private val logitBias: JsonField, + private val logprobs: JsonField, + private val maxTokens: JsonField, + private val metadata: JsonField, + private val n: JsonField, + private val numRetries: JsonField, + private val parallelToolCalls: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val seed: JsonField, + private val serviceTier: JsonField, + private val stop: JsonField, + private val stream: JsonField, + private val streamOptions: JsonField, + private val temperature: JsonField, + private val toolChoice: JsonField, + private val tools: JsonField>, + private val topLogprobs: JsonField, + private val topP: JsonField, + private val user: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("messages") + @ExcludeMissing + messages: JsonField> = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing bodyModel: JsonField = JsonMissing.of(), + @JsonProperty("caching") @ExcludeMissing caching: JsonField = JsonMissing.of(), + @JsonProperty("context_window_fallback_dict") + @ExcludeMissing + contextWindowFallbackDict: JsonField = JsonMissing.of(), + @JsonProperty("fallbacks") + @ExcludeMissing + fallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("frequency_penalty") + @ExcludeMissing + frequencyPenalty: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + functionCall: JsonField = JsonMissing.of(), + @JsonProperty("functions") + @ExcludeMissing + functions: JsonField> = JsonMissing.of(), + @JsonProperty("guardrails") + @ExcludeMissing + guardrails: JsonField> = JsonMissing.of(), + @JsonProperty("logit_bias") + @ExcludeMissing + logitBias: JsonField = JsonMissing.of(), + @JsonProperty("logprobs") + @ExcludeMissing + logprobs: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens") + @ExcludeMissing + maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("n") @ExcludeMissing n: JsonField = JsonMissing.of(), + @JsonProperty("num_retries") + @ExcludeMissing + numRetries: JsonField = JsonMissing.of(), + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + parallelToolCalls: JsonField = JsonMissing.of(), + @JsonProperty("presence_penalty") + @ExcludeMissing + presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("response_format") + @ExcludeMissing + responseFormat: JsonField = JsonMissing.of(), + @JsonProperty("seed") @ExcludeMissing seed: JsonField = JsonMissing.of(), + @JsonProperty("service_tier") + @ExcludeMissing + serviceTier: JsonField = JsonMissing.of(), + @JsonProperty("stop") @ExcludeMissing stop: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing stream: JsonField = JsonMissing.of(), + @JsonProperty("stream_options") + @ExcludeMissing + streamOptions: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + temperature: JsonField = JsonMissing.of(), + @JsonProperty("tool_choice") + @ExcludeMissing + toolChoice: JsonField = JsonMissing.of(), + @JsonProperty("tools") @ExcludeMissing tools: JsonField> = JsonMissing.of(), + @JsonProperty("top_logprobs") + @ExcludeMissing + topLogprobs: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing topP: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonField = JsonMissing.of(), + ) : this( + messages, + bodyModel, + caching, + contextWindowFallbackDict, + fallbacks, + frequencyPenalty, + functionCall, + functions, + guardrails, + logitBias, + logprobs, + maxTokens, + metadata, + n, + numRetries, + parallelToolCalls, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop, + stream, + streamOptions, + temperature, + toolChoice, + tools, + topLogprobs, + topP, + user, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List = messages.getRequired("messages") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bodyModel(): String = bodyModel.getRequired("model") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caching(): Optional = caching.getOptional("caching") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbackDict(): Optional = + contextWindowFallbackDict.getOptional("context_window_fallback_dict") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = fallbacks.getOptional("fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun frequencyPenalty(): Optional = frequencyPenalty.getOptional("frequency_penalty") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functionCall(): Optional = functionCall.getOptional("function_call") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun functions(): Optional> = functions.getOptional("functions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrails(): Optional> = guardrails.getOptional("guardrails") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logitBias(): Optional = logitBias.getOptional("logit_bias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logprobs(): Optional = logprobs.getOptional("logprobs") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = maxTokens.getOptional("max_tokens") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun n(): Optional = n.getOptional("n") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = numRetries.getOptional("num_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional = + parallelToolCalls.getOptional("parallel_tool_calls") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun presencePenalty(): Optional = presencePenalty.getOptional("presence_penalty") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFormat(): Optional = + responseFormat.getOptional("response_format") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun seed(): Optional = seed.getOptional("seed") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceTier(): Optional = serviceTier.getOptional("service_tier") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stop(): Optional = stop.getOptional("stop") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stream(): Optional = stream.getOptional("stream") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamOptions(): Optional = streamOptions.getOptional("stream_options") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = temperature.getOptional("temperature") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun toolChoice(): Optional = toolChoice.getOptional("tool_choice") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tools(): Optional> = tools.getOptional("tools") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topLogprobs(): Optional = topLogprobs.getOptional("top_logprobs") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun topP(): Optional = topP.getOptional("top_p") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun user(): Optional = user.getOptional("user") + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messages") + @ExcludeMissing + fun _messages(): JsonField> = messages + + /** + * Returns the raw JSON value of [bodyModel]. + * + * Unlike [bodyModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _bodyModel(): JsonField = bodyModel + + /** + * Returns the raw JSON value of [caching]. + * + * Unlike [caching], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caching") @ExcludeMissing fun _caching(): JsonField = caching + + /** + * Returns the raw JSON value of [contextWindowFallbackDict]. + * + * Unlike [contextWindowFallbackDict], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context_window_fallback_dict") + @ExcludeMissing + fun _contextWindowFallbackDict(): JsonField = + contextWindowFallbackDict + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fallbacks") + @ExcludeMissing + fun _fallbacks(): JsonField> = fallbacks + + /** + * Returns the raw JSON value of [frequencyPenalty]. + * + * Unlike [frequencyPenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency_penalty") + @ExcludeMissing + fun _frequencyPenalty(): JsonField = frequencyPenalty + + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall(): JsonField = functionCall + + /** + * Returns the raw JSON value of [functions]. + * + * Unlike [functions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("functions") + @ExcludeMissing + fun _functions(): JsonField> = functions + + /** + * Returns the raw JSON value of [guardrails]. + * + * Unlike [guardrails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("guardrails") + @ExcludeMissing + fun _guardrails(): JsonField> = guardrails + + /** + * Returns the raw JSON value of [logitBias]. + * + * Unlike [logitBias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logit_bias") + @ExcludeMissing + fun _logitBias(): JsonField = logitBias + + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField = logprobs + + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [n]. + * + * Unlike [n], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_retries") @ExcludeMissing fun _numRetries(): JsonField = numRetries + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + fun _parallelToolCalls(): JsonField = parallelToolCalls + + /** + * Returns the raw JSON value of [presencePenalty]. + * + * Unlike [presencePenalty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("presence_penalty") + @ExcludeMissing + fun _presencePenalty(): JsonField = presencePenalty + + /** + * Returns the raw JSON value of [responseFormat]. + * + * Unlike [responseFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("response_format") + @ExcludeMissing + fun _responseFormat(): JsonField = responseFormat + + /** + * Returns the raw JSON value of [seed]. + * + * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seed") @ExcludeMissing fun _seed(): JsonField = seed + + /** + * Returns the raw JSON value of [serviceTier]. + * + * Unlike [serviceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("service_tier") + @ExcludeMissing + fun _serviceTier(): JsonField = serviceTier + + /** + * Returns the raw JSON value of [stop]. + * + * Unlike [stop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField = stop + + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + + /** + * Returns the raw JSON value of [streamOptions]. + * + * Unlike [streamOptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stream_options") + @ExcludeMissing + fun _streamOptions(): JsonField = streamOptions + + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tool_choice") + @ExcludeMissing + fun _toolChoice(): JsonField = toolChoice + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField> = tools + + /** + * Returns the raw JSON value of [topLogprobs]. + * + * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_logprobs") + @ExcludeMissing + fun _topLogprobs(): JsonField = topLogprobs + + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonField = user + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .messages() + * .bodyModel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var messages: JsonField>? = null + private var bodyModel: JsonField? = null + private var caching: JsonField = JsonMissing.of() + private var contextWindowFallbackDict: JsonField = + JsonMissing.of() + private var fallbacks: JsonField>? = null + private var frequencyPenalty: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var functions: JsonField>? = null + private var guardrails: JsonField>? = null + private var logitBias: JsonField = JsonMissing.of() + private var logprobs: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var n: JsonField = JsonMissing.of() + private var numRetries: JsonField = JsonMissing.of() + private var parallelToolCalls: JsonField = JsonMissing.of() + private var presencePenalty: JsonField = JsonMissing.of() + private var responseFormat: JsonField = JsonMissing.of() + private var seed: JsonField = JsonMissing.of() + private var serviceTier: JsonField = JsonMissing.of() + private var stop: JsonField = JsonMissing.of() + private var stream: JsonField = JsonMissing.of() + private var streamOptions: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var toolChoice: JsonField = JsonMissing.of() + private var tools: JsonField>? = null + private var topLogprobs: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var user: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + messages = body.messages.map { it.toMutableList() } + bodyModel = body.bodyModel + caching = body.caching + contextWindowFallbackDict = body.contextWindowFallbackDict + fallbacks = body.fallbacks.map { it.toMutableList() } + frequencyPenalty = body.frequencyPenalty + functionCall = body.functionCall + functions = body.functions.map { it.toMutableList() } + guardrails = body.guardrails.map { it.toMutableList() } + logitBias = body.logitBias + logprobs = body.logprobs + maxTokens = body.maxTokens + metadata = body.metadata + n = body.n + numRetries = body.numRetries + parallelToolCalls = body.parallelToolCalls + presencePenalty = body.presencePenalty + responseFormat = body.responseFormat + seed = body.seed + serviceTier = body.serviceTier + stop = body.stop + stream = body.stream + streamOptions = body.streamOptions + temperature = body.temperature + toolChoice = body.toolChoice + tools = body.tools.map { it.toMutableList() } + topLogprobs = body.topLogprobs + topP = body.topP + user = body.user + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun messages(messages: List) = messages(JsonField.of(messages)) + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField>) = apply { + this.messages = messages.map { it.toMutableList() } + } + + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) + } + } + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionUser(chatCompletionUser)`. + */ + fun addMessage(chatCompletionUser: Message.ChatCompletionUserMessage) = + addMessage(Message.ofChatCompletionUser(chatCompletionUser)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionAssistant(chatCompletionAssistant)`. + */ + fun addMessage(chatCompletionAssistant: Message.ChatCompletionAssistantMessage) = + addMessage(Message.ofChatCompletionAssistant(chatCompletionAssistant)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionTool(chatCompletionTool)`. + */ + fun addMessage(chatCompletionTool: Message.ChatCompletionToolMessage) = + addMessage(Message.ofChatCompletionTool(chatCompletionTool)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionSystem(chatCompletionSystem)`. + */ + fun addMessage(chatCompletionSystem: Message.ChatCompletionSystemMessage) = + addMessage(Message.ofChatCompletionSystem(chatCompletionSystem)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionFunction(chatCompletionFunction)`. + */ + fun addMessage(chatCompletionFunction: Message.ChatCompletionFunctionMessage) = + addMessage(Message.ofChatCompletionFunction(chatCompletionFunction)) + + /** + * Alias for calling [addMessage] with + * `Message.ofChatCompletionDeveloper(chatCompletionDeveloper)`. + */ + fun addMessage(chatCompletionDeveloper: Message.ChatCompletionDeveloperMessage) = + addMessage(Message.ofChatCompletionDeveloper(chatCompletionDeveloper)) + + fun bodyModel(bodyModel: String) = bodyModel(JsonField.of(bodyModel)) + + /** + * Sets [Builder.bodyModel] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bodyModel(bodyModel: JsonField) = apply { this.bodyModel = bodyModel } + + fun caching(caching: Boolean?) = caching(JsonField.ofNullable(caching)) + + /** + * Alias for [Builder.caching]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun caching(caching: Boolean) = caching(caching as Boolean?) + + /** Alias for calling [Builder.caching] with `caching.orElse(null)`. */ + fun caching(caching: Optional) = caching(caching.getOrNull()) + + /** + * Sets [Builder.caching] to an arbitrary JSON value. + * + * You should usually call [Builder.caching] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caching(caching: JsonField) = apply { this.caching = caching } + + fun contextWindowFallbackDict(contextWindowFallbackDict: ContextWindowFallbackDict?) = + contextWindowFallbackDict(JsonField.ofNullable(contextWindowFallbackDict)) + + /** + * Alias for calling [Builder.contextWindowFallbackDict] with + * `contextWindowFallbackDict.orElse(null)`. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: Optional + ) = contextWindowFallbackDict(contextWindowFallbackDict.getOrNull()) + + /** + * Sets [Builder.contextWindowFallbackDict] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbackDict] with a well-typed + * [ContextWindowFallbackDict] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun contextWindowFallbackDict( + contextWindowFallbackDict: JsonField + ) = apply { this.contextWindowFallbackDict = contextWindowFallbackDict } + + fun fallbacks(fallbacks: List?) = fallbacks(JsonField.ofNullable(fallbacks)) + + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) + + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { + this.fallbacks = fallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: String) = apply { + fallbacks = + (fallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("fallbacks", it).add(fallback) + } + } + + fun frequencyPenalty(frequencyPenalty: Double?) = + frequencyPenalty(JsonField.ofNullable(frequencyPenalty)) + + /** + * Alias for [Builder.frequencyPenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(frequencyPenalty as Double?) + + /** + * Alias for calling [Builder.frequencyPenalty] with `frequencyPenalty.orElse(null)`. + */ + fun frequencyPenalty(frequencyPenalty: Optional) = + frequencyPenalty(frequencyPenalty.getOrNull()) + + /** + * Sets [Builder.frequencyPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.frequencyPenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + this.frequencyPenalty = frequencyPenalty + } + + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) + + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) + + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + /** Alias for calling [functionCall] with `FunctionCall.ofString(string)`. */ + fun functionCall(string: String) = functionCall(FunctionCall.ofString(string)) + + /** + * Alias for calling [functionCall] with `FunctionCall.ofUnionMember1(unionMember1)`. + */ + fun functionCall(unionMember1: FunctionCall.UnionMember1) = + functionCall(FunctionCall.ofUnionMember1(unionMember1)) + + fun functions(functions: List?) = functions(JsonField.ofNullable(functions)) + + /** Alias for calling [Builder.functions] with `functions.orElse(null)`. */ + fun functions(functions: Optional>) = functions(functions.getOrNull()) + + /** + * Sets [Builder.functions] to an arbitrary JSON value. + * + * You should usually call [Builder.functions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun functions(functions: JsonField>) = apply { + this.functions = functions.map { it.toMutableList() } + } + + /** + * Adds a single [Function] to [functions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFunction(function: Function) = apply { + functions = + (functions ?: JsonField.of(mutableListOf())).also { + checkKnown("functions", it).add(function) + } + } + + fun guardrails(guardrails: List?) = guardrails(JsonField.ofNullable(guardrails)) + + /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */ + fun guardrails(guardrails: Optional>) = guardrails(guardrails.getOrNull()) + + /** + * Sets [Builder.guardrails] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun guardrails(guardrails: JsonField>) = apply { + this.guardrails = guardrails.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [guardrails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGuardrail(guardrail: String) = apply { + guardrails = + (guardrails ?: JsonField.of(mutableListOf())).also { + checkKnown("guardrails", it).add(guardrail) + } + } + + fun logitBias(logitBias: LogitBias?) = logitBias(JsonField.ofNullable(logitBias)) + + /** Alias for calling [Builder.logitBias] with `logitBias.orElse(null)`. */ + fun logitBias(logitBias: Optional) = logitBias(logitBias.getOrNull()) + + /** + * Sets [Builder.logitBias] to an arbitrary JSON value. + * + * You should usually call [Builder.logitBias] with a well-typed [LogitBias] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logitBias(logitBias: JsonField) = apply { this.logitBias = logitBias } + + fun logprobs(logprobs: Boolean?) = logprobs(JsonField.ofNullable(logprobs)) + + /** + * Alias for [Builder.logprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun logprobs(logprobs: Boolean) = logprobs(logprobs as Boolean?) + + /** Alias for calling [Builder.logprobs] with `logprobs.orElse(null)`. */ + fun logprobs(logprobs: Optional) = logprobs(logprobs.getOrNull()) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logprobs(logprobs: JsonField) = apply { this.logprobs = logprobs } + + fun maxTokens(maxTokens: Long?) = maxTokens(JsonField.ofNullable(maxTokens)) + + /** + * Alias for [Builder.maxTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxTokens(maxTokens: Long) = maxTokens(maxTokens as Long?) + + /** Alias for calling [Builder.maxTokens] with `maxTokens.orElse(null)`. */ + fun maxTokens(maxTokens: Optional) = maxTokens(maxTokens.getOrNull()) + + /** + * Sets [Builder.maxTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun n(n: Long?) = n(JsonField.ofNullable(n)) + + /** + * Alias for [Builder.n]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun n(n: Long) = n(n as Long?) + + /** Alias for calling [Builder.n] with `n.orElse(null)`. */ + fun n(n: Optional) = n(n.getOrNull()) + + /** + * Sets [Builder.n] to an arbitrary JSON value. + * + * You should usually call [Builder.n] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun n(n: JsonField) = apply { this.n = n } + + fun numRetries(numRetries: Long?) = numRetries(JsonField.ofNullable(numRetries)) + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numRetries(numRetries: JsonField) = apply { this.numRetries = numRetries } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = + parallelToolCalls(JsonField.ofNullable(parallelToolCalls)) + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** + * Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. + */ + fun parallelToolCalls(parallelToolCalls: Optional) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField) = apply { + this.parallelToolCalls = parallelToolCalls + } + + fun presencePenalty(presencePenalty: Double?) = + presencePenalty(JsonField.ofNullable(presencePenalty)) + + /** + * Alias for [Builder.presencePenalty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun presencePenalty(presencePenalty: Double) = + presencePenalty(presencePenalty as Double?) + + /** Alias for calling [Builder.presencePenalty] with `presencePenalty.orElse(null)`. */ + fun presencePenalty(presencePenalty: Optional) = + presencePenalty(presencePenalty.getOrNull()) + + /** + * Sets [Builder.presencePenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.presencePenalty] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun presencePenalty(presencePenalty: JsonField) = apply { + this.presencePenalty = presencePenalty + } + + fun responseFormat(responseFormat: ResponseFormat?) = + responseFormat(JsonField.ofNullable(responseFormat)) + + /** Alias for calling [Builder.responseFormat] with `responseFormat.orElse(null)`. */ + fun responseFormat(responseFormat: Optional) = + responseFormat(responseFormat.getOrNull()) + + /** + * Sets [Builder.responseFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.responseFormat] with a well-typed [ResponseFormat] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun responseFormat(responseFormat: JsonField) = apply { + this.responseFormat = responseFormat + } + + fun seed(seed: Long?) = seed(JsonField.ofNullable(seed)) + + /** + * Alias for [Builder.seed]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun seed(seed: Long) = seed(seed as Long?) + + /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ + fun seed(seed: Optional) = seed(seed.getOrNull()) + + /** + * Sets [Builder.seed] to an arbitrary JSON value. + * + * You should usually call [Builder.seed] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun seed(seed: JsonField) = apply { this.seed = seed } + + fun serviceTier(serviceTier: String?) = serviceTier(JsonField.ofNullable(serviceTier)) + + /** Alias for calling [Builder.serviceTier] with `serviceTier.orElse(null)`. */ + fun serviceTier(serviceTier: Optional) = serviceTier(serviceTier.getOrNull()) + + /** + * Sets [Builder.serviceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceTier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serviceTier(serviceTier: JsonField) = apply { + this.serviceTier = serviceTier + } + + fun stop(stop: Stop?) = stop(JsonField.ofNullable(stop)) + + /** Alias for calling [Builder.stop] with `stop.orElse(null)`. */ + fun stop(stop: Optional) = stop(stop.getOrNull()) + + /** + * Sets [Builder.stop] to an arbitrary JSON value. + * + * You should usually call [Builder.stop] with a well-typed [Stop] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun stop(stop: JsonField) = apply { this.stop = stop } + + /** Alias for calling [stop] with `Stop.ofString(string)`. */ + fun stop(string: String) = stop(Stop.ofString(string)) + + /** Alias for calling [stop] with `Stop.ofStrings(strings)`. */ + fun stopOfStrings(strings: List) = stop(Stop.ofStrings(strings)) + + fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) + + /** + * Alias for [Builder.stream]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun stream(stream: Boolean) = stream(stream as Boolean?) + + /** Alias for calling [Builder.stream] with `stream.orElse(null)`. */ + fun stream(stream: Optional) = stream(stream.getOrNull()) + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stream(stream: JsonField) = apply { this.stream = stream } + + fun streamOptions(streamOptions: StreamOptions?) = + streamOptions(JsonField.ofNullable(streamOptions)) + + /** Alias for calling [Builder.streamOptions] with `streamOptions.orElse(null)`. */ + fun streamOptions(streamOptions: Optional) = + streamOptions(streamOptions.getOrNull()) + + /** + * Sets [Builder.streamOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.streamOptions] with a well-typed [StreamOptions] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun streamOptions(streamOptions: JsonField) = apply { + this.streamOptions = streamOptions + } + + fun temperature(temperature: Double?) = temperature(JsonField.ofNullable(temperature)) + + /** + * Alias for [Builder.temperature]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun temperature(temperature: Double) = temperature(temperature as Double?) + + /** Alias for calling [Builder.temperature] with `temperature.orElse(null)`. */ + fun temperature(temperature: Optional) = temperature(temperature.getOrNull()) + + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + fun toolChoice(toolChoice: ToolChoice?) = toolChoice(JsonField.ofNullable(toolChoice)) + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [ToolChoice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolChoice(toolChoice: JsonField) = apply { + this.toolChoice = toolChoice + } + + /** Alias for calling [toolChoice] with `ToolChoice.ofString(string)`. */ + fun toolChoice(string: String) = toolChoice(ToolChoice.ofString(string)) + + /** Alias for calling [toolChoice] with `ToolChoice.ofUnionMember1(unionMember1)`. */ + fun toolChoice(unionMember1: ToolChoice.UnionMember1) = + toolChoice(ToolChoice.ofUnionMember1(unionMember1)) + + fun tools(tools: List?) = tools(JsonField.ofNullable(tools)) + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tools(tools: JsonField>) = apply { + this.tools = tools.map { it.toMutableList() } + } + + /** + * Adds a single [Tool] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: Tool) = apply { + tools = + (tools ?: JsonField.of(mutableListOf())).also { + checkKnown("tools", it).add(tool) + } + } + + fun topLogprobs(topLogprobs: Long?) = topLogprobs(JsonField.ofNullable(topLogprobs)) + + /** + * Alias for [Builder.topLogprobs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topLogprobs(topLogprobs: Long) = topLogprobs(topLogprobs as Long?) + + /** Alias for calling [Builder.topLogprobs] with `topLogprobs.orElse(null)`. */ + fun topLogprobs(topLogprobs: Optional) = topLogprobs(topLogprobs.getOrNull()) + + /** + * Sets [Builder.topLogprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.topLogprobs] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topLogprobs(topLogprobs: JsonField) = apply { this.topLogprobs = topLogprobs } + + fun topP(topP: Double?) = topP(JsonField.ofNullable(topP)) + + /** + * Alias for [Builder.topP]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun topP(topP: Double) = topP(topP as Double?) + + /** Alias for calling [Builder.topP] with `topP.orElse(null)`. */ + fun topP(topP: Optional) = topP(topP.getOrNull()) + + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topP(topP: JsonField) = apply { this.topP = topP } + + fun user(user: String?) = user(JsonField.ofNullable(user)) + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun user(user: JsonField) = apply { this.user = user } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .bodyModel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("messages", messages).map { it.toImmutable() }, + checkRequired("bodyModel", bodyModel), + caching, + contextWindowFallbackDict, + (fallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + frequencyPenalty, + functionCall, + (functions ?: JsonMissing.of()).map { it.toImmutable() }, + (guardrails ?: JsonMissing.of()).map { it.toImmutable() }, + logitBias, + logprobs, + maxTokens, + metadata, + n, + numRetries, + parallelToolCalls, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop, + stream, + streamOptions, + temperature, + toolChoice, + (tools ?: JsonMissing.of()).map { it.toImmutable() }, + topLogprobs, + topP, + user, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + messages().forEach { it.validate() } + bodyModel() + caching() + contextWindowFallbackDict().ifPresent { it.validate() } + fallbacks() + frequencyPenalty() + functionCall().ifPresent { it.validate() } + functions().ifPresent { it.forEach { it.validate() } } + guardrails() + logitBias().ifPresent { it.validate() } + logprobs() + maxTokens() + metadata().ifPresent { it.validate() } + n() + numRetries() + parallelToolCalls() + presencePenalty() + responseFormat().ifPresent { it.validate() } + seed() + serviceTier() + stop().ifPresent { it.validate() } + stream() + streamOptions().ifPresent { it.validate() } + temperature() + toolChoice().ifPresent { it.validate() } + tools().ifPresent { it.forEach { it.validate() } } + topLogprobs() + topP() + user() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (messages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (bodyModel.asKnown().isPresent) 1 else 0) + + (if (caching.asKnown().isPresent) 1 else 0) + + (contextWindowFallbackDict.asKnown().getOrNull()?.validity() ?: 0) + + (fallbacks.asKnown().getOrNull()?.size ?: 0) + + (if (frequencyPenalty.asKnown().isPresent) 1 else 0) + + (functionCall.asKnown().getOrNull()?.validity() ?: 0) + + (functions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (guardrails.asKnown().getOrNull()?.size ?: 0) + + (logitBias.asKnown().getOrNull()?.validity() ?: 0) + + (if (logprobs.asKnown().isPresent) 1 else 0) + + (if (maxTokens.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (n.asKnown().isPresent) 1 else 0) + + (if (numRetries.asKnown().isPresent) 1 else 0) + + (if (parallelToolCalls.asKnown().isPresent) 1 else 0) + + (if (presencePenalty.asKnown().isPresent) 1 else 0) + + (responseFormat.asKnown().getOrNull()?.validity() ?: 0) + + (if (seed.asKnown().isPresent) 1 else 0) + + (if (serviceTier.asKnown().isPresent) 1 else 0) + + (stop.asKnown().getOrNull()?.validity() ?: 0) + + (if (stream.asKnown().isPresent) 1 else 0) + + (streamOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (temperature.asKnown().isPresent) 1 else 0) + + (toolChoice.asKnown().getOrNull()?.validity() ?: 0) + + (tools.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (topLogprobs.asKnown().isPresent) 1 else 0) + + (if (topP.asKnown().isPresent) 1 else 0) + + (if (user.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + messages == other.messages && + bodyModel == other.bodyModel && + caching == other.caching && + contextWindowFallbackDict == other.contextWindowFallbackDict && + fallbacks == other.fallbacks && + frequencyPenalty == other.frequencyPenalty && + functionCall == other.functionCall && + functions == other.functions && + guardrails == other.guardrails && + logitBias == other.logitBias && + logprobs == other.logprobs && + maxTokens == other.maxTokens && + metadata == other.metadata && + n == other.n && + numRetries == other.numRetries && + parallelToolCalls == other.parallelToolCalls && + presencePenalty == other.presencePenalty && + responseFormat == other.responseFormat && + seed == other.seed && + serviceTier == other.serviceTier && + stop == other.stop && + stream == other.stream && + streamOptions == other.streamOptions && + temperature == other.temperature && + toolChoice == other.toolChoice && + tools == other.tools && + topLogprobs == other.topLogprobs && + topP == other.topP && + user == other.user && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + messages, + bodyModel, + caching, + contextWindowFallbackDict, + fallbacks, + frequencyPenalty, + functionCall, + functions, + guardrails, + logitBias, + logprobs, + maxTokens, + metadata, + n, + numRetries, + parallelToolCalls, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop, + stream, + streamOptions, + temperature, + toolChoice, + tools, + topLogprobs, + topP, + user, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{messages=$messages, bodyModel=$bodyModel, caching=$caching, contextWindowFallbackDict=$contextWindowFallbackDict, fallbacks=$fallbacks, frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, functions=$functions, guardrails=$guardrails, logitBias=$logitBias, logprobs=$logprobs, maxTokens=$maxTokens, metadata=$metadata, n=$n, numRetries=$numRetries, parallelToolCalls=$parallelToolCalls, presencePenalty=$presencePenalty, responseFormat=$responseFormat, seed=$seed, serviceTier=$serviceTier, stop=$stop, stream=$stream, streamOptions=$streamOptions, temperature=$temperature, toolChoice=$toolChoice, tools=$tools, topLogprobs=$topLogprobs, topP=$topP, user=$user, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + class Message + private constructor( + private val chatCompletionUser: ChatCompletionUserMessage? = null, + private val chatCompletionAssistant: ChatCompletionAssistantMessage? = null, + private val chatCompletionTool: ChatCompletionToolMessage? = null, + private val chatCompletionSystem: ChatCompletionSystemMessage? = null, + private val chatCompletionFunction: ChatCompletionFunctionMessage? = null, + private val chatCompletionDeveloper: ChatCompletionDeveloperMessage? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletionUser(): Optional = + Optional.ofNullable(chatCompletionUser) + + fun chatCompletionAssistant(): Optional = + Optional.ofNullable(chatCompletionAssistant) + + fun chatCompletionTool(): Optional = + Optional.ofNullable(chatCompletionTool) + + fun chatCompletionSystem(): Optional = + Optional.ofNullable(chatCompletionSystem) + + fun chatCompletionFunction(): Optional = + Optional.ofNullable(chatCompletionFunction) + + fun chatCompletionDeveloper(): Optional = + Optional.ofNullable(chatCompletionDeveloper) + + fun isChatCompletionUser(): Boolean = chatCompletionUser != null + + fun isChatCompletionAssistant(): Boolean = chatCompletionAssistant != null + + fun isChatCompletionTool(): Boolean = chatCompletionTool != null + + fun isChatCompletionSystem(): Boolean = chatCompletionSystem != null + + fun isChatCompletionFunction(): Boolean = chatCompletionFunction != null + + fun isChatCompletionDeveloper(): Boolean = chatCompletionDeveloper != null + + fun asChatCompletionUser(): ChatCompletionUserMessage = + chatCompletionUser.getOrThrow("chatCompletionUser") + + fun asChatCompletionAssistant(): ChatCompletionAssistantMessage = + chatCompletionAssistant.getOrThrow("chatCompletionAssistant") + + fun asChatCompletionTool(): ChatCompletionToolMessage = + chatCompletionTool.getOrThrow("chatCompletionTool") + + fun asChatCompletionSystem(): ChatCompletionSystemMessage = + chatCompletionSystem.getOrThrow("chatCompletionSystem") + + fun asChatCompletionFunction(): ChatCompletionFunctionMessage = + chatCompletionFunction.getOrThrow("chatCompletionFunction") + + fun asChatCompletionDeveloper(): ChatCompletionDeveloperMessage = + chatCompletionDeveloper.getOrThrow("chatCompletionDeveloper") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletionUser != null -> visitor.visitChatCompletionUser(chatCompletionUser) + chatCompletionAssistant != null -> + visitor.visitChatCompletionAssistant(chatCompletionAssistant) + chatCompletionTool != null -> visitor.visitChatCompletionTool(chatCompletionTool) + chatCompletionSystem != null -> + visitor.visitChatCompletionSystem(chatCompletionSystem) + chatCompletionFunction != null -> + visitor.visitChatCompletionFunction(chatCompletionFunction) + chatCompletionDeveloper != null -> + visitor.visitChatCompletionDeveloper(chatCompletionDeveloper) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletionUser( + chatCompletionUser: ChatCompletionUserMessage + ) { + chatCompletionUser.validate() + } + + override fun visitChatCompletionAssistant( + chatCompletionAssistant: ChatCompletionAssistantMessage + ) { + chatCompletionAssistant.validate() + } + + override fun visitChatCompletionTool( + chatCompletionTool: ChatCompletionToolMessage + ) { + chatCompletionTool.validate() + } + + override fun visitChatCompletionSystem( + chatCompletionSystem: ChatCompletionSystemMessage + ) { + chatCompletionSystem.validate() + } + + override fun visitChatCompletionFunction( + chatCompletionFunction: ChatCompletionFunctionMessage + ) { + chatCompletionFunction.validate() + } + + override fun visitChatCompletionDeveloper( + chatCompletionDeveloper: ChatCompletionDeveloperMessage + ) { + chatCompletionDeveloper.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletionUser( + chatCompletionUser: ChatCompletionUserMessage + ) = chatCompletionUser.validity() + + override fun visitChatCompletionAssistant( + chatCompletionAssistant: ChatCompletionAssistantMessage + ) = chatCompletionAssistant.validity() + + override fun visitChatCompletionTool( + chatCompletionTool: ChatCompletionToolMessage + ) = chatCompletionTool.validity() + + override fun visitChatCompletionSystem( + chatCompletionSystem: ChatCompletionSystemMessage + ) = chatCompletionSystem.validity() + + override fun visitChatCompletionFunction( + chatCompletionFunction: ChatCompletionFunctionMessage + ) = chatCompletionFunction.validity() + + override fun visitChatCompletionDeveloper( + chatCompletionDeveloper: ChatCompletionDeveloperMessage + ) = chatCompletionDeveloper.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Message && + chatCompletionUser == other.chatCompletionUser && + chatCompletionAssistant == other.chatCompletionAssistant && + chatCompletionTool == other.chatCompletionTool && + chatCompletionSystem == other.chatCompletionSystem && + chatCompletionFunction == other.chatCompletionFunction && + chatCompletionDeveloper == other.chatCompletionDeveloper + } + + override fun hashCode(): Int = + Objects.hash( + chatCompletionUser, + chatCompletionAssistant, + chatCompletionTool, + chatCompletionSystem, + chatCompletionFunction, + chatCompletionDeveloper, + ) + + override fun toString(): String = + when { + chatCompletionUser != null -> "Message{chatCompletionUser=$chatCompletionUser}" + chatCompletionAssistant != null -> + "Message{chatCompletionAssistant=$chatCompletionAssistant}" + chatCompletionTool != null -> "Message{chatCompletionTool=$chatCompletionTool}" + chatCompletionSystem != null -> + "Message{chatCompletionSystem=$chatCompletionSystem}" + chatCompletionFunction != null -> + "Message{chatCompletionFunction=$chatCompletionFunction}" + chatCompletionDeveloper != null -> + "Message{chatCompletionDeveloper=$chatCompletionDeveloper}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + + companion object { + + @JvmStatic + fun ofChatCompletionUser(chatCompletionUser: ChatCompletionUserMessage) = + Message(chatCompletionUser = chatCompletionUser) + + @JvmStatic + fun ofChatCompletionAssistant(chatCompletionAssistant: ChatCompletionAssistantMessage) = + Message(chatCompletionAssistant = chatCompletionAssistant) + + @JvmStatic + fun ofChatCompletionTool(chatCompletionTool: ChatCompletionToolMessage) = + Message(chatCompletionTool = chatCompletionTool) + + @JvmStatic + fun ofChatCompletionSystem(chatCompletionSystem: ChatCompletionSystemMessage) = + Message(chatCompletionSystem = chatCompletionSystem) + + @JvmStatic + fun ofChatCompletionFunction(chatCompletionFunction: ChatCompletionFunctionMessage) = + Message(chatCompletionFunction = chatCompletionFunction) + + @JvmStatic + fun ofChatCompletionDeveloper(chatCompletionDeveloper: ChatCompletionDeveloperMessage) = + Message(chatCompletionDeveloper = chatCompletionDeveloper) + } + + /** + * An interface that defines how to map each variant of [Message] to a value of type [T]. + */ + interface Visitor { + + fun visitChatCompletionUser(chatCompletionUser: ChatCompletionUserMessage): T + + fun visitChatCompletionAssistant( + chatCompletionAssistant: ChatCompletionAssistantMessage + ): T + + fun visitChatCompletionTool(chatCompletionTool: ChatCompletionToolMessage): T + + fun visitChatCompletionSystem(chatCompletionSystem: ChatCompletionSystemMessage): T + + fun visitChatCompletionFunction( + chatCompletionFunction: ChatCompletionFunctionMessage + ): T + + fun visitChatCompletionDeveloper( + chatCompletionDeveloper: ChatCompletionDeveloperMessage + ): T + + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Message: $json") + } + } + + internal class Deserializer : BaseDeserializer(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Message(chatCompletionUser = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionAssistant = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Message(chatCompletionTool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionSystem = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionFunction = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(chatCompletionDeveloper = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Message(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletionUser != null -> + generator.writeObject(value.chatCompletionUser) + value.chatCompletionAssistant != null -> + generator.writeObject(value.chatCompletionAssistant) + value.chatCompletionTool != null -> + generator.writeObject(value.chatCompletionTool) + value.chatCompletionSystem != null -> + generator.writeObject(value.chatCompletionSystem) + value.chatCompletionFunction != null -> + generator.writeObject(value.chatCompletionFunction) + value.chatCompletionDeveloper != null -> + generator.writeObject(value.chatCompletionDeveloper) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + class ChatCompletionUserMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(content, role, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("user") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionUserMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionUserMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("user") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionUserMessage: ChatCompletionUserMessage) = apply { + content = chatCompletionUserMessage.content + role = chatCompletionUserMessage.role + cacheControl = chatCompletionUserMessage.cacheControl + additionalProperties = + chatCompletionUserMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = + content( + Content.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + ) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("user") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionUserMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionUserMessage = + ChatCompletionUserMessage( + checkRequired("content", content), + role, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionUserMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("user")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("user")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent2s: List? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent2s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent2s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent2s(): Boolean = + unnamedSchemaWithArrayParent2s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent2s(): List = + unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent2s != null -> + visitor.visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) { + unnamedSchemaWithArrayParent2s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = unnamedSchemaWithArrayParent2s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent2s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent2s != null -> + "Content{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = + Content( + unnamedSchemaWithArrayParent2s = + unnamedSchemaWithArrayParent2s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent2s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent2s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent2s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 + private constructor( + private val chatCompletionTextObject: ChatCompletionTextObject? = null, + private val chatCompletionImageObject: ChatCompletionImageObject? = null, + private val chatCompletionAudioObject: ChatCompletionAudioObject? = null, + private val chatCompletionDocumentObject: ChatCompletionDocumentObject? = null, + private val chatCompletionVideoObject: ChatCompletionVideoObject? = null, + private val chatCompletionFileObject: ChatCompletionFileObject? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletionTextObject(): Optional = + Optional.ofNullable(chatCompletionTextObject) + + fun chatCompletionImageObject(): Optional = + Optional.ofNullable(chatCompletionImageObject) + + fun chatCompletionAudioObject(): Optional = + Optional.ofNullable(chatCompletionAudioObject) + + fun chatCompletionDocumentObject(): Optional = + Optional.ofNullable(chatCompletionDocumentObject) + + fun chatCompletionVideoObject(): Optional = + Optional.ofNullable(chatCompletionVideoObject) + + fun chatCompletionFileObject(): Optional = + Optional.ofNullable(chatCompletionFileObject) + + fun isChatCompletionTextObject(): Boolean = chatCompletionTextObject != null + + fun isChatCompletionImageObject(): Boolean = chatCompletionImageObject != null + + fun isChatCompletionAudioObject(): Boolean = chatCompletionAudioObject != null + + fun isChatCompletionDocumentObject(): Boolean = + chatCompletionDocumentObject != null + + fun isChatCompletionVideoObject(): Boolean = chatCompletionVideoObject != null + + fun isChatCompletionFileObject(): Boolean = chatCompletionFileObject != null + + fun asChatCompletionTextObject(): ChatCompletionTextObject = + chatCompletionTextObject.getOrThrow("chatCompletionTextObject") + + fun asChatCompletionImageObject(): ChatCompletionImageObject = + chatCompletionImageObject.getOrThrow("chatCompletionImageObject") + + fun asChatCompletionAudioObject(): ChatCompletionAudioObject = + chatCompletionAudioObject.getOrThrow("chatCompletionAudioObject") + + fun asChatCompletionDocumentObject(): ChatCompletionDocumentObject = + chatCompletionDocumentObject.getOrThrow("chatCompletionDocumentObject") + + fun asChatCompletionVideoObject(): ChatCompletionVideoObject = + chatCompletionVideoObject.getOrThrow("chatCompletionVideoObject") + + fun asChatCompletionFileObject(): ChatCompletionFileObject = + chatCompletionFileObject.getOrThrow("chatCompletionFileObject") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletionTextObject != null -> + visitor.visitChatCompletionTextObject(chatCompletionTextObject) + chatCompletionImageObject != null -> + visitor.visitChatCompletionImageObject(chatCompletionImageObject) + chatCompletionAudioObject != null -> + visitor.visitChatCompletionAudioObject(chatCompletionAudioObject) + chatCompletionDocumentObject != null -> + visitor.visitChatCompletionDocumentObject( + chatCompletionDocumentObject + ) + chatCompletionVideoObject != null -> + visitor.visitChatCompletionVideoObject(chatCompletionVideoObject) + chatCompletionFileObject != null -> + visitor.visitChatCompletionFileObject(chatCompletionFileObject) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent2 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) { + chatCompletionTextObject.validate() + } + + override fun visitChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ) { + chatCompletionImageObject.validate() + } + + override fun visitChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ) { + chatCompletionAudioObject.validate() + } + + override fun visitChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) { + chatCompletionDocumentObject.validate() + } + + override fun visitChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ) { + chatCompletionVideoObject.validate() + } + + override fun visitChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ) { + chatCompletionFileObject.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = chatCompletionTextObject.validity() + + override fun visitChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ) = chatCompletionImageObject.validity() + + override fun visitChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ) = chatCompletionAudioObject.validity() + + override fun visitChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) = chatCompletionDocumentObject.validity() + + override fun visitChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ) = chatCompletionVideoObject.validity() + + override fun visitChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ) = chatCompletionFileObject.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent2 && + chatCompletionTextObject == other.chatCompletionTextObject && + chatCompletionImageObject == other.chatCompletionImageObject && + chatCompletionAudioObject == other.chatCompletionAudioObject && + chatCompletionDocumentObject == other.chatCompletionDocumentObject && + chatCompletionVideoObject == other.chatCompletionVideoObject && + chatCompletionFileObject == other.chatCompletionFileObject + } + + override fun hashCode(): Int = + Objects.hash( + chatCompletionTextObject, + chatCompletionImageObject, + chatCompletionAudioObject, + chatCompletionDocumentObject, + chatCompletionVideoObject, + chatCompletionFileObject, + ) + + override fun toString(): String = + when { + chatCompletionTextObject != null -> + "UnnamedSchemaWithArrayParent2{chatCompletionTextObject=$chatCompletionTextObject}" + chatCompletionImageObject != null -> + "UnnamedSchemaWithArrayParent2{chatCompletionImageObject=$chatCompletionImageObject}" + chatCompletionAudioObject != null -> + "UnnamedSchemaWithArrayParent2{chatCompletionAudioObject=$chatCompletionAudioObject}" + chatCompletionDocumentObject != null -> + "UnnamedSchemaWithArrayParent2{chatCompletionDocumentObject=$chatCompletionDocumentObject}" + chatCompletionVideoObject != null -> + "UnnamedSchemaWithArrayParent2{chatCompletionVideoObject=$chatCompletionVideoObject}" + chatCompletionFileObject != null -> + "UnnamedSchemaWithArrayParent2{chatCompletionFileObject=$chatCompletionFileObject}" + _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + } + + companion object { + + @JvmStatic + fun ofChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = + UnnamedSchemaWithArrayParent2( + chatCompletionTextObject = chatCompletionTextObject + ) + + @JvmStatic + fun ofChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ) = + UnnamedSchemaWithArrayParent2( + chatCompletionImageObject = chatCompletionImageObject + ) + + @JvmStatic + fun ofChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ) = + UnnamedSchemaWithArrayParent2( + chatCompletionAudioObject = chatCompletionAudioObject + ) + + @JvmStatic + fun ofChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) = + UnnamedSchemaWithArrayParent2( + chatCompletionDocumentObject = chatCompletionDocumentObject + ) + + @JvmStatic + fun ofChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ) = + UnnamedSchemaWithArrayParent2( + chatCompletionVideoObject = chatCompletionVideoObject + ) + + @JvmStatic + fun ofChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ) = + UnnamedSchemaWithArrayParent2( + chatCompletionFileObject = chatCompletionFileObject + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + */ + interface Visitor { + + fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ): T + + fun visitChatCompletionImageObject( + chatCompletionImageObject: ChatCompletionImageObject + ): T + + fun visitChatCompletionAudioObject( + chatCompletionAudioObject: ChatCompletionAudioObject + ): T + + fun visitChatCompletionDocumentObject( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ): T + + fun visitChatCompletionVideoObject( + chatCompletionVideoObject: ChatCompletionVideoObject + ): T + + fun visitChatCompletionFileObject( + chatCompletionFileObject: ChatCompletionFileObject + ): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent2] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + chatCompletionTextObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + chatCompletionImageObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + chatCompletionAudioObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + chatCompletionDocumentObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + chatCompletionVideoObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + chatCompletionFileObject = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from boolean). + 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent2, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletionTextObject != null -> + generator.writeObject(value.chatCompletionTextObject) + value.chatCompletionImageObject != null -> + generator.writeObject(value.chatCompletionImageObject) + value.chatCompletionAudioObject != null -> + generator.writeObject(value.chatCompletionAudioObject) + value.chatCompletionDocumentObject != null -> + generator.writeObject(value.chatCompletionDocumentObject) + value.chatCompletionVideoObject != null -> + generator.writeObject(value.chatCompletionVideoObject) + value.chatCompletionFileObject != null -> + generator.writeObject(value.chatCompletionFileObject) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if + * the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionImageObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(imageUrl, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("image_url") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionImageObject]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionImageObject]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("image_url") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionImageObject: ChatCompletionImageObject + ) = apply { + imageUrl = chatCompletionImageObject.imageUrl + type = chatCompletionImageObject.type + additionalProperties = + chatCompletionImageObject.additionalProperties.toMutableMap() + } + + fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed + * [ImageUrl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** Alias for calling [imageUrl] with `ImageUrl.ofString(string)`. */ + fun imageUrl(string: String) = imageUrl(ImageUrl.ofString(string)) + + /** + * Alias for calling [imageUrl] with + * `ImageUrl.ofChatCompletionImageUrlObject(chatCompletionImageUrlObject)`. + */ + fun imageUrl( + chatCompletionImageUrlObject: ImageUrl.ChatCompletionImageUrlObject + ) = + imageUrl( + ImageUrl.ofChatCompletionImageUrlObject( + chatCompletionImageUrlObject + ) + ) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("image_url") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionImageObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionImageObject = + ChatCompletionImageObject( + checkRequired("imageUrl", imageUrl), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionImageObject = apply { + if (validated) { + return@apply + } + + imageUrl().validate() + _type().let { + if (it != JsonValue.from("image_url")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (imageUrl.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("image_url")) 1 else 0 } + + @JsonDeserialize(using = ImageUrl.Deserializer::class) + @JsonSerialize(using = ImageUrl.Serializer::class) + class ImageUrl + private constructor( + private val string: String? = null, + private val chatCompletionImageUrlObject: + ChatCompletionImageUrlObject? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionImageUrlObject(): + Optional = + Optional.ofNullable(chatCompletionImageUrlObject) + + fun isString(): Boolean = string != null + + fun isChatCompletionImageUrlObject(): Boolean = + chatCompletionImageUrlObject != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionImageUrlObject(): ChatCompletionImageUrlObject = + chatCompletionImageUrlObject.getOrThrow( + "chatCompletionImageUrlObject" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionImageUrlObject != null -> + visitor.visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ImageUrl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject: + ChatCompletionImageUrlObject + ) { + chatCompletionImageUrlObject.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject: + ChatCompletionImageUrlObject + ) = chatCompletionImageUrlObject.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ImageUrl && + string == other.string && + chatCompletionImageUrlObject == + other.chatCompletionImageUrlObject + } + + override fun hashCode(): Int = + Objects.hash(string, chatCompletionImageUrlObject) + + override fun toString(): String = + when { + string != null -> "ImageUrl{string=$string}" + chatCompletionImageUrlObject != null -> + "ImageUrl{chatCompletionImageUrlObject=$chatCompletionImageUrlObject}" + _json != null -> "ImageUrl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ImageUrl") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ImageUrl(string = string) + + @JvmStatic + fun ofChatCompletionImageUrlObject( + chatCompletionImageUrlObject: ChatCompletionImageUrlObject + ) = + ImageUrl( + chatCompletionImageUrlObject = chatCompletionImageUrlObject + ) + } + + /** + * An interface that defines how to map each variant of [ImageUrl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionImageUrlObject( + chatCompletionImageUrlObject: ChatCompletionImageUrlObject + ): T + + /** + * Maps an unknown variant of [ImageUrl] to a value of type [T]. + * + * An instance of [ImageUrl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown ImageUrl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ImageUrl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ImageUrl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef< + ChatCompletionImageUrlObject + >(), + ) + ?.let { + ImageUrl( + chatCompletionImageUrlObject = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ImageUrl(string = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> ImageUrl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ImageUrl::class) { + + override fun serialize( + value: ImageUrl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionImageUrlObject != null -> + generator.writeObject( + value.chatCompletionImageUrlObject + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ImageUrl") + } + } + } + + class ChatCompletionImageUrlObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val format: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") + @ExcludeMissing + url: JsonField = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + ) : this(url, detail, format, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("format") + @ExcludeMissing + fun _format(): JsonField = format + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionImageUrlObject]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionImageUrlObject]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var detail: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionImageUrlObject: ChatCompletionImageUrlObject + ) = apply { + url = chatCompletionImageUrlObject.url + detail = chatCompletionImageUrlObject.detail + format = chatCompletionImageUrlObject.format + additionalProperties = + chatCompletionImageUrlObject.additionalProperties + .toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun format(format: String) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { + this.format = format + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [ChatCompletionImageUrlObject]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionImageUrlObject = + ChatCompletionImageUrlObject( + checkRequired("url", url), + detail, + format, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionImageUrlObject = apply { + if (validated) { + return@apply + } + + url() + detail() + format() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (if (detail.asKnown().isPresent) 1 else 0) + + (if (format.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionImageUrlObject && + url == other.url && + detail == other.detail && + format == other.format && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, detail, format, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionImageUrlObject{url=$url, detail=$detail, format=$format, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionImageObject && + imageUrl == other.imageUrl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionImageObject{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + } + + class ChatCompletionAudioObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val inputAudio: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("input_audio") + @ExcludeMissing + inputAudio: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(inputAudio, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun inputAudio(): InputAudio = inputAudio.getRequired("input_audio") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("input_audio") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [inputAudio]. + * + * Unlike [inputAudio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_audio") + @ExcludeMissing + fun _inputAudio(): JsonField = inputAudio + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionAudioObject]. + * + * The following fields are required: + * ```java + * .inputAudio() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionAudioObject]. */ + class Builder internal constructor() { + + private var inputAudio: JsonField? = null + private var type: JsonValue = JsonValue.from("input_audio") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionAudioObject: ChatCompletionAudioObject + ) = apply { + inputAudio = chatCompletionAudioObject.inputAudio + type = chatCompletionAudioObject.type + additionalProperties = + chatCompletionAudioObject.additionalProperties.toMutableMap() + } + + fun inputAudio(inputAudio: InputAudio) = + inputAudio(JsonField.of(inputAudio)) + + /** + * Sets [Builder.inputAudio] to an arbitrary JSON value. + * + * You should usually call [Builder.inputAudio] with a well-typed + * [InputAudio] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun inputAudio(inputAudio: JsonField) = apply { + this.inputAudio = inputAudio + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("input_audio") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionAudioObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .inputAudio() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionAudioObject = + ChatCompletionAudioObject( + checkRequired("inputAudio", inputAudio), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionAudioObject = apply { + if (validated) { + return@apply + } + + inputAudio().validate() + _type().let { + if (it != JsonValue.from("input_audio")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (inputAudio.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("input_audio")) 1 else 0 } + + class InputAudio + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val format: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + ) : this(data, format, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun data(): String = data.getRequired("data") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun format(): Format = format.getRequired("format") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("format") + @ExcludeMissing + fun _format(): JsonField = format + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InputAudio]. + * + * The following fields are required: + * ```java + * .data() + * .format() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputAudio]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var format: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(inputAudio: InputAudio) = apply { + data = inputAudio.data + format = inputAudio.format + additionalProperties = + inputAudio.additionalProperties.toMutableMap() + } + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed + * [Format] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { + this.format = format + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InputAudio]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .data() + * .format() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InputAudio = + InputAudio( + checkRequired("data", data), + checkRequired("format", format), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InputAudio = apply { + if (validated) { + return@apply + } + + data() + format().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (data.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + class Format + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized + * from data that doesn't match any known member, and you want to + * know that value. For example, if the SDK is on an older version + * than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val WAV = of("wav") + + @JvmField val MP3 = of("mp3") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + WAV, + MP3, + } + + /** + * An enum containing [Format]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known + * member. For example, if the SDK is on an older version than the + * API, then the API may respond with new members that the SDK is + * unaware of. + * - It was constructed with an arbitrary value using the [of] + * method. + */ + enum class Value { + WAV, + MP3, + /** + * An enum member indicating that [Format] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's + * value, or [Value._UNKNOWN] if the class was instantiated with an + * unknown value. + * + * Use the [known] method instead if you're certain the value is + * always known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + WAV -> Value.WAV + MP3 -> Value.MP3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's + * value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + WAV -> Known.WAV + MP3 -> Known.MP3 + else -> + throw HanzoInvalidDataException( + "Unknown Format: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputAudio && + data == other.data && + format == other.format && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, format, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputAudio{data=$data, format=$format, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionAudioObject && + inputAudio == other.inputAudio && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inputAudio, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionAudioObject{inputAudio=$inputAudio, type=$type, additionalProperties=$additionalProperties}" + } + + class ChatCompletionDocumentObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val citations: JsonField, + private val context: JsonField, + private val source: JsonField, + private val title: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("citations") + @ExcludeMissing + citations: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("title") + @ExcludeMissing + title: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(citations, context, source, title, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun citations(): Optional = citations.getOptional("citations") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun context(): String = context.getRequired("context") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun source(): Source = source.getRequired("source") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("document") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [citations]. + * + * Unlike [citations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("citations") + @ExcludeMissing + fun _citations(): JsonField = citations + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("title") + @ExcludeMissing + fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionDocumentObject]. + * + * The following fields are required: + * ```java + * .citations() + * .context() + * .source() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionDocumentObject]. */ + class Builder internal constructor() { + + private var citations: JsonField? = null + private var context: JsonField? = null + private var source: JsonField? = null + private var title: JsonField? = null + private var type: JsonValue = JsonValue.from("document") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionDocumentObject: ChatCompletionDocumentObject + ) = apply { + citations = chatCompletionDocumentObject.citations + context = chatCompletionDocumentObject.context + source = chatCompletionDocumentObject.source + title = chatCompletionDocumentObject.title + type = chatCompletionDocumentObject.type + additionalProperties = + chatCompletionDocumentObject.additionalProperties.toMutableMap() + } + + fun citations(citations: Citations?) = + citations(JsonField.ofNullable(citations)) + + /** + * Alias for calling [Builder.citations] with `citations.orElse(null)`. + */ + fun citations(citations: Optional) = + citations(citations.getOrNull()) + + /** + * Sets [Builder.citations] to an arbitrary JSON value. + * + * You should usually call [Builder.citations] with a well-typed + * [Citations] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun citations(citations: JsonField) = apply { + this.citations = citations + } + + fun context(context: String) = context(JsonField.of(context)) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun context(context: JsonField) = apply { + this.context = context + } + + fun source(source: Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("document") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionDocumentObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .citations() + * .context() + * .source() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionDocumentObject = + ChatCompletionDocumentObject( + checkRequired("citations", citations), + checkRequired("context", context), + checkRequired("source", source), + checkRequired("title", title), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionDocumentObject = apply { + if (validated) { + return@apply + } + + citations().ifPresent { it.validate() } + context() + source().validate() + title() + _type().let { + if (it != JsonValue.from("document")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (citations.asKnown().getOrNull()?.validity() ?: 0) + + (if (context.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("document")) 1 else 0 } + + class Citations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") + @ExcludeMissing + enabled: JsonField = JsonMissing.of() + ) : this(enabled, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun enabled(): Boolean = enabled.getRequired("enabled") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enabled") + @ExcludeMissing + fun _enabled(): JsonField = enabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Citations]. + * + * The following fields are required: + * ```java + * .enabled() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Citations]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(citations: Citations) = apply { + enabled = citations.enabled + additionalProperties = + citations.additionalProperties.toMutableMap() + } + + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun enabled(enabled: JsonField) = apply { + this.enabled = enabled + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Citations]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .enabled() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Citations = + Citations( + checkRequired("enabled", enabled), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Citations = apply { + if (validated) { + return@apply + } + + enabled() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (enabled.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Citations && + enabled == other.enabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(enabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Citations{enabled=$enabled, additionalProperties=$additionalProperties}" + } + + class Source + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val mediaType: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("media_type") + @ExcludeMissing + mediaType: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(data, mediaType, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun data(): String = data.getRequired("data") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun mediaType(): String = mediaType.getRequired("media_type") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if + * the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [mediaType]. + * + * Unlike [mediaType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("media_type") + @ExcludeMissing + fun _mediaType(): JsonField = mediaType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Source]. + * + * The following fields are required: + * ```java + * .data() + * .mediaType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Source]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var mediaType: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(source: Source) = apply { + data = source.data + mediaType = source.mediaType + type = source.type + additionalProperties = + source.additionalProperties.toMutableMap() + } + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun mediaType(mediaType: String) = + mediaType(JsonField.of(mediaType)) + + /** + * Sets [Builder.mediaType] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaType] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun mediaType(mediaType: JsonField) = apply { + this.mediaType = mediaType + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Source]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .data() + * .mediaType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Source = + Source( + checkRequired("data", data), + checkRequired("mediaType", mediaType), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + data() + mediaType() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (data.asKnown().isPresent) 1 else 0) + + (if (mediaType.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Source && + data == other.data && + mediaType == other.mediaType && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, mediaType, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Source{data=$data, mediaType=$mediaType, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionDocumentObject && + citations == other.citations && + context == other.context && + source == other.source && + title == other.title && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + citations, + context, + source, + title, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionDocumentObject{citations=$citations, context=$context, source=$source, title=$title, type=$type, additionalProperties=$additionalProperties}" + } + + class ChatCompletionVideoObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val videoUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("video_url") + @ExcludeMissing + videoUrl: JsonField = JsonMissing.of(), + ) : this(type, videoUrl, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("video_url") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun videoUrl(): VideoUrl = videoUrl.getRequired("video_url") + + /** + * Returns the raw JSON value of [videoUrl]. + * + * Unlike [videoUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("video_url") + @ExcludeMissing + fun _videoUrl(): JsonField = videoUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionVideoObject]. + * + * The following fields are required: + * ```java + * .videoUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionVideoObject]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("video_url") + private var videoUrl: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionVideoObject: ChatCompletionVideoObject + ) = apply { + type = chatCompletionVideoObject.type + videoUrl = chatCompletionVideoObject.videoUrl + additionalProperties = + chatCompletionVideoObject.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("video_url") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun videoUrl(videoUrl: VideoUrl) = videoUrl(JsonField.of(videoUrl)) + + /** + * Sets [Builder.videoUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.videoUrl] with a well-typed + * [VideoUrl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun videoUrl(videoUrl: JsonField) = apply { + this.videoUrl = videoUrl + } + + /** Alias for calling [videoUrl] with `VideoUrl.ofString(string)`. */ + fun videoUrl(string: String) = videoUrl(VideoUrl.ofString(string)) + + /** + * Alias for calling [videoUrl] with + * `VideoUrl.ofChatCompletionVideoUrlObject(chatCompletionVideoUrlObject)`. + */ + fun videoUrl( + chatCompletionVideoUrlObject: VideoUrl.ChatCompletionVideoUrlObject + ) = + videoUrl( + VideoUrl.ofChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject + ) + ) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionVideoObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .videoUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionVideoObject = + ChatCompletionVideoObject( + type, + checkRequired("videoUrl", videoUrl), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionVideoObject = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("video_url")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + videoUrl().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("video_url")) 1 else 0 } + + (videoUrl.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = VideoUrl.Deserializer::class) + @JsonSerialize(using = VideoUrl.Serializer::class) + class VideoUrl + private constructor( + private val string: String? = null, + private val chatCompletionVideoUrlObject: + ChatCompletionVideoUrlObject? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionVideoUrlObject(): + Optional = + Optional.ofNullable(chatCompletionVideoUrlObject) + + fun isString(): Boolean = string != null + + fun isChatCompletionVideoUrlObject(): Boolean = + chatCompletionVideoUrlObject != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionVideoUrlObject(): ChatCompletionVideoUrlObject = + chatCompletionVideoUrlObject.getOrThrow( + "chatCompletionVideoUrlObject" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionVideoUrlObject != null -> + visitor.visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): VideoUrl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: + ChatCompletionVideoUrlObject + ) { + chatCompletionVideoUrlObject.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: + ChatCompletionVideoUrlObject + ) = chatCompletionVideoUrlObject.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoUrl && + string == other.string && + chatCompletionVideoUrlObject == + other.chatCompletionVideoUrlObject + } + + override fun hashCode(): Int = + Objects.hash(string, chatCompletionVideoUrlObject) + + override fun toString(): String = + when { + string != null -> "VideoUrl{string=$string}" + chatCompletionVideoUrlObject != null -> + "VideoUrl{chatCompletionVideoUrlObject=$chatCompletionVideoUrlObject}" + _json != null -> "VideoUrl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid VideoUrl") + } + + companion object { + + @JvmStatic fun ofString(string: String) = VideoUrl(string = string) + + @JvmStatic + fun ofChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: ChatCompletionVideoUrlObject + ) = + VideoUrl( + chatCompletionVideoUrlObject = chatCompletionVideoUrlObject + ) + } + + /** + * An interface that defines how to map each variant of [VideoUrl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionVideoUrlObject( + chatCompletionVideoUrlObject: ChatCompletionVideoUrlObject + ): T + + /** + * Maps an unknown variant of [VideoUrl] to a value of type [T]. + * + * An instance of [VideoUrl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown VideoUrl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(VideoUrl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): VideoUrl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef< + ChatCompletionVideoUrlObject + >(), + ) + ?.let { + VideoUrl( + chatCompletionVideoUrlObject = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { VideoUrl(string = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> VideoUrl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(VideoUrl::class) { + + override fun serialize( + value: VideoUrl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionVideoUrlObject != null -> + generator.writeObject( + value.chatCompletionVideoUrlObject + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid VideoUrl") + } + } + } + + class ChatCompletionVideoUrlObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") + @ExcludeMissing + url: JsonField = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(url, detail, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws HanzoInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionVideoUrlObject]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionVideoUrlObject]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionVideoUrlObject: ChatCompletionVideoUrlObject + ) = apply { + url = chatCompletionVideoUrlObject.url + detail = chatCompletionVideoUrlObject.detail + additionalProperties = + chatCompletionVideoUrlObject.additionalProperties + .toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [ChatCompletionVideoUrlObject]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionVideoUrlObject = + ChatCompletionVideoUrlObject( + checkRequired("url", url), + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionVideoUrlObject = apply { + if (validated) { + return@apply + } + + url() + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionVideoUrlObject && + url == other.url && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionVideoUrlObject{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionVideoObject && + type == other.type && + videoUrl == other.videoUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, videoUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionVideoObject{type=$type, videoUrl=$videoUrl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionFileObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val file: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file") + @ExcludeMissing + file: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(file, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun file(): File = file.getRequired("file") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("file") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [file]. + * + * Unlike [file], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): JsonField = file + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionFileObject]. + * + * The following fields are required: + * ```java + * .file() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionFileObject]. */ + class Builder internal constructor() { + + private var file: JsonField? = null + private var type: JsonValue = JsonValue.from("file") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionFileObject: ChatCompletionFileObject) = + apply { + file = chatCompletionFileObject.file + type = chatCompletionFileObject.type + additionalProperties = + chatCompletionFileObject.additionalProperties.toMutableMap() + } + + fun file(file: File) = file(JsonField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary JSON value. + * + * You should usually call [Builder.file] with a well-typed [File] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun file(file: JsonField) = apply { this.file = file } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("file") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionFileObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .file() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionFileObject = + ChatCompletionFileObject( + checkRequired("file", file), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionFileObject = apply { + if (validated) { + return@apply + } + + file().validate() + _type().let { + if (it != JsonValue.from("file")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (file.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("file")) 1 else 0 } + + class File + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileData: JsonField, + private val fileId: JsonField, + private val filename: JsonField, + private val format: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_data") + @ExcludeMissing + fileData: JsonField = JsonMissing.of(), + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + ) : this(fileData, fileId, filename, format, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun fileData(): Optional = fileData.getOptional("file_data") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("file_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun filename(): Optional = filename.getOptional("filename") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Returns the raw JSON value of [fileData]. + * + * Unlike [fileData], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("file_data") + @ExcludeMissing + fun _fileData(): JsonField = fileData + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("file_id") + @ExcludeMissing + fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filename") + @ExcludeMissing + fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("format") + @ExcludeMissing + fun _format(): JsonField = format + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [File]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [File]. */ + class Builder internal constructor() { + + private var fileData: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filename: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(file: File) = apply { + fileData = file.fileData + fileId = file.fileId + filename = file.filename + format = file.format + additionalProperties = file.additionalProperties.toMutableMap() + } + + fun fileData(fileData: String) = fileData(JsonField.of(fileData)) + + /** + * Sets [Builder.fileData] to an arbitrary JSON value. + * + * You should usually call [Builder.fileData] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun fileData(fileData: JsonField) = apply { + this.fileData = fileData + } + + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { + this.fileId = fileId + } + + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filename(filename: JsonField) = apply { + this.filename = filename + } + + fun format(format: String) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { + this.format = format + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [File]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): File = + File( + fileData, + fileId, + filename, + format, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): File = apply { + if (validated) { + return@apply + } + + fileData() + fileId() + filename() + format() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileData.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (format.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is File && + fileData == other.fileData && + fileId == other.fileId && + filename == other.filename && + format == other.format && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + fileData, + fileId, + filename, + format, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "File{fileData=$fileData, fileId=$fileId, filename=$filename, format=$format, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionFileObject && + file == other.file && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(file, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionFileObject{file=$file, type=$type, additionalProperties=$additionalProperties}" + } + } + } + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionUserMessage && + content == other.content && + role == other.role && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionUserMessage{content=$content, role=$role, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionAssistantMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val role: JsonValue, + private val cacheControl: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val reasoningContent: JsonField, + private val thinkingBlocks: JsonField>, + private val toolCalls: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_content") + @ExcludeMissing + reasoningContent: JsonField = JsonMissing.of(), + @JsonProperty("thinking_blocks") + @ExcludeMissing + thinkingBlocks: JsonField> = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + toolCalls: JsonField> = JsonMissing.of(), + ) : this( + role, + cacheControl, + content, + functionCall, + name, + reasoningContent, + thinkingBlocks, + toolCalls, + mutableMapOf(), + ) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("assistant") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun functionCall(): Optional = functionCall.getOptional("function_call") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reasoningContent(): Optional = + reasoningContent.getOptional("reasoning_content") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thinkingBlocks(): Optional> = + thinkingBlocks.getOptional("thinking_blocks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolCalls(): Optional> = toolCalls.getOptional("tool_calls") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall(): JsonField = functionCall + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [reasoningContent]. + * + * Unlike [reasoningContent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reasoning_content") + @ExcludeMissing + fun _reasoningContent(): JsonField = reasoningContent + + /** + * Returns the raw JSON value of [thinkingBlocks]. + * + * Unlike [thinkingBlocks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thinking_blocks") + @ExcludeMissing + fun _thinkingBlocks(): JsonField> = thinkingBlocks + + /** + * Returns the raw JSON value of [toolCalls]. + * + * Unlike [toolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls(): JsonField> = toolCalls + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionAssistantMessage]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionAssistantMessage]. */ + class Builder internal constructor() { + + private var role: JsonValue = JsonValue.from("assistant") + private var cacheControl: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var reasoningContent: JsonField = JsonMissing.of() + private var thinkingBlocks: JsonField>? = null + private var toolCalls: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionAssistantMessage: ChatCompletionAssistantMessage) = + apply { + role = chatCompletionAssistantMessage.role + cacheControl = chatCompletionAssistantMessage.cacheControl + content = chatCompletionAssistantMessage.content + functionCall = chatCompletionAssistantMessage.functionCall + name = chatCompletionAssistantMessage.name + reasoningContent = chatCompletionAssistantMessage.reasoningContent + thinkingBlocks = + chatCompletionAssistantMessage.thinkingBlocks.map { it.toMutableList() } + toolCalls = + chatCompletionAssistantMessage.toolCalls.map { it.toMutableList() } + additionalProperties = + chatCompletionAssistantMessage.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("assistant") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun content(content: Content?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = + content( + Content.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + ) + + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) + + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) + + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun reasoningContent(reasoningContent: String?) = + reasoningContent(JsonField.ofNullable(reasoningContent)) + + /** + * Alias for calling [Builder.reasoningContent] with + * `reasoningContent.orElse(null)`. + */ + fun reasoningContent(reasoningContent: Optional) = + reasoningContent(reasoningContent.getOrNull()) + + /** + * Sets [Builder.reasoningContent] to an arbitrary JSON value. + * + * You should usually call [Builder.reasoningContent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun reasoningContent(reasoningContent: JsonField) = apply { + this.reasoningContent = reasoningContent + } + + fun thinkingBlocks(thinkingBlocks: List?) = + thinkingBlocks(JsonField.ofNullable(thinkingBlocks)) + + /** + * Alias for calling [Builder.thinkingBlocks] with `thinkingBlocks.orElse(null)`. + */ + fun thinkingBlocks(thinkingBlocks: Optional>) = + thinkingBlocks(thinkingBlocks.getOrNull()) + + /** + * Sets [Builder.thinkingBlocks] to an arbitrary JSON value. + * + * You should usually call [Builder.thinkingBlocks] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thinkingBlocks(thinkingBlocks: JsonField>) = apply { + this.thinkingBlocks = thinkingBlocks.map { it.toMutableList() } + } + + /** + * Adds a single [ThinkingBlock] to [thinkingBlocks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThinkingBlock(thinkingBlock: ThinkingBlock) = apply { + thinkingBlocks = + (thinkingBlocks ?: JsonField.of(mutableListOf())).also { + checkKnown("thinkingBlocks", it).add(thinkingBlock) + } + } + + /** + * Alias for calling [addThinkingBlock] with + * `ThinkingBlock.ofChatCompletion(chatCompletion)`. + */ + fun addThinkingBlock(chatCompletion: ThinkingBlock.ChatCompletionThinkingBlock) = + addThinkingBlock(ThinkingBlock.ofChatCompletion(chatCompletion)) + + /** + * Alias for calling [addThinkingBlock] with + * `ThinkingBlock.ofChatCompletionRedacted(chatCompletionRedacted)`. + */ + fun addThinkingBlock( + chatCompletionRedacted: ThinkingBlock.ChatCompletionRedactedThinkingBlock + ) = addThinkingBlock(ThinkingBlock.ofChatCompletionRedacted(chatCompletionRedacted)) + + fun toolCalls(toolCalls: List?) = + toolCalls(JsonField.ofNullable(toolCalls)) + + /** Alias for calling [Builder.toolCalls] with `toolCalls.orElse(null)`. */ + fun toolCalls(toolCalls: Optional>) = + toolCalls(toolCalls.getOrNull()) + + /** + * Sets [Builder.toolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCalls] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun toolCalls(toolCalls: JsonField>) = apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [ToolCall] to [toolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addToolCall(toolCall: ToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCalls", it).add(toolCall) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionAssistantMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChatCompletionAssistantMessage = + ChatCompletionAssistantMessage( + role, + cacheControl, + content, + functionCall, + name, + reasoningContent, + (thinkingBlocks ?: JsonMissing.of()).map { it.toImmutable() }, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionAssistantMessage = apply { + if (validated) { + return@apply + } + + _role().let { + if (it != JsonValue.from("assistant")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + content().ifPresent { it.validate() } + functionCall().ifPresent { it.validate() } + name() + reasoningContent() + thinkingBlocks().ifPresent { it.forEach { it.validate() } } + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + role.let { if (it == JsonValue.from("assistant")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + (functionCall.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (reasoningContent.asKnown().isPresent) 1 else 0) + + (thinkingBlocks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (toolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent3s: List? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent3s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent3s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent3s(): Boolean = + unnamedSchemaWithArrayParent3s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent3s(): List = + unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent3s != null -> + visitor.visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) { + unnamedSchemaWithArrayParent3s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = unnamedSchemaWithArrayParent3s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent3s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent3s != null -> + "Content{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = + Content( + unnamedSchemaWithArrayParent3s = + unnamedSchemaWithArrayParent3s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent3s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent3s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent3s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 + private constructor( + private val chatCompletionTextObject: ChatCompletionTextObject? = null, + private val chatCompletionThinkingBlock: ChatCompletionThinkingBlock? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletionTextObject(): Optional = + Optional.ofNullable(chatCompletionTextObject) + + fun chatCompletionThinkingBlock(): Optional = + Optional.ofNullable(chatCompletionThinkingBlock) + + fun isChatCompletionTextObject(): Boolean = chatCompletionTextObject != null + + fun isChatCompletionThinkingBlock(): Boolean = + chatCompletionThinkingBlock != null + + fun asChatCompletionTextObject(): ChatCompletionTextObject = + chatCompletionTextObject.getOrThrow("chatCompletionTextObject") + + fun asChatCompletionThinkingBlock(): ChatCompletionThinkingBlock = + chatCompletionThinkingBlock.getOrThrow("chatCompletionThinkingBlock") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletionTextObject != null -> + visitor.visitChatCompletionTextObject(chatCompletionTextObject) + chatCompletionThinkingBlock != null -> + visitor.visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent3 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) { + chatCompletionTextObject.validate() + } + + override fun visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) { + chatCompletionThinkingBlock.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = chatCompletionTextObject.validity() + + override fun visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = chatCompletionThinkingBlock.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent3 && + chatCompletionTextObject == other.chatCompletionTextObject && + chatCompletionThinkingBlock == other.chatCompletionThinkingBlock + } + + override fun hashCode(): Int = + Objects.hash(chatCompletionTextObject, chatCompletionThinkingBlock) + + override fun toString(): String = + when { + chatCompletionTextObject != null -> + "UnnamedSchemaWithArrayParent3{chatCompletionTextObject=$chatCompletionTextObject}" + chatCompletionThinkingBlock != null -> + "UnnamedSchemaWithArrayParent3{chatCompletionThinkingBlock=$chatCompletionThinkingBlock}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + } + + companion object { + + @JvmStatic + fun ofChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ) = + UnnamedSchemaWithArrayParent3( + chatCompletionTextObject = chatCompletionTextObject + ) + + @JvmStatic + fun ofChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = + UnnamedSchemaWithArrayParent3( + chatCompletionThinkingBlock = chatCompletionThinkingBlock + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + */ + interface Visitor { + + fun visitChatCompletionTextObject( + chatCompletionTextObject: ChatCompletionTextObject + ): T + + fun visitChatCompletionThinkingBlock( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent3: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent3 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + chatCompletionTextObject = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + chatCompletionThinkingBlock = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from boolean). + 0 -> UnnamedSchemaWithArrayParent3(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent3, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletionTextObject != null -> + generator.writeObject(value.chatCompletionTextObject) + value.chatCompletionThinkingBlock != null -> + generator.writeObject(value.chatCompletionThinkingBlock) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent3" + ) + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if + * the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + + class ChatCompletionThinkingBlock + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val cacheControl: JsonField, + private val signature: JsonField, + private val thinking: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("signature") + @ExcludeMissing + signature: JsonField = JsonMissing.of(), + @JsonProperty("thinking") + @ExcludeMissing + thinking: JsonField = JsonMissing.of(), + ) : this(type, cacheControl, signature, thinking, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.getOptional("signature") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun thinking(): Optional = thinking.getOptional("thinking") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [signature]. + * + * Unlike [signature], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): JsonField = signature + + /** + * Returns the raw JSON value of [thinking]. + * + * Unlike [thinking], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thinking") + @ExcludeMissing + fun _thinking(): JsonField = thinking + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionThinkingBlock]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionThinkingBlock]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("thinking") + private var cacheControl: JsonField = JsonMissing.of() + private var signature: JsonField = JsonMissing.of() + private var thinking: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = apply { + type = chatCompletionThinkingBlock.type + cacheControl = chatCompletionThinkingBlock.cacheControl + signature = chatCompletionThinkingBlock.signature + thinking = chatCompletionThinkingBlock.thinking + additionalProperties = + chatCompletionThinkingBlock.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl?) = + cacheControl(JsonField.ofNullable(cacheControl)) + + /** + * Alias for calling [Builder.cacheControl] with + * `cacheControl.orElse(null)`. + */ + fun cacheControl(cacheControl: Optional) = + cacheControl(cacheControl.getOrNull()) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofUnionMember0(unionMember0)`. + */ + fun cacheControl(unionMember0: CacheControl.UnionMember0) = + cacheControl(CacheControl.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofChatCompletionCachedContent()`. + */ + fun cacheControlChatCompletionCachedContent() = + cacheControl(CacheControl.ofChatCompletionCachedContent()) + + fun signature(signature: String) = signature(JsonField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary JSON value. + * + * You should usually call [Builder.signature] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun signature(signature: JsonField) = apply { + this.signature = signature + } + + fun thinking(thinking: String) = thinking(JsonField.of(thinking)) + + /** + * Sets [Builder.thinking] to an arbitrary JSON value. + * + * You should usually call [Builder.thinking] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun thinking(thinking: JsonField) = apply { + this.thinking = thinking + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionThinkingBlock]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): ChatCompletionThinkingBlock = + ChatCompletionThinkingBlock( + type, + cacheControl, + signature, + thinking, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionThinkingBlock = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("thinking")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + cacheControl().ifPresent { it.validate() } + signature() + thinking() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("thinking")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (signature.asKnown().isPresent) 1 else 0) + + (if (thinking.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = CacheControl.Deserializer::class) + @JsonSerialize(using = CacheControl.Serializer::class) + class CacheControl + private constructor( + private val unionMember0: UnionMember0? = null, + private val chatCompletionCachedContent: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun chatCompletionCachedContent(): Optional = + Optional.ofNullable(chatCompletionCachedContent) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isChatCompletionCachedContent(): Boolean = + chatCompletionCachedContent != null + + fun asUnionMember0(): UnionMember0 = + unionMember0.getOrThrow("unionMember0") + + fun asChatCompletionCachedContent(): JsonValue = + chatCompletionCachedContent.getOrThrow( + "chatCompletionCachedContent" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + chatCompletionCachedContent != null -> + visitor.visitChatCompletionCachedContent( + chatCompletionCachedContent + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) { + chatCompletionCachedContent.let { + if ( + it != + JsonValue.from(mapOf("type" to "ephemeral")) + ) { + throw HanzoInvalidDataException( + "'chatCompletionCachedContent' is invalid, received $it" + ) + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) = + chatCompletionCachedContent.let { + if ( + it == + JsonValue.from(mapOf("type" to "ephemeral")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + unionMember0 == other.unionMember0 && + chatCompletionCachedContent == other.chatCompletionCachedContent + } + + override fun hashCode(): Int = + Objects.hash(unionMember0, chatCompletionCachedContent) + + override fun toString(): String = + when { + unionMember0 != null -> + "CacheControl{unionMember0=$unionMember0}" + chatCompletionCachedContent != null -> + "CacheControl{chatCompletionCachedContent=$chatCompletionCachedContent}" + _json != null -> "CacheControl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CacheControl") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + CacheControl(unionMember0 = unionMember0) + + @JvmStatic + fun ofChatCompletionCachedContent() = + CacheControl( + chatCompletionCachedContent = + JsonValue.from(mapOf("type" to "ephemeral")) + ) + } + + /** + * An interface that defines how to map each variant of [CacheControl] + * to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ): T + + /** + * Maps an unknown variant of [CacheControl] to a value of type [T]. + * + * An instance of [CacheControl] can contain an unknown variant if + * it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the + * API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CacheControl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CacheControl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CacheControl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + chatCompletionCachedContent = it, + _json = json, + ) + } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + unionMember0 = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> CacheControl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CacheControl::class) { + + override fun serialize( + value: CacheControl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.chatCompletionCachedContent != null -> + generator.writeObject(value.chatCompletionCachedContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CacheControl") + } + } + } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + */ + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionThinkingBlock && + type == other.type && + cacheControl == other.cacheControl && + signature == other.signature && + thinking == other.thinking && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + type, + cacheControl, + signature, + thinking, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionThinkingBlock{type=$type, cacheControl=$cacheControl, signature=$signature, thinking=$thinking, additionalProperties=$additionalProperties}" + } + } + } + + class FunctionCall + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val providerSpecificFields: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("provider_specific_fields") + @ExcludeMissing + providerSpecificFields: JsonField = JsonMissing.of(), + ) : this(arguments, name, providerSpecificFields, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun arguments(): Optional = arguments.getOptional("arguments") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun providerSpecificFields(): Optional = + providerSpecificFields.getOptional("provider_specific_fields") + + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [providerSpecificFields]. + * + * Unlike [providerSpecificFields], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("provider_specific_fields") + @ExcludeMissing + fun _providerSpecificFields(): JsonField = + providerSpecificFields + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FunctionCall]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FunctionCall]. */ + class Builder internal constructor() { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var providerSpecificFields: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionCall: FunctionCall) = apply { + arguments = functionCall.arguments + name = functionCall.name + providerSpecificFields = functionCall.providerSpecificFields + additionalProperties = functionCall.additionalProperties.toMutableMap() + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun providerSpecificFields(providerSpecificFields: ProviderSpecificFields?) = + providerSpecificFields(JsonField.ofNullable(providerSpecificFields)) + + /** + * Alias for calling [Builder.providerSpecificFields] with + * `providerSpecificFields.orElse(null)`. + */ + fun providerSpecificFields( + providerSpecificFields: Optional + ) = providerSpecificFields(providerSpecificFields.getOrNull()) + + /** + * Sets [Builder.providerSpecificFields] to an arbitrary JSON value. + * + * You should usually call [Builder.providerSpecificFields] with a well-typed + * [ProviderSpecificFields] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun providerSpecificFields( + providerSpecificFields: JsonField + ) = apply { this.providerSpecificFields = providerSpecificFields } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FunctionCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + providerSpecificFields, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FunctionCall = apply { + if (validated) { + return@apply + } + + arguments() + name() + providerSpecificFields().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arguments.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (providerSpecificFields.asKnown().getOrNull()?.validity() ?: 0) + + class ProviderSpecificFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ProviderSpecificFields]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderSpecificFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(providerSpecificFields: ProviderSpecificFields) = apply { + additionalProperties = + providerSpecificFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderSpecificFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProviderSpecificFields = + ProviderSpecificFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ProviderSpecificFields = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderSpecificFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionCall && + arguments == other.arguments && + name == other.name && + providerSpecificFields == other.providerSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(arguments, name, providerSpecificFields, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, providerSpecificFields=$providerSpecificFields, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = ThinkingBlock.Deserializer::class) + @JsonSerialize(using = ThinkingBlock.Serializer::class) + class ThinkingBlock + private constructor( + private val chatCompletion: ChatCompletionThinkingBlock? = null, + private val chatCompletionRedacted: ChatCompletionRedactedThinkingBlock? = null, + private val _json: JsonValue? = null, + ) { + + fun chatCompletion(): Optional = + Optional.ofNullable(chatCompletion) + + fun chatCompletionRedacted(): Optional = + Optional.ofNullable(chatCompletionRedacted) + + fun isChatCompletion(): Boolean = chatCompletion != null + + fun isChatCompletionRedacted(): Boolean = chatCompletionRedacted != null + + fun asChatCompletion(): ChatCompletionThinkingBlock = + chatCompletion.getOrThrow("chatCompletion") + + fun asChatCompletionRedacted(): ChatCompletionRedactedThinkingBlock = + chatCompletionRedacted.getOrThrow("chatCompletionRedacted") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + chatCompletion != null -> visitor.visitChatCompletion(chatCompletion) + chatCompletionRedacted != null -> + visitor.visitChatCompletionRedacted(chatCompletionRedacted) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ThinkingBlock = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitChatCompletion( + chatCompletion: ChatCompletionThinkingBlock + ) { + chatCompletion.validate() + } + + override fun visitChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ) { + chatCompletionRedacted.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChatCompletion( + chatCompletion: ChatCompletionThinkingBlock + ) = chatCompletion.validity() + + override fun visitChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ) = chatCompletionRedacted.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThinkingBlock && + chatCompletion == other.chatCompletion && + chatCompletionRedacted == other.chatCompletionRedacted + } + + override fun hashCode(): Int = Objects.hash(chatCompletion, chatCompletionRedacted) + + override fun toString(): String = + when { + chatCompletion != null -> "ThinkingBlock{chatCompletion=$chatCompletion}" + chatCompletionRedacted != null -> + "ThinkingBlock{chatCompletionRedacted=$chatCompletionRedacted}" + _json != null -> "ThinkingBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ThinkingBlock") + } + + companion object { + + @JvmStatic + fun ofChatCompletion(chatCompletion: ChatCompletionThinkingBlock) = + ThinkingBlock(chatCompletion = chatCompletion) + + @JvmStatic + fun ofChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ) = ThinkingBlock(chatCompletionRedacted = chatCompletionRedacted) + } + + /** + * An interface that defines how to map each variant of [ThinkingBlock] to a value + * of type [T]. + */ + interface Visitor { + + fun visitChatCompletion(chatCompletion: ChatCompletionThinkingBlock): T + + fun visitChatCompletionRedacted( + chatCompletionRedacted: ChatCompletionRedactedThinkingBlock + ): T + + /** + * Maps an unknown variant of [ThinkingBlock] to a value of type [T]. + * + * An instance of [ThinkingBlock] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown ThinkingBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ThinkingBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ThinkingBlock { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { ThinkingBlock(chatCompletion = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ThinkingBlock(chatCompletionRedacted = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> ThinkingBlock(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ThinkingBlock::class) { + + override fun serialize( + value: ThinkingBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.chatCompletion != null -> + generator.writeObject(value.chatCompletion) + value.chatCompletionRedacted != null -> + generator.writeObject(value.chatCompletionRedacted) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ThinkingBlock") + } + } + } + + class ChatCompletionThinkingBlock + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val cacheControl: JsonField, + private val signature: JsonField, + private val thinking: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("signature") + @ExcludeMissing + signature: JsonField = JsonMissing.of(), + @JsonProperty("thinking") + @ExcludeMissing + thinking: JsonField = JsonMissing.of(), + ) : this(type, cacheControl, signature, thinking, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.getOptional("signature") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thinking(): Optional = thinking.getOptional("thinking") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [signature]. + * + * Unlike [signature], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): JsonField = signature + + /** + * Returns the raw JSON value of [thinking]. + * + * Unlike [thinking], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thinking") + @ExcludeMissing + fun _thinking(): JsonField = thinking + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionThinkingBlock]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionThinkingBlock]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("thinking") + private var cacheControl: JsonField = JsonMissing.of() + private var signature: JsonField = JsonMissing.of() + private var thinking: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionThinkingBlock: ChatCompletionThinkingBlock + ) = apply { + type = chatCompletionThinkingBlock.type + cacheControl = chatCompletionThinkingBlock.cacheControl + signature = chatCompletionThinkingBlock.signature + thinking = chatCompletionThinkingBlock.thinking + additionalProperties = + chatCompletionThinkingBlock.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("thinking") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl?) = + cacheControl(JsonField.ofNullable(cacheControl)) + + /** + * Alias for calling [Builder.cacheControl] with + * `cacheControl.orElse(null)`. + */ + fun cacheControl(cacheControl: Optional) = + cacheControl(cacheControl.getOrNull()) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofUnionMember0(unionMember0)`. + */ + fun cacheControl(unionMember0: CacheControl.UnionMember0) = + cacheControl(CacheControl.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofChatCompletionCachedContent()`. + */ + fun cacheControlChatCompletionCachedContent() = + cacheControl(CacheControl.ofChatCompletionCachedContent()) + + fun signature(signature: String) = signature(JsonField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary JSON value. + * + * You should usually call [Builder.signature] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun signature(signature: JsonField) = apply { + this.signature = signature + } + + fun thinking(thinking: String) = thinking(JsonField.of(thinking)) + + /** + * Sets [Builder.thinking] to an arbitrary JSON value. + * + * You should usually call [Builder.thinking] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun thinking(thinking: JsonField) = apply { + this.thinking = thinking + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionThinkingBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChatCompletionThinkingBlock = + ChatCompletionThinkingBlock( + type, + cacheControl, + signature, + thinking, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionThinkingBlock = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("thinking")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + signature() + thinking() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("thinking")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (signature.asKnown().isPresent) 1 else 0) + + (if (thinking.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = CacheControl.Deserializer::class) + @JsonSerialize(using = CacheControl.Serializer::class) + class CacheControl + private constructor( + private val unionMember0: UnionMember0? = null, + private val chatCompletionCachedContent: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun chatCompletionCachedContent(): Optional = + Optional.ofNullable(chatCompletionCachedContent) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isChatCompletionCachedContent(): Boolean = + chatCompletionCachedContent != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asChatCompletionCachedContent(): JsonValue = + chatCompletionCachedContent.getOrThrow("chatCompletionCachedContent") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + chatCompletionCachedContent != null -> + visitor.visitChatCompletionCachedContent( + chatCompletionCachedContent + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) { + chatCompletionCachedContent.let { + if ( + it != JsonValue.from(mapOf("type" to "ephemeral")) + ) { + throw HanzoInvalidDataException( + "'chatCompletionCachedContent' is invalid, received $it" + ) + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) = + chatCompletionCachedContent.let { + if (it == JsonValue.from(mapOf("type" to "ephemeral"))) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + unionMember0 == other.unionMember0 && + chatCompletionCachedContent == other.chatCompletionCachedContent + } + + override fun hashCode(): Int = + Objects.hash(unionMember0, chatCompletionCachedContent) + + override fun toString(): String = + when { + unionMember0 != null -> "CacheControl{unionMember0=$unionMember0}" + chatCompletionCachedContent != null -> + "CacheControl{chatCompletionCachedContent=$chatCompletionCachedContent}" + _json != null -> "CacheControl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CacheControl") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + CacheControl(unionMember0 = unionMember0) + + @JvmStatic + fun ofChatCompletionCachedContent() = + CacheControl( + chatCompletionCachedContent = + JsonValue.from(mapOf("type" to "ephemeral")) + ) + } + + /** + * An interface that defines how to map each variant of [CacheControl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ): T + + /** + * Maps an unknown variant of [CacheControl] to a value of type [T]. + * + * An instance of [CacheControl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CacheControl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CacheControl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CacheControl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + chatCompletionCachedContent = it, + _json = json, + ) + } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl(unionMember0 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> CacheControl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CacheControl::class) { + + override fun serialize( + value: CacheControl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.chatCompletionCachedContent != null -> + generator.writeObject(value.chatCompletionCachedContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CacheControl") + } + } + } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionThinkingBlock && + type == other.type && + cacheControl == other.cacheControl && + signature == other.signature && + thinking == other.thinking && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, cacheControl, signature, thinking, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionThinkingBlock{type=$type, cacheControl=$cacheControl, signature=$signature, thinking=$thinking, additionalProperties=$additionalProperties}" + } + + class ChatCompletionRedactedThinkingBlock + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val cacheControl: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + ) : this(type, cacheControl, data, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("redacted_thinking") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionRedactedThinkingBlock]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionRedactedThinkingBlock]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("redacted_thinking") + private var cacheControl: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + chatCompletionRedactedThinkingBlock: ChatCompletionRedactedThinkingBlock + ) = apply { + type = chatCompletionRedactedThinkingBlock.type + cacheControl = chatCompletionRedactedThinkingBlock.cacheControl + data = chatCompletionRedactedThinkingBlock.data + additionalProperties = + chatCompletionRedactedThinkingBlock.additionalProperties + .toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("redacted_thinking") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl?) = + cacheControl(JsonField.ofNullable(cacheControl)) + + /** + * Alias for calling [Builder.cacheControl] with + * `cacheControl.orElse(null)`. + */ + fun cacheControl(cacheControl: Optional) = + cacheControl(cacheControl.getOrNull()) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofUnionMember0(unionMember0)`. + */ + fun cacheControl(unionMember0: CacheControl.UnionMember0) = + cacheControl(CacheControl.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [cacheControl] with + * `CacheControl.ofChatCompletionCachedContent()`. + */ + fun cacheControlChatCompletionCachedContent() = + cacheControl(CacheControl.ofChatCompletionCachedContent()) + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionRedactedThinkingBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChatCompletionRedactedThinkingBlock = + ChatCompletionRedactedThinkingBlock( + type, + cacheControl, + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionRedactedThinkingBlock = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("redacted_thinking")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + data() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("redacted_thinking")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (data.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = CacheControl.Deserializer::class) + @JsonSerialize(using = CacheControl.Serializer::class) + class CacheControl + private constructor( + private val unionMember0: UnionMember0? = null, + private val chatCompletionCachedContent: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun chatCompletionCachedContent(): Optional = + Optional.ofNullable(chatCompletionCachedContent) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isChatCompletionCachedContent(): Boolean = + chatCompletionCachedContent != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asChatCompletionCachedContent(): JsonValue = + chatCompletionCachedContent.getOrThrow("chatCompletionCachedContent") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + chatCompletionCachedContent != null -> + visitor.visitChatCompletionCachedContent( + chatCompletionCachedContent + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) { + chatCompletionCachedContent.let { + if ( + it != JsonValue.from(mapOf("type" to "ephemeral")) + ) { + throw HanzoInvalidDataException( + "'chatCompletionCachedContent' is invalid, received $it" + ) + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ) = + chatCompletionCachedContent.let { + if (it == JsonValue.from(mapOf("type" to "ephemeral"))) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + unionMember0 == other.unionMember0 && + chatCompletionCachedContent == other.chatCompletionCachedContent + } + + override fun hashCode(): Int = + Objects.hash(unionMember0, chatCompletionCachedContent) + + override fun toString(): String = + when { + unionMember0 != null -> "CacheControl{unionMember0=$unionMember0}" + chatCompletionCachedContent != null -> + "CacheControl{chatCompletionCachedContent=$chatCompletionCachedContent}" + _json != null -> "CacheControl{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CacheControl") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + CacheControl(unionMember0 = unionMember0) + + @JvmStatic + fun ofChatCompletionCachedContent() = + CacheControl( + chatCompletionCachedContent = + JsonValue.from(mapOf("type" to "ephemeral")) + ) + } + + /** + * An interface that defines how to map each variant of [CacheControl] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitChatCompletionCachedContent( + chatCompletionCachedContent: JsonValue + ): T + + /** + * Maps an unknown variant of [CacheControl] to a value of type [T]. + * + * An instance of [CacheControl] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown CacheControl: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CacheControl::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CacheControl { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl( + chatCompletionCachedContent = it, + _json = json, + ) + } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CacheControl(unionMember0 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from boolean). + 0 -> CacheControl(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CacheControl::class) { + + override fun serialize( + value: CacheControl, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.chatCompletionCachedContent != null -> + generator.writeObject(value.chatCompletionCachedContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CacheControl") + } + } + } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionRedactedThinkingBlock && + type == other.type && + cacheControl == other.cacheControl && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, cacheControl, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionRedactedThinkingBlock{type=$type, cacheControl=$cacheControl, data=$data, additionalProperties=$additionalProperties}" + } + } + + class ToolCall + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("function") + @ExcludeMissing + function: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, function, type, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun function(): Function = function.getRequired("function") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("function") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [function]. + * + * Unlike [function], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("function") + @ExcludeMissing + fun _function(): JsonField = function + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ToolCall]. + * + * The following fields are required: + * ```java + * .id() + * .function() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ToolCall]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var function: JsonField? = null + private var type: JsonValue = JsonValue.from("function") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(toolCall: ToolCall) = apply { + id = toolCall.id + function = toolCall.function + type = toolCall.type + additionalProperties = toolCall.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun function(function: Function) = function(JsonField.of(function)) + + /** + * Sets [Builder.function] to an arbitrary JSON value. + * + * You should usually call [Builder.function] with a well-typed [Function] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun function(function: JsonField) = apply { this.function = function } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("function") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ToolCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .function() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ToolCall = + ToolCall( + checkRequired("id", id), + checkRequired("function", function), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ToolCall = apply { + if (validated) { + return@apply + } + + id() + function().validate() + _type().let { + if (it != JsonValue.from("function")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (function.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("function")) 1 else 0 } + + class Function + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val providerSpecificFields: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("provider_specific_fields") + @ExcludeMissing + providerSpecificFields: JsonField = JsonMissing.of(), + ) : this(arguments, name, providerSpecificFields, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun arguments(): Optional = arguments.getOptional("arguments") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun providerSpecificFields(): Optional = + providerSpecificFields.getOptional("provider_specific_fields") + + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [providerSpecificFields]. + * + * Unlike [providerSpecificFields], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("provider_specific_fields") + @ExcludeMissing + fun _providerSpecificFields(): JsonField = + providerSpecificFields + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Function]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Function]. */ + class Builder internal constructor() { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var providerSpecificFields: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + arguments = function.arguments + name = function.name + providerSpecificFields = function.providerSpecificFields + additionalProperties = function.additionalProperties.toMutableMap() + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun providerSpecificFields( + providerSpecificFields: ProviderSpecificFields? + ) = providerSpecificFields(JsonField.ofNullable(providerSpecificFields)) + + /** + * Alias for calling [Builder.providerSpecificFields] with + * `providerSpecificFields.orElse(null)`. + */ + fun providerSpecificFields( + providerSpecificFields: Optional + ) = providerSpecificFields(providerSpecificFields.getOrNull()) + + /** + * Sets [Builder.providerSpecificFields] to an arbitrary JSON value. + * + * You should usually call [Builder.providerSpecificFields] with a + * well-typed [ProviderSpecificFields] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun providerSpecificFields( + providerSpecificFields: JsonField + ) = apply { this.providerSpecificFields = providerSpecificFields } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Function = + Function( + arguments, + name, + providerSpecificFields, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Function = apply { + if (validated) { + return@apply + } + + arguments() + name() + providerSpecificFields().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arguments.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (providerSpecificFields.asKnown().getOrNull()?.validity() ?: 0) + + class ProviderSpecificFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ProviderSpecificFields]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderSpecificFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(providerSpecificFields: ProviderSpecificFields) = + apply { + additionalProperties = + providerSpecificFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderSpecificFields]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): ProviderSpecificFields = + ProviderSpecificFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ProviderSpecificFields = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderSpecificFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Function && + arguments == other.arguments && + name == other.name && + providerSpecificFields == other.providerSpecificFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(arguments, name, providerSpecificFields, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Function{arguments=$arguments, name=$name, providerSpecificFields=$providerSpecificFields, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolCall && + id == other.id && + function == other.function && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, function, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionAssistantMessage && + role == other.role && + cacheControl == other.cacheControl && + content == other.content && + functionCall == other.functionCall && + name == other.name && + reasoningContent == other.reasoningContent && + thinkingBlocks == other.thinkingBlocks && + toolCalls == other.toolCalls && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + role, + cacheControl, + content, + functionCall, + name, + reasoningContent, + thinkingBlocks, + toolCalls, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionAssistantMessage{role=$role, cacheControl=$cacheControl, content=$content, functionCall=$functionCall, name=$name, reasoningContent=$reasoningContent, thinkingBlocks=$thinkingBlocks, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + } + + class ChatCompletionToolMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val toolCallId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + toolCallId: JsonField = JsonMissing.of(), + ) : this(content, role, toolCallId, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun toolCallId(): String = toolCallId.getRequired("tool_call_id") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField = toolCallId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionToolMessage]. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionToolMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("tool") + private var toolCallId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionToolMessage: ChatCompletionToolMessage) = apply { + content = chatCompletionToolMessage.content + role = chatCompletionToolMessage.role + toolCallId = chatCompletionToolMessage.toolCallId + additionalProperties = + chatCompletionToolMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofChatCompletionTextObjects(chatCompletionTextObjects)`. + */ + fun contentOfChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = content(Content.ofChatCompletionTextObjects(chatCompletionTextObjects)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionToolMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionToolMessage = + ChatCompletionToolMessage( + checkRequired("content", content), + role, + checkRequired("toolCallId", toolCallId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionToolMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("tool")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + toolCallId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("tool")) 1 else 0 } + + (if (toolCallId.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val chatCompletionTextObjects: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionTextObjects(): Optional> = + Optional.ofNullable(chatCompletionTextObjects) + + fun isString(): Boolean = string != null + + fun isChatCompletionTextObjects(): Boolean = chatCompletionTextObjects != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionTextObjects(): List = + chatCompletionTextObjects.getOrThrow("chatCompletionTextObjects") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionTextObjects != null -> + visitor.visitChatCompletionTextObjects(chatCompletionTextObjects) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) { + chatCompletionTextObjects.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = chatCompletionTextObjects.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + chatCompletionTextObjects == other.chatCompletionTextObjects + } + + override fun hashCode(): Int = Objects.hash(string, chatCompletionTextObjects) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + chatCompletionTextObjects != null -> + "Content{chatCompletionTextObjects=$chatCompletionTextObjects}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = Content(chatCompletionTextObjects = chatCompletionTextObjects.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content(chatCompletionTextObjects = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionTextObjects != null -> + generator.writeObject(value.chatCompletionTextObjects) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionToolMessage && + content == other.content && + role == other.role && + toolCallId == other.toolCallId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, toolCallId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionToolMessage{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + class ChatCompletionSystemMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val cacheControl: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(content, role, cacheControl, name, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("system") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionSystemMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionSystemMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("system") + private var cacheControl: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionSystemMessage: ChatCompletionSystemMessage) = + apply { + content = chatCompletionSystemMessage.content + role = chatCompletionSystemMessage.role + cacheControl = chatCompletionSystemMessage.cacheControl + name = chatCompletionSystemMessage.name + additionalProperties = + chatCompletionSystemMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** Alias for calling [content] with `Content.ofJsonValues(jsonValues)`. */ + fun contentOfJsonValues(jsonValues: List) = + content(Content.ofJsonValues(jsonValues)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("system") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionSystemMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionSystemMessage = + ChatCompletionSystemMessage( + checkRequired("content", content), + role, + cacheControl, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionSystemMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("system")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("system")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) + + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitJsonValues(jsonValues: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = + jsonValues.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + jsonValues == other.jsonValues + } + + override fun hashCode(): Int = Objects.hash(string, jsonValues) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + jsonValues != null -> "Content{jsonValues=$jsonValues}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = + Content(jsonValues = jsonValues.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitJsonValues(jsonValues: List): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Content(jsonValues = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + } + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionSystemMessage && + content == other.content && + role == other.role && + cacheControl == other.cacheControl && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, cacheControl, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionSystemMessage{content=$content, role=$role, cacheControl=$cacheControl, name=$name, additionalProperties=$additionalProperties}" + } + + class ChatCompletionFunctionMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonValue, + private val toolCallId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + toolCallId: JsonField = JsonMissing.of(), + ) : this(content, name, role, toolCallId, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("function") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolCallId(): Optional = toolCallId.getOptional("tool_call_id") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField = toolCallId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionFunctionMessage]. + * + * The following fields are required: + * ```java + * .content() + * .name() + * .toolCallId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionFunctionMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var name: JsonField? = null + private var role: JsonValue = JsonValue.from("function") + private var toolCallId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionFunctionMessage: ChatCompletionFunctionMessage) = + apply { + content = chatCompletionFunctionMessage.content + name = chatCompletionFunctionMessage.name + role = chatCompletionFunctionMessage.role + toolCallId = chatCompletionFunctionMessage.toolCallId + additionalProperties = + chatCompletionFunctionMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofChatCompletionTextObjects(chatCompletionTextObjects)`. + */ + fun contentOfChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = content(Content.ofChatCompletionTextObjects(chatCompletionTextObjects)) + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("function") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun toolCallId(toolCallId: String?) = toolCallId(JsonField.ofNullable(toolCallId)) + + /** Alias for calling [Builder.toolCallId] with `toolCallId.orElse(null)`. */ + fun toolCallId(toolCallId: Optional) = toolCallId(toolCallId.getOrNull()) + + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionFunctionMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .name() + * .toolCallId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionFunctionMessage = + ChatCompletionFunctionMessage( + checkRequired("content", content), + checkRequired("name", name), + role, + checkRequired("toolCallId", toolCallId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionFunctionMessage = apply { + if (validated) { + return@apply + } + + content().ifPresent { it.validate() } + name() + _role().let { + if (it != JsonValue.from("function")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + toolCallId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + role.let { if (it == JsonValue.from("function")) 1 else 0 } + + (if (toolCallId.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val chatCompletionTextObjects: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionTextObjects(): Optional> = + Optional.ofNullable(chatCompletionTextObjects) + + fun isString(): Boolean = string != null + + fun isChatCompletionTextObjects(): Boolean = chatCompletionTextObjects != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionTextObjects(): List = + chatCompletionTextObjects.getOrThrow("chatCompletionTextObjects") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + chatCompletionTextObjects != null -> + visitor.visitChatCompletionTextObjects(chatCompletionTextObjects) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) { + chatCompletionTextObjects.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = chatCompletionTextObjects.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + chatCompletionTextObjects == other.chatCompletionTextObjects + } + + override fun hashCode(): Int = Objects.hash(string, chatCompletionTextObjects) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + chatCompletionTextObjects != null -> + "Content{chatCompletionTextObjects=$chatCompletionTextObjects}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofChatCompletionTextObjects( + chatCompletionTextObjects: List + ) = Content(chatCompletionTextObjects = chatCompletionTextObjects.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionTextObjects( + chatCompletionTextObjects: List + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { + Content(chatCompletionTextObjects = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.chatCompletionTextObjects != null -> + generator.writeObject(value.chatCompletionTextObjects) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + class ChatCompletionTextObject + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val cacheControl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + ) : this(text, type, cacheControl, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cacheControl(): Optional = + cacheControl.getOptional("cache_control") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionTextObject]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionTextObject]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var cacheControl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionTextObject: ChatCompletionTextObject) = + apply { + text = chatCompletionTextObject.text + type = chatCompletionTextObject.type + cacheControl = chatCompletionTextObject.cacheControl + additionalProperties = + chatCompletionTextObject.additionalProperties.toMutableMap() + } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed + * [CacheControl] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionTextObject]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionTextObject = + ChatCompletionTextObject( + checkRequired("text", text), + type, + cacheControl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionTextObject = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("text")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CacheControl]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = + cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionTextObject && + text == other.text && + type == other.type && + cacheControl == other.cacheControl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, cacheControl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionTextObject{text=$text, type=$type, cacheControl=$cacheControl, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionFunctionMessage && + content == other.content && + name == other.name && + role == other.role && + toolCallId == other.toolCallId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, name, role, toolCallId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionFunctionMessage{content=$content, name=$name, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + class ChatCompletionDeveloperMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonValue, + private val cacheControl: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonValue = JsonMissing.of(), + @JsonProperty("cache_control") + @ExcludeMissing + cacheControl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(content, role, cacheControl, name, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("developer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonValue = role + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cacheControl(): Optional = cacheControl.getOptional("cache_control") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [cacheControl]. + * + * Unlike [cacheControl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_control") + @ExcludeMissing + fun _cacheControl(): JsonField = cacheControl + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionDeveloperMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatCompletionDeveloperMessage]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonValue = JsonValue.from("developer") + private var cacheControl: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chatCompletionDeveloperMessage: ChatCompletionDeveloperMessage) = + apply { + content = chatCompletionDeveloperMessage.content + role = chatCompletionDeveloperMessage.role + cacheControl = chatCompletionDeveloperMessage.cacheControl + name = chatCompletionDeveloperMessage.name + additionalProperties = + chatCompletionDeveloperMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** Alias for calling [content] with `Content.ofJsonValues(jsonValues)`. */ + fun contentOfJsonValues(jsonValues: List) = + content(Content.ofJsonValues(jsonValues)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("developer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonValue) = apply { this.role = role } + + fun cacheControl(cacheControl: CacheControl) = + cacheControl(JsonField.of(cacheControl)) + + /** + * Sets [Builder.cacheControl] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheControl] with a well-typed [CacheControl] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cacheControl(cacheControl: JsonField) = apply { + this.cacheControl = cacheControl + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatCompletionDeveloperMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatCompletionDeveloperMessage = + ChatCompletionDeveloperMessage( + checkRequired("content", content), + role, + cacheControl, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatCompletionDeveloperMessage = apply { + if (validated) { + return@apply + } + + content().validate() + _role().let { + if (it != JsonValue.from("developer")) { + throw HanzoInvalidDataException("'role' is invalid, received $it") + } + } + cacheControl().ifPresent { it.validate() } + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + role.let { if (it == JsonValue.from("developer")) 1 else 0 } + + (cacheControl.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) + + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitJsonValues(jsonValues: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = + jsonValues.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + jsonValues == other.jsonValues + } + + override fun hashCode(): Int = Objects.hash(string, jsonValues) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + jsonValues != null -> "Content{jsonValues=$jsonValues}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = + Content(jsonValues = jsonValues.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitJsonValues(jsonValues: List): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Content(jsonValues = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + } + + class CacheControl + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CacheControl]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CacheControl]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("ephemeral") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cacheControl: CacheControl) = apply { + type = cacheControl.type + additionalProperties = cacheControl.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ephemeral") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CacheControl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CacheControl = + CacheControl(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CacheControl = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("ephemeral")) { + throw HanzoInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("ephemeral")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CacheControl && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CacheControl{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionDeveloperMessage && + content == other.content && + role == other.role && + cacheControl == other.cacheControl && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(content, role, cacheControl, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatCompletionDeveloperMessage{content=$content, role=$role, cacheControl=$cacheControl, name=$name, additionalProperties=$additionalProperties}" + } + } + + class ContextWindowFallbackDict + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContextWindowFallbackDict]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContextWindowFallbackDict]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contextWindowFallbackDict: ContextWindowFallbackDict) = apply { + additionalProperties = contextWindowFallbackDict.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContextWindowFallbackDict]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContextWindowFallbackDict = + ContextWindowFallbackDict(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ContextWindowFallbackDict = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContextWindowFallbackDict && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContextWindowFallbackDict{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = FunctionCall.Deserializer::class) + @JsonSerialize(using = FunctionCall.Serializer::class) + class FunctionCall + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): FunctionCall = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionCall && + string == other.string && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "FunctionCall{string=$string}" + unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } + + companion object { + + @JvmStatic fun ofString(string: String) = FunctionCall(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + FunctionCall(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [FunctionCall] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [FunctionCall] to a value of type [T]. + * + * An instance of [FunctionCall] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown FunctionCall: $json") + } + } + + internal class Deserializer : BaseDeserializer(FunctionCall::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + FunctionCall(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + FunctionCall(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> FunctionCall(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(FunctionCall::class) { + + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + class Function + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Function]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Function]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + additionalProperties = function.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Function = Function(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Function = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Function && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Function{additionalProperties=$additionalProperties}" + } + + class LogitBias + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogitBias]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogitBias]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logitBias: LogitBias) = apply { + additionalProperties = logitBias.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogitBias]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogitBias = LogitBias(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LogitBias = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogitBias && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LogitBias{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ResponseFormat + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ResponseFormat]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseFormat]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseFormat: ResponseFormat) = apply { + additionalProperties = responseFormat.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponseFormat]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ResponseFormat = ResponseFormat(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ResponseFormat = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseFormat && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ResponseFormat{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Stop.Deserializer::class) + @JsonSerialize(using = Stop.Serializer::class) + class Stop + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Stop = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitStrings(strings: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Stop && string == other.string && strings == other.strings + } + + override fun hashCode(): Int = Objects.hash(string, strings) + + override fun toString(): String = + when { + string != null -> "Stop{string=$string}" + strings != null -> "Stop{strings=$strings}" + _json != null -> "Stop{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Stop") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Stop(string = string) + + @JvmStatic fun ofStrings(strings: List) = Stop(strings = strings.toImmutable()) + } + + /** An interface that defines how to map each variant of [Stop] to a value of type [T]. */ + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + /** + * Maps an unknown variant of [Stop] to a value of type [T]. + * + * An instance of [Stop] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Stop: $json") + } + } + + internal class Deserializer : BaseDeserializer(Stop::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Stop { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Stop(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Stop(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Stop(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Stop::class) { + + override fun serialize( + value: Stop, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Stop") + } + } + } + } + + class StreamOptions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StreamOptions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StreamOptions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(streamOptions: StreamOptions) = apply { + additionalProperties = streamOptions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StreamOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StreamOptions = StreamOptions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): StreamOptions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StreamOptions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "StreamOptions{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = ToolChoice.Deserializer::class) + @JsonSerialize(using = ToolChoice.Serializer::class) + class ToolChoice + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ToolChoice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolChoice && + string == other.string && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "ToolChoice{string=$string}" + unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ToolChoice(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [ToolChoice] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [ToolChoice] to a value of type [T]. + * + * An instance of [ToolChoice] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown ToolChoice: $json") + } + } + + internal class Deserializer : BaseDeserializer(ToolChoice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ToolChoice(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ToolChoice(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> ToolChoice(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ToolChoice::class) { + + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + class Tool + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Tool]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tool]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tool: Tool) = apply { + additionalProperties = tool.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tool]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Tool = Tool(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Tool = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tool && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Tool{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -233,15 +16921,15 @@ private constructor( } return other is ChatCompleteParams && - model == other.model && + pathModel == other.pathModel && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(pathModel, body, additionalHeaders, additionalQueryParams) override fun toString() = - "ChatCompleteParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ChatCompleteParams{pathModel=$pathModel, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt index edfdabca..6b36bd84 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileCreateParams.kt @@ -33,7 +33,7 @@ import kotlin.jvm.optionals.getOrNull * * ``` * curl http://localhost:4000/v1/files -H "Authorization: Bearer sk-1234" -F purpose="batch" -F file="@mydata.jsonl" - * + * -F expires_after[anchor]="created_at" -F expires_after[seconds]=2592000 * ``` */ class FileCreateParams @@ -64,6 +64,24 @@ private constructor( */ fun customLlmProvider(): Optional = body.customLlmProvider() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmMetadata(): Optional = body.litellmMetadata() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun targetModelNames(): Optional = body.targetModelNames() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun targetStorage(): Optional = body.targetStorage() + /** * Returns the raw multipart value of [file]. * @@ -86,6 +104,30 @@ private constructor( */ fun _customLlmProvider(): MultipartField = body._customLlmProvider() + /** + * Returns the raw multipart value of [litellmMetadata]. + * + * Unlike [litellmMetadata], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _litellmMetadata(): MultipartField = body._litellmMetadata() + + /** + * Returns the raw multipart value of [targetModelNames]. + * + * Unlike [targetModelNames], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _targetModelNames(): MultipartField = body._targetModelNames() + + /** + * Returns the raw multipart value of [targetStorage]. + * + * Unlike [targetStorage], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _targetStorage(): MultipartField = body._targetStorage() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -139,6 +181,9 @@ private constructor( * - [file] * - [purpose] * - [customLlmProvider] + * - [litellmMetadata] + * - [targetModelNames] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -182,6 +227,53 @@ private constructor( body.customLlmProvider(customLlmProvider) } + fun litellmMetadata(litellmMetadata: String?) = apply { + body.litellmMetadata(litellmMetadata) + } + + /** Alias for calling [Builder.litellmMetadata] with `litellmMetadata.orElse(null)`. */ + fun litellmMetadata(litellmMetadata: Optional) = + litellmMetadata(litellmMetadata.getOrNull()) + + /** + * Sets [Builder.litellmMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.litellmMetadata] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun litellmMetadata(litellmMetadata: MultipartField) = apply { + body.litellmMetadata(litellmMetadata) + } + + fun targetModelNames(targetModelNames: String) = apply { + body.targetModelNames(targetModelNames) + } + + /** + * Sets [Builder.targetModelNames] to an arbitrary multipart value. + * + * You should usually call [Builder.targetModelNames] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun targetModelNames(targetModelNames: MultipartField) = apply { + body.targetModelNames(targetModelNames) + } + + fun targetStorage(targetStorage: String) = apply { body.targetStorage(targetStorage) } + + /** + * Sets [Builder.targetStorage] to an arbitrary multipart value. + * + * You should usually call [Builder.targetStorage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun targetStorage(targetStorage: MultipartField) = apply { + body.targetStorage(targetStorage) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -326,6 +418,9 @@ private constructor( "file" to _file(), "purpose" to _purpose(), "custom_llm_provider" to _customLlmProvider(), + "litellm_metadata" to _litellmMetadata(), + "target_model_names" to _targetModelNames(), + "target_storage" to _targetStorage(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() @@ -344,6 +439,9 @@ private constructor( private val file: MultipartField, private val purpose: MultipartField, private val customLlmProvider: MultipartField, + private val litellmMetadata: MultipartField, + private val targetModelNames: MultipartField, + private val targetStorage: MultipartField, private val additionalProperties: MutableMap, ) { @@ -366,6 +464,26 @@ private constructor( fun customLlmProvider(): Optional = customLlmProvider.value.getOptional("custom_llm_provider") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmMetadata(): Optional = + litellmMetadata.value.getOptional("litellm_metadata") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun targetModelNames(): Optional = + targetModelNames.value.getOptional("target_model_names") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun targetStorage(): Optional = targetStorage.value.getOptional("target_storage") + /** * Returns the raw multipart value of [file]. * @@ -391,6 +509,36 @@ private constructor( @ExcludeMissing fun _customLlmProvider(): MultipartField = customLlmProvider + /** + * Returns the raw multipart value of [litellmMetadata]. + * + * Unlike [litellmMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("litellm_metadata") + @ExcludeMissing + fun _litellmMetadata(): MultipartField = litellmMetadata + + /** + * Returns the raw multipart value of [targetModelNames]. + * + * Unlike [targetModelNames], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("target_model_names") + @ExcludeMissing + fun _targetModelNames(): MultipartField = targetModelNames + + /** + * Returns the raw multipart value of [targetStorage]. + * + * Unlike [targetStorage], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("target_storage") + @ExcludeMissing + fun _targetStorage(): MultipartField = targetStorage + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -423,6 +571,9 @@ private constructor( private var file: MultipartField? = null private var purpose: MultipartField? = null private var customLlmProvider: MultipartField = MultipartField.of(null) + private var litellmMetadata: MultipartField = MultipartField.of(null) + private var targetModelNames: MultipartField = MultipartField.of(null) + private var targetStorage: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -430,6 +581,9 @@ private constructor( file = body.file purpose = body.purpose customLlmProvider = body.customLlmProvider + litellmMetadata = body.litellmMetadata + targetModelNames = body.targetModelNames + targetStorage = body.targetStorage additionalProperties = body.additionalProperties.toMutableMap() } @@ -479,6 +633,52 @@ private constructor( this.customLlmProvider = customLlmProvider } + fun litellmMetadata(litellmMetadata: String?) = + litellmMetadata(MultipartField.of(litellmMetadata)) + + /** Alias for calling [Builder.litellmMetadata] with `litellmMetadata.orElse(null)`. */ + fun litellmMetadata(litellmMetadata: Optional) = + litellmMetadata(litellmMetadata.getOrNull()) + + /** + * Sets [Builder.litellmMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.litellmMetadata] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun litellmMetadata(litellmMetadata: MultipartField) = apply { + this.litellmMetadata = litellmMetadata + } + + fun targetModelNames(targetModelNames: String) = + targetModelNames(MultipartField.of(targetModelNames)) + + /** + * Sets [Builder.targetModelNames] to an arbitrary multipart value. + * + * You should usually call [Builder.targetModelNames] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun targetModelNames(targetModelNames: MultipartField) = apply { + this.targetModelNames = targetModelNames + } + + fun targetStorage(targetStorage: String) = + targetStorage(MultipartField.of(targetStorage)) + + /** + * Sets [Builder.targetStorage] to an arbitrary multipart value. + * + * You should usually call [Builder.targetStorage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun targetStorage(targetStorage: MultipartField) = apply { + this.targetStorage = targetStorage + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -516,6 +716,9 @@ private constructor( checkRequired("file", file), checkRequired("purpose", purpose), customLlmProvider, + litellmMetadata, + targetModelNames, + targetStorage, additionalProperties.toMutableMap(), ) } @@ -530,6 +733,9 @@ private constructor( file() purpose() customLlmProvider() + litellmMetadata() + targetModelNames() + targetStorage() validated = true } @@ -550,17 +756,28 @@ private constructor( file == other.file && purpose == other.purpose && customLlmProvider == other.customLlmProvider && + litellmMetadata == other.litellmMetadata && + targetModelNames == other.targetModelNames && + targetStorage == other.targetStorage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(file, purpose, customLlmProvider, additionalProperties) + Objects.hash( + file, + purpose, + customLlmProvider, + litellmMetadata, + targetModelNames, + targetStorage, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{file=$file, purpose=$purpose, customLlmProvider=$customLlmProvider, additionalProperties=$additionalProperties}" + "Body{file=$file, purpose=$purpose, customLlmProvider=$customLlmProvider, litellmMetadata=$litellmMetadata, targetModelNames=$targetModelNames, targetStorage=$targetStorage, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt index 7c08a9c4..841ef409 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/files/FileListParams.kt @@ -26,6 +26,7 @@ class FileListParams private constructor( private val provider: String?, private val purpose: String?, + private val targetModelNames: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -34,6 +35,8 @@ private constructor( fun purpose(): Optional = Optional.ofNullable(purpose) + fun targetModelNames(): Optional = Optional.ofNullable(targetModelNames) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -55,6 +58,7 @@ private constructor( private var provider: String? = null private var purpose: String? = null + private var targetModelNames: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -62,6 +66,7 @@ private constructor( internal fun from(fileListParams: FileListParams) = apply { provider = fileListParams.provider purpose = fileListParams.purpose + targetModelNames = fileListParams.targetModelNames additionalHeaders = fileListParams.additionalHeaders.toBuilder() additionalQueryParams = fileListParams.additionalQueryParams.toBuilder() } @@ -76,6 +81,14 @@ private constructor( /** Alias for calling [Builder.purpose] with `purpose.orElse(null)`. */ fun purpose(purpose: Optional) = purpose(purpose.getOrNull()) + fun targetModelNames(targetModelNames: String?) = apply { + this.targetModelNames = targetModelNames + } + + /** Alias for calling [Builder.targetModelNames] with `targetModelNames.orElse(null)`. */ + fun targetModelNames(targetModelNames: Optional) = + targetModelNames(targetModelNames.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -183,6 +196,7 @@ private constructor( FileListParams( provider, purpose, + targetModelNames, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -200,6 +214,7 @@ private constructor( QueryParams.builder() .apply { purpose?.let { put("purpose", it) } + targetModelNames?.let { put("target_model_names", it) } putAll(additionalQueryParams) } .build() @@ -212,13 +227,14 @@ private constructor( return other is FileListParams && provider == other.provider && purpose == other.purpose && + targetModelNames == other.targetModelNames && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(provider, purpose, additionalHeaders, additionalQueryParams) + Objects.hash(provider, purpose, targetModelNames, additionalHeaders, additionalQueryParams) override fun toString() = - "FileListParams{provider=$provider, purpose=$purpose, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileListParams{provider=$provider, purpose=$purpose, targetModelNames=$targetModelNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt index 43ef4b36..14b268a1 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobCreateParams.kt @@ -2,37 +2,12 @@ package ai.hanzo.api.models.finetuning.jobs -import ai.hanzo.api.core.BaseDeserializer -import ai.hanzo.api.core.BaseSerializer -import ai.hanzo.api.core.Enum -import ai.hanzo.api.core.ExcludeMissing -import ai.hanzo.api.core.JsonField -import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params -import ai.hanzo.api.core.allMaxBy -import ai.hanzo.api.core.checkKnown import ai.hanzo.api.core.checkRequired -import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams -import ai.hanzo.api.core.toImmutable -import ai.hanzo.api.errors.HanzoInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * Creates a fine-tuning job which begins the process of creating a new model from a given dataset. @@ -53,117 +28,15 @@ import kotlin.jvm.optionals.getOrNull */ class JobCreateParams private constructor( - private val body: Body, + private val liteLlmFineTuningJobCreate: LiteLlmFineTuningJobCreate, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun customLlmProvider(): CustomLlmProvider = body.customLlmProvider() + fun liteLlmFineTuningJobCreate(): LiteLlmFineTuningJobCreate = liteLlmFineTuningJobCreate - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun model(): String = body.model() - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun trainingFile(): String = body.trainingFile() - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hyperparameters(): Optional = body.hyperparameters() - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun integrations(): Optional> = body.integrations() - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun seed(): Optional = body.seed() - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun suffix(): Optional = body.suffix() - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun validationFile(): Optional = body.validationFile() - - /** - * Returns the raw JSON value of [customLlmProvider]. - * - * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _customLlmProvider(): JsonField = body._customLlmProvider() - - /** - * Returns the raw JSON value of [model]. - * - * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _model(): JsonField = body._model() - - /** - * Returns the raw JSON value of [trainingFile]. - * - * Unlike [trainingFile], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _trainingFile(): JsonField = body._trainingFile() - - /** - * Returns the raw JSON value of [hyperparameters]. - * - * Unlike [hyperparameters], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _hyperparameters(): JsonField = body._hyperparameters() - - /** - * Returns the raw JSON value of [integrations]. - * - * Unlike [integrations], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _integrations(): JsonField> = body._integrations() - - /** - * Returns the raw JSON value of [seed]. - * - * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _seed(): JsonField = body._seed() - - /** - * Returns the raw JSON value of [suffix]. - * - * Unlike [suffix], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _suffix(): JsonField = body._suffix() - - /** - * Returns the raw JSON value of [validationFile]. - * - * Unlike [validationFile], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _validationFile(): JsonField = body._validationFile() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + liteLlmFineTuningJobCreate._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -180,9 +53,7 @@ private constructor( * * The following fields are required: * ```java - * .customLlmProvider() - * .model() - * .trainingFile() + * .liteLlmFineTuningJobCreate() * ``` */ @JvmStatic fun builder() = Builder() @@ -191,181 +62,22 @@ private constructor( /** A builder for [JobCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var liteLlmFineTuningJobCreate: LiteLlmFineTuningJobCreate? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(jobCreateParams: JobCreateParams) = apply { - body = jobCreateParams.body.toBuilder() + liteLlmFineTuningJobCreate = jobCreateParams.liteLlmFineTuningJobCreate additionalHeaders = jobCreateParams.additionalHeaders.toBuilder() additionalQueryParams = jobCreateParams.additionalQueryParams.toBuilder() } - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [customLlmProvider] - * - [model] - * - [trainingFile] - * - [hyperparameters] - * - [integrations] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun customLlmProvider(customLlmProvider: CustomLlmProvider) = apply { - body.customLlmProvider(customLlmProvider) - } - - /** - * Sets [Builder.customLlmProvider] to an arbitrary JSON value. - * - * You should usually call [Builder.customLlmProvider] with a well-typed [CustomLlmProvider] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun customLlmProvider(customLlmProvider: JsonField) = apply { - body.customLlmProvider(customLlmProvider) - } - - fun model(model: String) = apply { body.model(model) } - - /** - * Sets [Builder.model] to an arbitrary JSON value. - * - * You should usually call [Builder.model] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun model(model: JsonField) = apply { body.model(model) } - - fun trainingFile(trainingFile: String) = apply { body.trainingFile(trainingFile) } - - /** - * Sets [Builder.trainingFile] to an arbitrary JSON value. - * - * You should usually call [Builder.trainingFile] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun trainingFile(trainingFile: JsonField) = apply { - body.trainingFile(trainingFile) - } - - fun hyperparameters(hyperparameters: Hyperparameters?) = apply { - body.hyperparameters(hyperparameters) - } - - /** Alias for calling [Builder.hyperparameters] with `hyperparameters.orElse(null)`. */ - fun hyperparameters(hyperparameters: Optional) = - hyperparameters(hyperparameters.getOrNull()) - - /** - * Sets [Builder.hyperparameters] to an arbitrary JSON value. - * - * You should usually call [Builder.hyperparameters] with a well-typed [Hyperparameters] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun hyperparameters(hyperparameters: JsonField) = apply { - body.hyperparameters(hyperparameters) - } - - fun integrations(integrations: List?) = apply { body.integrations(integrations) } - - /** Alias for calling [Builder.integrations] with `integrations.orElse(null)`. */ - fun integrations(integrations: Optional>) = - integrations(integrations.getOrNull()) - - /** - * Sets [Builder.integrations] to an arbitrary JSON value. - * - * You should usually call [Builder.integrations] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun integrations(integrations: JsonField>) = apply { - body.integrations(integrations) - } - - /** - * Adds a single [String] to [integrations]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addIntegration(integration: String) = apply { body.addIntegration(integration) } - - fun seed(seed: Long?) = apply { body.seed(seed) } - - /** - * Alias for [Builder.seed]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun seed(seed: Long) = seed(seed as Long?) - - /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ - fun seed(seed: Optional) = seed(seed.getOrNull()) - - /** - * Sets [Builder.seed] to an arbitrary JSON value. - * - * You should usually call [Builder.seed] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun seed(seed: JsonField) = apply { body.seed(seed) } - - fun suffix(suffix: String?) = apply { body.suffix(suffix) } - - /** Alias for calling [Builder.suffix] with `suffix.orElse(null)`. */ - fun suffix(suffix: Optional) = suffix(suffix.getOrNull()) - - /** - * Sets [Builder.suffix] to an arbitrary JSON value. - * - * You should usually call [Builder.suffix] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun suffix(suffix: JsonField) = apply { body.suffix(suffix) } - - fun validationFile(validationFile: String?) = apply { body.validationFile(validationFile) } - - /** Alias for calling [Builder.validationFile] with `validationFile.orElse(null)`. */ - fun validationFile(validationFile: Optional) = - validationFile(validationFile.getOrNull()) - - /** - * Sets [Builder.validationFile] to an arbitrary JSON value. - * - * You should usually call [Builder.validationFile] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun validationFile(validationFile: JsonField) = apply { - body.validationFile(validationFile) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + fun liteLlmFineTuningJobCreate(liteLlmFineTuningJobCreate: LiteLlmFineTuningJobCreate) = apply { - body.putAllAdditionalProperties(additionalBodyProperties) + this.liteLlmFineTuningJobCreate = liteLlmFineTuningJobCreate } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -471,1433 +183,39 @@ private constructor( * * The following fields are required: * ```java - * .customLlmProvider() - * .model() - * .trainingFile() + * .liteLlmFineTuningJobCreate() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): JobCreateParams = - JobCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + JobCreateParams( + checkRequired("liteLlmFineTuningJobCreate", liteLlmFineTuningJobCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } - fun _body(): Body = body + fun _body(): LiteLlmFineTuningJobCreate = liteLlmFineTuningJobCreate override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val customLlmProvider: JsonField, - private val model: JsonField, - private val trainingFile: JsonField, - private val hyperparameters: JsonField, - private val integrations: JsonField>, - private val seed: JsonField, - private val suffix: JsonField, - private val validationFile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("custom_llm_provider") - @ExcludeMissing - customLlmProvider: JsonField = JsonMissing.of(), - @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), - @JsonProperty("training_file") - @ExcludeMissing - trainingFile: JsonField = JsonMissing.of(), - @JsonProperty("hyperparameters") - @ExcludeMissing - hyperparameters: JsonField = JsonMissing.of(), - @JsonProperty("integrations") - @ExcludeMissing - integrations: JsonField> = JsonMissing.of(), - @JsonProperty("seed") @ExcludeMissing seed: JsonField = JsonMissing.of(), - @JsonProperty("suffix") @ExcludeMissing suffix: JsonField = JsonMissing.of(), - @JsonProperty("validation_file") - @ExcludeMissing - validationFile: JsonField = JsonMissing.of(), - ) : this( - customLlmProvider, - model, - trainingFile, - hyperparameters, - integrations, - seed, - suffix, - validationFile, - mutableMapOf(), - ) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun customLlmProvider(): CustomLlmProvider = - customLlmProvider.getRequired("custom_llm_provider") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun model(): String = model.getRequired("model") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun trainingFile(): String = trainingFile.getRequired("training_file") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hyperparameters(): Optional = - hyperparameters.getOptional("hyperparameters") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun integrations(): Optional> = integrations.getOptional("integrations") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun seed(): Optional = seed.getOptional("seed") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun suffix(): Optional = suffix.getOptional("suffix") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun validationFile(): Optional = validationFile.getOptional("validation_file") - - /** - * Returns the raw JSON value of [customLlmProvider]. - * - * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_llm_provider") - @ExcludeMissing - fun _customLlmProvider(): JsonField = customLlmProvider - - /** - * Returns the raw JSON value of [model]. - * - * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - - /** - * Returns the raw JSON value of [trainingFile]. - * - * Unlike [trainingFile], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("training_file") - @ExcludeMissing - fun _trainingFile(): JsonField = trainingFile - - /** - * Returns the raw JSON value of [hyperparameters]. - * - * Unlike [hyperparameters], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("hyperparameters") - @ExcludeMissing - fun _hyperparameters(): JsonField = hyperparameters - - /** - * Returns the raw JSON value of [integrations]. - * - * Unlike [integrations], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("integrations") - @ExcludeMissing - fun _integrations(): JsonField> = integrations - - /** - * Returns the raw JSON value of [seed]. - * - * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("seed") @ExcludeMissing fun _seed(): JsonField = seed - - /** - * Returns the raw JSON value of [suffix]. - * - * Unlike [suffix], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("suffix") @ExcludeMissing fun _suffix(): JsonField = suffix - - /** - * Returns the raw JSON value of [validationFile]. - * - * Unlike [validationFile], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("validation_file") - @ExcludeMissing - fun _validationFile(): JsonField = validationFile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .customLlmProvider() - * .model() - * .trainingFile() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var customLlmProvider: JsonField? = null - private var model: JsonField? = null - private var trainingFile: JsonField? = null - private var hyperparameters: JsonField = JsonMissing.of() - private var integrations: JsonField>? = null - private var seed: JsonField = JsonMissing.of() - private var suffix: JsonField = JsonMissing.of() - private var validationFile: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - customLlmProvider = body.customLlmProvider - model = body.model - trainingFile = body.trainingFile - hyperparameters = body.hyperparameters - integrations = body.integrations.map { it.toMutableList() } - seed = body.seed - suffix = body.suffix - validationFile = body.validationFile - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun customLlmProvider(customLlmProvider: CustomLlmProvider) = - customLlmProvider(JsonField.of(customLlmProvider)) - - /** - * Sets [Builder.customLlmProvider] to an arbitrary JSON value. - * - * You should usually call [Builder.customLlmProvider] with a well-typed - * [CustomLlmProvider] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun customLlmProvider(customLlmProvider: JsonField) = apply { - this.customLlmProvider = customLlmProvider - } - - fun model(model: String) = model(JsonField.of(model)) - - /** - * Sets [Builder.model] to an arbitrary JSON value. - * - * You should usually call [Builder.model] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun model(model: JsonField) = apply { this.model = model } - - fun trainingFile(trainingFile: String) = trainingFile(JsonField.of(trainingFile)) - - /** - * Sets [Builder.trainingFile] to an arbitrary JSON value. - * - * You should usually call [Builder.trainingFile] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun trainingFile(trainingFile: JsonField) = apply { - this.trainingFile = trainingFile - } - - fun hyperparameters(hyperparameters: Hyperparameters?) = - hyperparameters(JsonField.ofNullable(hyperparameters)) - - /** Alias for calling [Builder.hyperparameters] with `hyperparameters.orElse(null)`. */ - fun hyperparameters(hyperparameters: Optional) = - hyperparameters(hyperparameters.getOrNull()) - - /** - * Sets [Builder.hyperparameters] to an arbitrary JSON value. - * - * You should usually call [Builder.hyperparameters] with a well-typed [Hyperparameters] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun hyperparameters(hyperparameters: JsonField) = apply { - this.hyperparameters = hyperparameters - } - - fun integrations(integrations: List?) = - integrations(JsonField.ofNullable(integrations)) - - /** Alias for calling [Builder.integrations] with `integrations.orElse(null)`. */ - fun integrations(integrations: Optional>) = - integrations(integrations.getOrNull()) - - /** - * Sets [Builder.integrations] to an arbitrary JSON value. - * - * You should usually call [Builder.integrations] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun integrations(integrations: JsonField>) = apply { - this.integrations = integrations.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [integrations]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addIntegration(integration: String) = apply { - integrations = - (integrations ?: JsonField.of(mutableListOf())).also { - checkKnown("integrations", it).add(integration) - } - } - - fun seed(seed: Long?) = seed(JsonField.ofNullable(seed)) - - /** - * Alias for [Builder.seed]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun seed(seed: Long) = seed(seed as Long?) - - /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ - fun seed(seed: Optional) = seed(seed.getOrNull()) - - /** - * Sets [Builder.seed] to an arbitrary JSON value. - * - * You should usually call [Builder.seed] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun seed(seed: JsonField) = apply { this.seed = seed } - - fun suffix(suffix: String?) = suffix(JsonField.ofNullable(suffix)) - - /** Alias for calling [Builder.suffix] with `suffix.orElse(null)`. */ - fun suffix(suffix: Optional) = suffix(suffix.getOrNull()) - - /** - * Sets [Builder.suffix] to an arbitrary JSON value. - * - * You should usually call [Builder.suffix] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun suffix(suffix: JsonField) = apply { this.suffix = suffix } - - fun validationFile(validationFile: String?) = - validationFile(JsonField.ofNullable(validationFile)) - - /** Alias for calling [Builder.validationFile] with `validationFile.orElse(null)`. */ - fun validationFile(validationFile: Optional) = - validationFile(validationFile.getOrNull()) - - /** - * Sets [Builder.validationFile] to an arbitrary JSON value. - * - * You should usually call [Builder.validationFile] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun validationFile(validationFile: JsonField) = apply { - this.validationFile = validationFile - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customLlmProvider() - * .model() - * .trainingFile() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("customLlmProvider", customLlmProvider), - checkRequired("model", model), - checkRequired("trainingFile", trainingFile), - hyperparameters, - (integrations ?: JsonMissing.of()).map { it.toImmutable() }, - seed, - suffix, - validationFile, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - customLlmProvider().validate() - model() - trainingFile() - hyperparameters().ifPresent { it.validate() } - integrations() - seed() - suffix() - validationFile() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (customLlmProvider.asKnown().getOrNull()?.validity() ?: 0) + - (if (model.asKnown().isPresent) 1 else 0) + - (if (trainingFile.asKnown().isPresent) 1 else 0) + - (hyperparameters.asKnown().getOrNull()?.validity() ?: 0) + - (integrations.asKnown().getOrNull()?.size ?: 0) + - (if (seed.asKnown().isPresent) 1 else 0) + - (if (suffix.asKnown().isPresent) 1 else 0) + - (if (validationFile.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - customLlmProvider == other.customLlmProvider && - model == other.model && - trainingFile == other.trainingFile && - hyperparameters == other.hyperparameters && - integrations == other.integrations && - seed == other.seed && - suffix == other.suffix && - validationFile == other.validationFile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - customLlmProvider, - model, - trainingFile, - hyperparameters, - integrations, - seed, - suffix, - validationFile, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{customLlmProvider=$customLlmProvider, model=$model, trainingFile=$trainingFile, hyperparameters=$hyperparameters, integrations=$integrations, seed=$seed, suffix=$suffix, validationFile=$validationFile, additionalProperties=$additionalProperties}" - } - - class CustomLlmProvider @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val OPENAI = of("openai") - - @JvmField val AZURE = of("azure") - - @JvmField val VERTEX_AI = of("vertex_ai") - - @JvmStatic fun of(value: String) = CustomLlmProvider(JsonField.of(value)) - } - - /** An enum containing [CustomLlmProvider]'s known values. */ - enum class Known { - OPENAI, - AZURE, - VERTEX_AI, - } - - /** - * An enum containing [CustomLlmProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [CustomLlmProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - OPENAI, - AZURE, - VERTEX_AI, - /** - * An enum member indicating that [CustomLlmProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - OPENAI -> Value.OPENAI - AZURE -> Value.AZURE - VERTEX_AI -> Value.VERTEX_AI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws HanzoInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - OPENAI -> Known.OPENAI - AZURE -> Known.AZURE - VERTEX_AI -> Known.VERTEX_AI - else -> throw HanzoInvalidDataException("Unknown CustomLlmProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws HanzoInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): CustomLlmProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomLlmProvider && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Hyperparameters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val batchSize: JsonField, - private val learningRateMultiplier: JsonField, - private val nEpochs: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("batch_size") - @ExcludeMissing - batchSize: JsonField = JsonMissing.of(), - @JsonProperty("learning_rate_multiplier") - @ExcludeMissing - learningRateMultiplier: JsonField = JsonMissing.of(), - @JsonProperty("n_epochs") @ExcludeMissing nEpochs: JsonField = JsonMissing.of(), - ) : this(batchSize, learningRateMultiplier, nEpochs, mutableMapOf()) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun batchSize(): Optional = batchSize.getOptional("batch_size") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun learningRateMultiplier(): Optional = - learningRateMultiplier.getOptional("learning_rate_multiplier") - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun nEpochs(): Optional = nEpochs.getOptional("n_epochs") - - /** - * Returns the raw JSON value of [batchSize]. - * - * Unlike [batchSize], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("batch_size") - @ExcludeMissing - fun _batchSize(): JsonField = batchSize - - /** - * Returns the raw JSON value of [learningRateMultiplier]. - * - * Unlike [learningRateMultiplier], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("learning_rate_multiplier") - @ExcludeMissing - fun _learningRateMultiplier(): JsonField = learningRateMultiplier - - /** - * Returns the raw JSON value of [nEpochs]. - * - * Unlike [nEpochs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("n_epochs") @ExcludeMissing fun _nEpochs(): JsonField = nEpochs - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Hyperparameters]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Hyperparameters]. */ - class Builder internal constructor() { - - private var batchSize: JsonField = JsonMissing.of() - private var learningRateMultiplier: JsonField = JsonMissing.of() - private var nEpochs: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(hyperparameters: Hyperparameters) = apply { - batchSize = hyperparameters.batchSize - learningRateMultiplier = hyperparameters.learningRateMultiplier - nEpochs = hyperparameters.nEpochs - additionalProperties = hyperparameters.additionalProperties.toMutableMap() - } - - fun batchSize(batchSize: BatchSize?) = batchSize(JsonField.ofNullable(batchSize)) - - /** Alias for calling [Builder.batchSize] with `batchSize.orElse(null)`. */ - fun batchSize(batchSize: Optional) = batchSize(batchSize.getOrNull()) - - /** - * Sets [Builder.batchSize] to an arbitrary JSON value. - * - * You should usually call [Builder.batchSize] with a well-typed [BatchSize] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun batchSize(batchSize: JsonField) = apply { this.batchSize = batchSize } - - /** Alias for calling [batchSize] with `BatchSize.ofString(string)`. */ - fun batchSize(string: String) = batchSize(BatchSize.ofString(string)) - - /** Alias for calling [batchSize] with `BatchSize.ofInteger(integer)`. */ - fun batchSize(integer: Long) = batchSize(BatchSize.ofInteger(integer)) - - fun learningRateMultiplier(learningRateMultiplier: LearningRateMultiplier?) = - learningRateMultiplier(JsonField.ofNullable(learningRateMultiplier)) - - /** - * Alias for calling [Builder.learningRateMultiplier] with - * `learningRateMultiplier.orElse(null)`. - */ - fun learningRateMultiplier(learningRateMultiplier: Optional) = - learningRateMultiplier(learningRateMultiplier.getOrNull()) - - /** - * Sets [Builder.learningRateMultiplier] to an arbitrary JSON value. - * - * You should usually call [Builder.learningRateMultiplier] with a well-typed - * [LearningRateMultiplier] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun learningRateMultiplier(learningRateMultiplier: JsonField) = - apply { - this.learningRateMultiplier = learningRateMultiplier - } - - /** - * Alias for calling [learningRateMultiplier] with - * `LearningRateMultiplier.ofString(string)`. - */ - fun learningRateMultiplier(string: String) = - learningRateMultiplier(LearningRateMultiplier.ofString(string)) - - /** - * Alias for calling [learningRateMultiplier] with - * `LearningRateMultiplier.ofNumber(number)`. - */ - fun learningRateMultiplier(number: Double) = - learningRateMultiplier(LearningRateMultiplier.ofNumber(number)) - - fun nEpochs(nEpochs: NEpochs?) = nEpochs(JsonField.ofNullable(nEpochs)) - - /** Alias for calling [Builder.nEpochs] with `nEpochs.orElse(null)`. */ - fun nEpochs(nEpochs: Optional) = nEpochs(nEpochs.getOrNull()) - - /** - * Sets [Builder.nEpochs] to an arbitrary JSON value. - * - * You should usually call [Builder.nEpochs] with a well-typed [NEpochs] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun nEpochs(nEpochs: JsonField) = apply { this.nEpochs = nEpochs } - - /** Alias for calling [nEpochs] with `NEpochs.ofString(string)`. */ - fun nEpochs(string: String) = nEpochs(NEpochs.ofString(string)) - - /** Alias for calling [nEpochs] with `NEpochs.ofInteger(integer)`. */ - fun nEpochs(integer: Long) = nEpochs(NEpochs.ofInteger(integer)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Hyperparameters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Hyperparameters = - Hyperparameters( - batchSize, - learningRateMultiplier, - nEpochs, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Hyperparameters = apply { - if (validated) { - return@apply - } - - batchSize().ifPresent { it.validate() } - learningRateMultiplier().ifPresent { it.validate() } - nEpochs().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (batchSize.asKnown().getOrNull()?.validity() ?: 0) + - (learningRateMultiplier.asKnown().getOrNull()?.validity() ?: 0) + - (nEpochs.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = BatchSize.Deserializer::class) - @JsonSerialize(using = BatchSize.Serializer::class) - class BatchSize - private constructor( - private val string: String? = null, - private val integer: Long? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun integer(): Optional = Optional.ofNullable(integer) - - fun isString(): Boolean = string != null - - fun isInteger(): Boolean = integer != null - - fun asString(): String = string.getOrThrow("string") - - fun asInteger(): Long = integer.getOrThrow("integer") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - integer != null -> visitor.visitInteger(integer) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): BatchSize = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitInteger(integer: Long) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitInteger(integer: Long) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchSize && string == other.string && integer == other.integer - } - - override fun hashCode(): Int = Objects.hash(string, integer) - - override fun toString(): String = - when { - string != null -> "BatchSize{string=$string}" - integer != null -> "BatchSize{integer=$integer}" - _json != null -> "BatchSize{_unknown=$_json}" - else -> throw IllegalStateException("Invalid BatchSize") - } - - companion object { - - @JvmStatic fun ofString(string: String) = BatchSize(string = string) - - @JvmStatic fun ofInteger(integer: Long) = BatchSize(integer = integer) - } - - /** - * An interface that defines how to map each variant of [BatchSize] to a value of type - * [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitInteger(integer: Long): T - - /** - * Maps an unknown variant of [BatchSize] to a value of type [T]. - * - * An instance of [BatchSize] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws HanzoInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw HanzoInvalidDataException("Unknown BatchSize: $json") - } - } - - internal class Deserializer : BaseDeserializer(BatchSize::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): BatchSize { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BatchSize(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - BatchSize(integer = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> BatchSize(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(BatchSize::class) { - - override fun serialize( - value: BatchSize, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.integer != null -> generator.writeObject(value.integer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid BatchSize") - } - } - } - } - - @JsonDeserialize(using = LearningRateMultiplier.Deserializer::class) - @JsonSerialize(using = LearningRateMultiplier.Serializer::class) - class LearningRateMultiplier - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): LearningRateMultiplier = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LearningRateMultiplier && - string == other.string && - number == other.number - } - - override fun hashCode(): Int = Objects.hash(string, number) - - override fun toString(): String = - when { - string != null -> "LearningRateMultiplier{string=$string}" - number != null -> "LearningRateMultiplier{number=$number}" - _json != null -> "LearningRateMultiplier{_unknown=$_json}" - else -> throw IllegalStateException("Invalid LearningRateMultiplier") - } - - companion object { - - @JvmStatic fun ofString(string: String) = LearningRateMultiplier(string = string) - - @JvmStatic fun ofNumber(number: Double) = LearningRateMultiplier(number = number) - } - - /** - * An interface that defines how to map each variant of [LearningRateMultiplier] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - /** - * Maps an unknown variant of [LearningRateMultiplier] to a value of type [T]. - * - * An instance of [LearningRateMultiplier] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws HanzoInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw HanzoInvalidDataException("Unknown LearningRateMultiplier: $json") - } - } - - internal class Deserializer : - BaseDeserializer(LearningRateMultiplier::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): LearningRateMultiplier { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - LearningRateMultiplier(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - LearningRateMultiplier(number = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> LearningRateMultiplier(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(LearningRateMultiplier::class) { - - override fun serialize( - value: LearningRateMultiplier, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.number != null -> generator.writeObject(value.number) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid LearningRateMultiplier") - } - } - } - } - - @JsonDeserialize(using = NEpochs.Deserializer::class) - @JsonSerialize(using = NEpochs.Serializer::class) - class NEpochs - private constructor( - private val string: String? = null, - private val integer: Long? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun integer(): Optional = Optional.ofNullable(integer) - - fun isString(): Boolean = string != null - - fun isInteger(): Boolean = integer != null - - fun asString(): String = string.getOrThrow("string") - - fun asInteger(): Long = integer.getOrThrow("integer") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - integer != null -> visitor.visitInteger(integer) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): NEpochs = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitInteger(integer: Long) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitInteger(integer: Long) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NEpochs && string == other.string && integer == other.integer - } - - override fun hashCode(): Int = Objects.hash(string, integer) - - override fun toString(): String = - when { - string != null -> "NEpochs{string=$string}" - integer != null -> "NEpochs{integer=$integer}" - _json != null -> "NEpochs{_unknown=$_json}" - else -> throw IllegalStateException("Invalid NEpochs") - } - - companion object { - - @JvmStatic fun ofString(string: String) = NEpochs(string = string) - - @JvmStatic fun ofInteger(integer: Long) = NEpochs(integer = integer) - } - - /** - * An interface that defines how to map each variant of [NEpochs] to a value of type - * [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitInteger(integer: Long): T - - /** - * Maps an unknown variant of [NEpochs] to a value of type [T]. - * - * An instance of [NEpochs] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws HanzoInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw HanzoInvalidDataException("Unknown NEpochs: $json") - } - } - - internal class Deserializer : BaseDeserializer(NEpochs::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): NEpochs { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - NEpochs(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - NEpochs(integer = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> NEpochs(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(NEpochs::class) { - - override fun serialize( - value: NEpochs, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.integer != null -> generator.writeObject(value.integer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid NEpochs") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Hyperparameters && - batchSize == other.batchSize && - learningRateMultiplier == other.learningRateMultiplier && - nEpochs == other.nEpochs && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(batchSize, learningRateMultiplier, nEpochs, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Hyperparameters{batchSize=$batchSize, learningRateMultiplier=$learningRateMultiplier, nEpochs=$nEpochs, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is JobCreateParams && - body == other.body && + liteLlmFineTuningJobCreate == other.liteLlmFineTuningJobCreate && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(liteLlmFineTuningJobCreate, additionalHeaders, additionalQueryParams) override fun toString() = - "JobCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "JobCreateParams{liteLlmFineTuningJobCreate=$liteLlmFineTuningJobCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParams.kt index 186faf75..ec99d495 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobListParams.kt @@ -5,7 +5,6 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.Enum import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.errors.HanzoInvalidDataException @@ -19,25 +18,29 @@ import kotlin.jvm.optionals.getOrNull * https://api.openai.com/v1/fine_tuning/jobs * * Supported Query Params: - * - `custom_llm_provider`: Name of the LLM provider + * - `custom_llm_provider`: Name of the LiteLLM provider * - `after`: Identifier for the last job from the previous pagination request. * - `limit`: Number of fine-tuning jobs to retrieve (default is 20). */ class JobListParams private constructor( - private val customLlmProvider: CustomLlmProvider, private val after: String?, + private val customLlmProvider: CustomLlmProvider?, private val limit: Long?, + private val targetModelNames: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customLlmProvider(): CustomLlmProvider = customLlmProvider - fun after(): Optional = Optional.ofNullable(after) + fun customLlmProvider(): Optional = Optional.ofNullable(customLlmProvider) + fun limit(): Optional = Optional.ofNullable(limit) + /** Comma separated list of model names to filter by. Example: 'gpt-4o,gpt-4o-mini' */ + fun targetModelNames(): Optional = Optional.ofNullable(targetModelNames) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -48,44 +51,45 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [JobListParams]. - * - * The following fields are required: - * ```java - * .customLlmProvider() - * ``` - */ + @JvmStatic fun none(): JobListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [JobListParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [JobListParams]. */ class Builder internal constructor() { - private var customLlmProvider: CustomLlmProvider? = null private var after: String? = null + private var customLlmProvider: CustomLlmProvider? = null private var limit: Long? = null + private var targetModelNames: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(jobListParams: JobListParams) = apply { - customLlmProvider = jobListParams.customLlmProvider after = jobListParams.after + customLlmProvider = jobListParams.customLlmProvider limit = jobListParams.limit + targetModelNames = jobListParams.targetModelNames additionalHeaders = jobListParams.additionalHeaders.toBuilder() additionalQueryParams = jobListParams.additionalQueryParams.toBuilder() } - fun customLlmProvider(customLlmProvider: CustomLlmProvider) = apply { - this.customLlmProvider = customLlmProvider - } - fun after(after: String?) = apply { this.after = after } /** Alias for calling [Builder.after] with `after.orElse(null)`. */ fun after(after: Optional) = after(after.getOrNull()) + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = apply { + this.customLlmProvider = customLlmProvider + } + + /** Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + fun limit(limit: Long?) = apply { this.limit = limit } /** @@ -98,6 +102,15 @@ private constructor( /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) + /** Comma separated list of model names to filter by. Example: 'gpt-4o,gpt-4o-mini' */ + fun targetModelNames(targetModelNames: String?) = apply { + this.targetModelNames = targetModelNames + } + + /** Alias for calling [Builder.targetModelNames] with `targetModelNames.orElse(null)`. */ + fun targetModelNames(targetModelNames: Optional) = + targetModelNames(targetModelNames.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -200,19 +213,13 @@ private constructor( * Returns an immutable instance of [JobListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customLlmProvider() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): JobListParams = JobListParams( - checkRequired("customLlmProvider", customLlmProvider), after, + customLlmProvider, limit, + targetModelNames, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -223,9 +230,10 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { - put("custom_llm_provider", customLlmProvider.toString()) after?.let { put("after", it) } + customLlmProvider?.let { put("custom_llm_provider", it.toString()) } limit?.let { put("limit", it.toString()) } + targetModelNames?.let { put("target_model_names", it) } putAll(additionalQueryParams) } .build() @@ -364,16 +372,24 @@ private constructor( } return other is JobListParams && - customLlmProvider == other.customLlmProvider && after == other.after && + customLlmProvider == other.customLlmProvider && limit == other.limit && + targetModelNames == other.targetModelNames && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(customLlmProvider, after, limit, additionalHeaders, additionalQueryParams) + Objects.hash( + after, + customLlmProvider, + limit, + targetModelNames, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "JobListParams{customLlmProvider=$customLlmProvider, after=$after, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "JobListParams{after=$after, customLlmProvider=$customLlmProvider, limit=$limit, targetModelNames=$targetModelNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt index 8ec17d92..e4a8179e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/JobRetrieveParams.kt @@ -5,7 +5,6 @@ package ai.hanzo.api.models.finetuning.jobs import ai.hanzo.api.core.Enum import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.Params -import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.errors.HanzoInvalidDataException @@ -19,20 +18,20 @@ import kotlin.jvm.optionals.getOrNull * https://api.openai.com/v1/fine_tuning/jobs/{fine_tuning_job_id} * * Supported Query Params: - * - `custom_llm_provider`: Name of the LLM provider + * - `custom_llm_provider`: Name of the LiteLLM provider * - `fine_tuning_job_id`: The ID of the fine-tuning job to retrieve. */ class JobRetrieveParams private constructor( private val fineTuningJobId: String?, - private val customLlmProvider: CustomLlmProvider, + private val customLlmProvider: CustomLlmProvider?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun fineTuningJobId(): Optional = Optional.ofNullable(fineTuningJobId) - fun customLlmProvider(): CustomLlmProvider = customLlmProvider + fun customLlmProvider(): Optional = Optional.ofNullable(customLlmProvider) /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -44,14 +43,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [JobRetrieveParams]. - * - * The following fields are required: - * ```java - * .customLlmProvider() - * ``` - */ + @JvmStatic fun none(): JobRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [JobRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -79,10 +73,14 @@ private constructor( fun fineTuningJobId(fineTuningJobId: Optional) = fineTuningJobId(fineTuningJobId.getOrNull()) - fun customLlmProvider(customLlmProvider: CustomLlmProvider) = apply { + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = apply { this.customLlmProvider = customLlmProvider } + /** Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -185,18 +183,11 @@ private constructor( * Returns an immutable instance of [JobRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customLlmProvider() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): JobRetrieveParams = JobRetrieveParams( fineTuningJobId, - checkRequired("customLlmProvider", customLlmProvider), + customLlmProvider, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -213,7 +204,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { - put("custom_llm_provider", customLlmProvider.toString()) + customLlmProvider?.let { put("custom_llm_provider", it.toString()) } putAll(additionalQueryParams) } .build() diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/LiteLlmFineTuningJobCreate.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/LiteLlmFineTuningJobCreate.kt new file mode 100644 index 00000000..74d9325a --- /dev/null +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/LiteLlmFineTuningJobCreate.kt @@ -0,0 +1,1423 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.hanzo.api.models.finetuning.jobs + +import ai.hanzo.api.core.BaseDeserializer +import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.Enum +import ai.hanzo.api.core.ExcludeMissing +import ai.hanzo.api.core.JsonField +import ai.hanzo.api.core.JsonMissing +import ai.hanzo.api.core.JsonValue +import ai.hanzo.api.core.allMaxBy +import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired +import ai.hanzo.api.core.getOrThrow +import ai.hanzo.api.core.toImmutable +import ai.hanzo.api.errors.HanzoInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LiteLlmFineTuningJobCreate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val model: JsonField, + private val trainingFile: JsonField, + private val customLlmProvider: JsonField, + private val hyperparameters: JsonField, + private val integrations: JsonField>, + private val seed: JsonField, + private val suffix: JsonField, + private val validationFile: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("training_file") + @ExcludeMissing + trainingFile: JsonField = JsonMissing.of(), + @JsonProperty("custom_llm_provider") + @ExcludeMissing + customLlmProvider: JsonField = JsonMissing.of(), + @JsonProperty("hyperparameters") + @ExcludeMissing + hyperparameters: JsonField = JsonMissing.of(), + @JsonProperty("integrations") + @ExcludeMissing + integrations: JsonField> = JsonMissing.of(), + @JsonProperty("seed") @ExcludeMissing seed: JsonField = JsonMissing.of(), + @JsonProperty("suffix") @ExcludeMissing suffix: JsonField = JsonMissing.of(), + @JsonProperty("validation_file") + @ExcludeMissing + validationFile: JsonField = JsonMissing.of(), + ) : this( + model, + trainingFile, + customLlmProvider, + hyperparameters, + integrations, + seed, + suffix, + validationFile, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun model(): String = model.getRequired("model") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun trainingFile(): String = trainingFile.getRequired("training_file") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customLlmProvider(): Optional = + customLlmProvider.getOptional("custom_llm_provider") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hyperparameters(): Optional = + hyperparameters.getOptional("hyperparameters") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun integrations(): Optional> = integrations.getOptional("integrations") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun seed(): Optional = seed.getOptional("seed") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun suffix(): Optional = suffix.getOptional("suffix") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun validationFile(): Optional = validationFile.getOptional("validation_file") + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [trainingFile]. + * + * Unlike [trainingFile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("training_file") + @ExcludeMissing + fun _trainingFile(): JsonField = trainingFile + + /** + * Returns the raw JSON value of [customLlmProvider]. + * + * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_llm_provider") + @ExcludeMissing + fun _customLlmProvider(): JsonField = customLlmProvider + + /** + * Returns the raw JSON value of [hyperparameters]. + * + * Unlike [hyperparameters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hyperparameters") + @ExcludeMissing + fun _hyperparameters(): JsonField = hyperparameters + + /** + * Returns the raw JSON value of [integrations]. + * + * Unlike [integrations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("integrations") + @ExcludeMissing + fun _integrations(): JsonField> = integrations + + /** + * Returns the raw JSON value of [seed]. + * + * Unlike [seed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seed") @ExcludeMissing fun _seed(): JsonField = seed + + /** + * Returns the raw JSON value of [suffix]. + * + * Unlike [suffix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("suffix") @ExcludeMissing fun _suffix(): JsonField = suffix + + /** + * Returns the raw JSON value of [validationFile]. + * + * Unlike [validationFile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("validation_file") + @ExcludeMissing + fun _validationFile(): JsonField = validationFile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LiteLlmFineTuningJobCreate]. + * + * The following fields are required: + * ```java + * .model() + * .trainingFile() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LiteLlmFineTuningJobCreate]. */ + class Builder internal constructor() { + + private var model: JsonField? = null + private var trainingFile: JsonField? = null + private var customLlmProvider: JsonField = JsonMissing.of() + private var hyperparameters: JsonField = JsonMissing.of() + private var integrations: JsonField>? = null + private var seed: JsonField = JsonMissing.of() + private var suffix: JsonField = JsonMissing.of() + private var validationFile: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(liteLlmFineTuningJobCreate: LiteLlmFineTuningJobCreate) = apply { + model = liteLlmFineTuningJobCreate.model + trainingFile = liteLlmFineTuningJobCreate.trainingFile + customLlmProvider = liteLlmFineTuningJobCreate.customLlmProvider + hyperparameters = liteLlmFineTuningJobCreate.hyperparameters + integrations = liteLlmFineTuningJobCreate.integrations.map { it.toMutableList() } + seed = liteLlmFineTuningJobCreate.seed + suffix = liteLlmFineTuningJobCreate.suffix + validationFile = liteLlmFineTuningJobCreate.validationFile + additionalProperties = liteLlmFineTuningJobCreate.additionalProperties.toMutableMap() + } + + fun model(model: String) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + fun trainingFile(trainingFile: String) = trainingFile(JsonField.of(trainingFile)) + + /** + * Sets [Builder.trainingFile] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingFile] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun trainingFile(trainingFile: JsonField) = apply { + this.trainingFile = trainingFile + } + + fun customLlmProvider(customLlmProvider: CustomLlmProvider?) = + customLlmProvider(JsonField.ofNullable(customLlmProvider)) + + /** Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + + /** + * Sets [Builder.customLlmProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.customLlmProvider] with a well-typed [CustomLlmProvider] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customLlmProvider(customLlmProvider: JsonField) = apply { + this.customLlmProvider = customLlmProvider + } + + fun hyperparameters(hyperparameters: Hyperparameters?) = + hyperparameters(JsonField.ofNullable(hyperparameters)) + + /** Alias for calling [Builder.hyperparameters] with `hyperparameters.orElse(null)`. */ + fun hyperparameters(hyperparameters: Optional) = + hyperparameters(hyperparameters.getOrNull()) + + /** + * Sets [Builder.hyperparameters] to an arbitrary JSON value. + * + * You should usually call [Builder.hyperparameters] with a well-typed [Hyperparameters] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun hyperparameters(hyperparameters: JsonField) = apply { + this.hyperparameters = hyperparameters + } + + fun integrations(integrations: List?) = + integrations(JsonField.ofNullable(integrations)) + + /** Alias for calling [Builder.integrations] with `integrations.orElse(null)`. */ + fun integrations(integrations: Optional>) = + integrations(integrations.getOrNull()) + + /** + * Sets [Builder.integrations] to an arbitrary JSON value. + * + * You should usually call [Builder.integrations] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun integrations(integrations: JsonField>) = apply { + this.integrations = integrations.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [integrations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIntegration(integration: String) = apply { + integrations = + (integrations ?: JsonField.of(mutableListOf())).also { + checkKnown("integrations", it).add(integration) + } + } + + fun seed(seed: Long?) = seed(JsonField.ofNullable(seed)) + + /** + * Alias for [Builder.seed]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun seed(seed: Long) = seed(seed as Long?) + + /** Alias for calling [Builder.seed] with `seed.orElse(null)`. */ + fun seed(seed: Optional) = seed(seed.getOrNull()) + + /** + * Sets [Builder.seed] to an arbitrary JSON value. + * + * You should usually call [Builder.seed] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun seed(seed: JsonField) = apply { this.seed = seed } + + fun suffix(suffix: String?) = suffix(JsonField.ofNullable(suffix)) + + /** Alias for calling [Builder.suffix] with `suffix.orElse(null)`. */ + fun suffix(suffix: Optional) = suffix(suffix.getOrNull()) + + /** + * Sets [Builder.suffix] to an arbitrary JSON value. + * + * You should usually call [Builder.suffix] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun suffix(suffix: JsonField) = apply { this.suffix = suffix } + + fun validationFile(validationFile: String?) = + validationFile(JsonField.ofNullable(validationFile)) + + /** Alias for calling [Builder.validationFile] with `validationFile.orElse(null)`. */ + fun validationFile(validationFile: Optional) = + validationFile(validationFile.getOrNull()) + + /** + * Sets [Builder.validationFile] to an arbitrary JSON value. + * + * You should usually call [Builder.validationFile] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun validationFile(validationFile: JsonField) = apply { + this.validationFile = validationFile + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LiteLlmFineTuningJobCreate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .model() + * .trainingFile() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LiteLlmFineTuningJobCreate = + LiteLlmFineTuningJobCreate( + checkRequired("model", model), + checkRequired("trainingFile", trainingFile), + customLlmProvider, + hyperparameters, + (integrations ?: JsonMissing.of()).map { it.toImmutable() }, + seed, + suffix, + validationFile, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LiteLlmFineTuningJobCreate = apply { + if (validated) { + return@apply + } + + model() + trainingFile() + customLlmProvider().ifPresent { it.validate() } + hyperparameters().ifPresent { it.validate() } + integrations() + seed() + suffix() + validationFile() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (model.asKnown().isPresent) 1 else 0) + + (if (trainingFile.asKnown().isPresent) 1 else 0) + + (customLlmProvider.asKnown().getOrNull()?.validity() ?: 0) + + (hyperparameters.asKnown().getOrNull()?.validity() ?: 0) + + (integrations.asKnown().getOrNull()?.size ?: 0) + + (if (seed.asKnown().isPresent) 1 else 0) + + (if (suffix.asKnown().isPresent) 1 else 0) + + (if (validationFile.asKnown().isPresent) 1 else 0) + + class CustomLlmProvider @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OPENAI = of("openai") + + @JvmField val AZURE = of("azure") + + @JvmField val VERTEX_AI = of("vertex_ai") + + @JvmStatic fun of(value: String) = CustomLlmProvider(JsonField.of(value)) + } + + /** An enum containing [CustomLlmProvider]'s known values. */ + enum class Known { + OPENAI, + AZURE, + VERTEX_AI, + } + + /** + * An enum containing [CustomLlmProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CustomLlmProvider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPENAI, + AZURE, + VERTEX_AI, + /** + * An enum member indicating that [CustomLlmProvider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPENAI -> Value.OPENAI + AZURE -> Value.AZURE + VERTEX_AI -> Value.VERTEX_AI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + OPENAI -> Known.OPENAI + AZURE -> Known.AZURE + VERTEX_AI -> Known.VERTEX_AI + else -> throw HanzoInvalidDataException("Unknown CustomLlmProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): CustomLlmProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomLlmProvider && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Hyperparameters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val batchSize: JsonField, + private val learningRateMultiplier: JsonField, + private val nEpochs: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("batch_size") + @ExcludeMissing + batchSize: JsonField = JsonMissing.of(), + @JsonProperty("learning_rate_multiplier") + @ExcludeMissing + learningRateMultiplier: JsonField = JsonMissing.of(), + @JsonProperty("n_epochs") @ExcludeMissing nEpochs: JsonField = JsonMissing.of(), + ) : this(batchSize, learningRateMultiplier, nEpochs, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun batchSize(): Optional = batchSize.getOptional("batch_size") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun learningRateMultiplier(): Optional = + learningRateMultiplier.getOptional("learning_rate_multiplier") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nEpochs(): Optional = nEpochs.getOptional("n_epochs") + + /** + * Returns the raw JSON value of [batchSize]. + * + * Unlike [batchSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("batch_size") + @ExcludeMissing + fun _batchSize(): JsonField = batchSize + + /** + * Returns the raw JSON value of [learningRateMultiplier]. + * + * Unlike [learningRateMultiplier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("learning_rate_multiplier") + @ExcludeMissing + fun _learningRateMultiplier(): JsonField = learningRateMultiplier + + /** + * Returns the raw JSON value of [nEpochs]. + * + * Unlike [nEpochs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("n_epochs") @ExcludeMissing fun _nEpochs(): JsonField = nEpochs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Hyperparameters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Hyperparameters]. */ + class Builder internal constructor() { + + private var batchSize: JsonField = JsonMissing.of() + private var learningRateMultiplier: JsonField = JsonMissing.of() + private var nEpochs: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(hyperparameters: Hyperparameters) = apply { + batchSize = hyperparameters.batchSize + learningRateMultiplier = hyperparameters.learningRateMultiplier + nEpochs = hyperparameters.nEpochs + additionalProperties = hyperparameters.additionalProperties.toMutableMap() + } + + fun batchSize(batchSize: BatchSize?) = batchSize(JsonField.ofNullable(batchSize)) + + /** Alias for calling [Builder.batchSize] with `batchSize.orElse(null)`. */ + fun batchSize(batchSize: Optional) = batchSize(batchSize.getOrNull()) + + /** + * Sets [Builder.batchSize] to an arbitrary JSON value. + * + * You should usually call [Builder.batchSize] with a well-typed [BatchSize] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun batchSize(batchSize: JsonField) = apply { this.batchSize = batchSize } + + /** Alias for calling [batchSize] with `BatchSize.ofString(string)`. */ + fun batchSize(string: String) = batchSize(BatchSize.ofString(string)) + + /** Alias for calling [batchSize] with `BatchSize.ofInteger(integer)`. */ + fun batchSize(integer: Long) = batchSize(BatchSize.ofInteger(integer)) + + fun learningRateMultiplier(learningRateMultiplier: LearningRateMultiplier?) = + learningRateMultiplier(JsonField.ofNullable(learningRateMultiplier)) + + /** + * Alias for calling [Builder.learningRateMultiplier] with + * `learningRateMultiplier.orElse(null)`. + */ + fun learningRateMultiplier(learningRateMultiplier: Optional) = + learningRateMultiplier(learningRateMultiplier.getOrNull()) + + /** + * Sets [Builder.learningRateMultiplier] to an arbitrary JSON value. + * + * You should usually call [Builder.learningRateMultiplier] with a well-typed + * [LearningRateMultiplier] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun learningRateMultiplier(learningRateMultiplier: JsonField) = + apply { + this.learningRateMultiplier = learningRateMultiplier + } + + /** + * Alias for calling [learningRateMultiplier] with + * `LearningRateMultiplier.ofString(string)`. + */ + fun learningRateMultiplier(string: String) = + learningRateMultiplier(LearningRateMultiplier.ofString(string)) + + /** + * Alias for calling [learningRateMultiplier] with + * `LearningRateMultiplier.ofNumber(number)`. + */ + fun learningRateMultiplier(number: Double) = + learningRateMultiplier(LearningRateMultiplier.ofNumber(number)) + + fun nEpochs(nEpochs: NEpochs?) = nEpochs(JsonField.ofNullable(nEpochs)) + + /** Alias for calling [Builder.nEpochs] with `nEpochs.orElse(null)`. */ + fun nEpochs(nEpochs: Optional) = nEpochs(nEpochs.getOrNull()) + + /** + * Sets [Builder.nEpochs] to an arbitrary JSON value. + * + * You should usually call [Builder.nEpochs] with a well-typed [NEpochs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun nEpochs(nEpochs: JsonField) = apply { this.nEpochs = nEpochs } + + /** Alias for calling [nEpochs] with `NEpochs.ofString(string)`. */ + fun nEpochs(string: String) = nEpochs(NEpochs.ofString(string)) + + /** Alias for calling [nEpochs] with `NEpochs.ofInteger(integer)`. */ + fun nEpochs(integer: Long) = nEpochs(NEpochs.ofInteger(integer)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Hyperparameters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Hyperparameters = + Hyperparameters( + batchSize, + learningRateMultiplier, + nEpochs, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Hyperparameters = apply { + if (validated) { + return@apply + } + + batchSize().ifPresent { it.validate() } + learningRateMultiplier().ifPresent { it.validate() } + nEpochs().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (batchSize.asKnown().getOrNull()?.validity() ?: 0) + + (learningRateMultiplier.asKnown().getOrNull()?.validity() ?: 0) + + (nEpochs.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = BatchSize.Deserializer::class) + @JsonSerialize(using = BatchSize.Serializer::class) + class BatchSize + private constructor( + private val string: String? = null, + private val integer: Long? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun integer(): Optional = Optional.ofNullable(integer) + + fun isString(): Boolean = string != null + + fun isInteger(): Boolean = integer != null + + fun asString(): String = string.getOrThrow("string") + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + integer != null -> visitor.visitInteger(integer) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): BatchSize = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitInteger(integer: Long) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchSize && string == other.string && integer == other.integer + } + + override fun hashCode(): Int = Objects.hash(string, integer) + + override fun toString(): String = + when { + string != null -> "BatchSize{string=$string}" + integer != null -> "BatchSize{integer=$integer}" + _json != null -> "BatchSize{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BatchSize") + } + + companion object { + + @JvmStatic fun ofString(string: String) = BatchSize(string = string) + + @JvmStatic fun ofInteger(integer: Long) = BatchSize(integer = integer) + } + + /** + * An interface that defines how to map each variant of [BatchSize] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitInteger(integer: Long): T + + /** + * Maps an unknown variant of [BatchSize] to a value of type [T]. + * + * An instance of [BatchSize] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown BatchSize: $json") + } + } + + internal class Deserializer : BaseDeserializer(BatchSize::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BatchSize { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BatchSize(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BatchSize(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> BatchSize(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(BatchSize::class) { + + override fun serialize( + value: BatchSize, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.integer != null -> generator.writeObject(value.integer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BatchSize") + } + } + } + } + + @JsonDeserialize(using = LearningRateMultiplier.Deserializer::class) + @JsonSerialize(using = LearningRateMultiplier.Serializer::class) + class LearningRateMultiplier + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LearningRateMultiplier = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LearningRateMultiplier && + string == other.string && + number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "LearningRateMultiplier{string=$string}" + number != null -> "LearningRateMultiplier{number=$number}" + _json != null -> "LearningRateMultiplier{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LearningRateMultiplier") + } + + companion object { + + @JvmStatic fun ofString(string: String) = LearningRateMultiplier(string = string) + + @JvmStatic fun ofNumber(number: Double) = LearningRateMultiplier(number = number) + } + + /** + * An interface that defines how to map each variant of [LearningRateMultiplier] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [LearningRateMultiplier] to a value of type [T]. + * + * An instance of [LearningRateMultiplier] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown LearningRateMultiplier: $json") + } + } + + internal class Deserializer : + BaseDeserializer(LearningRateMultiplier::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LearningRateMultiplier { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + LearningRateMultiplier(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + LearningRateMultiplier(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> LearningRateMultiplier(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(LearningRateMultiplier::class) { + + override fun serialize( + value: LearningRateMultiplier, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LearningRateMultiplier") + } + } + } + } + + @JsonDeserialize(using = NEpochs.Deserializer::class) + @JsonSerialize(using = NEpochs.Serializer::class) + class NEpochs + private constructor( + private val string: String? = null, + private val integer: Long? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun integer(): Optional = Optional.ofNullable(integer) + + fun isString(): Boolean = string != null + + fun isInteger(): Boolean = integer != null + + fun asString(): String = string.getOrThrow("string") + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + integer != null -> visitor.visitInteger(integer) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): NEpochs = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitInteger(integer: Long) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NEpochs && string == other.string && integer == other.integer + } + + override fun hashCode(): Int = Objects.hash(string, integer) + + override fun toString(): String = + when { + string != null -> "NEpochs{string=$string}" + integer != null -> "NEpochs{integer=$integer}" + _json != null -> "NEpochs{_unknown=$_json}" + else -> throw IllegalStateException("Invalid NEpochs") + } + + companion object { + + @JvmStatic fun ofString(string: String) = NEpochs(string = string) + + @JvmStatic fun ofInteger(integer: Long) = NEpochs(integer = integer) + } + + /** + * An interface that defines how to map each variant of [NEpochs] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitInteger(integer: Long): T + + /** + * Maps an unknown variant of [NEpochs] to a value of type [T]. + * + * An instance of [NEpochs] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown NEpochs: $json") + } + } + + internal class Deserializer : BaseDeserializer(NEpochs::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): NEpochs { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + NEpochs(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + NEpochs(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> NEpochs(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(NEpochs::class) { + + override fun serialize( + value: NEpochs, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.integer != null -> generator.writeObject(value.integer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid NEpochs") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Hyperparameters && + batchSize == other.batchSize && + learningRateMultiplier == other.learningRateMultiplier && + nEpochs == other.nEpochs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(batchSize, learningRateMultiplier, nEpochs, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Hyperparameters{batchSize=$batchSize, learningRateMultiplier=$learningRateMultiplier, nEpochs=$nEpochs, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LiteLlmFineTuningJobCreate && + model == other.model && + trainingFile == other.trainingFile && + customLlmProvider == other.customLlmProvider && + hyperparameters == other.hyperparameters && + integrations == other.integrations && + seed == other.seed && + suffix == other.suffix && + validationFile == other.validationFile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + model, + trainingFile, + customLlmProvider, + hyperparameters, + integrations, + seed, + suffix, + validationFile, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LiteLlmFineTuningJobCreate{model=$model, trainingFile=$trainingFile, customLlmProvider=$customLlmProvider, hyperparameters=$hyperparameters, integrations=$integrations, seed=$seed, suffix=$suffix, validationFile=$validationFile, additionalProperties=$additionalProperties}" +} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt index 5a2edfe8..871a1ebf 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/finetuning/jobs/cancel/CancelCreateParams.kt @@ -18,7 +18,7 @@ import kotlin.jvm.optionals.getOrNull * https://api.openai.com/v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel * * Supported Query Params: - * - `custom_llm_provider`: Name of the LLM provider + * - `custom_llm_provider`: Name of the LiteLLM provider * - `fine_tuning_job_id`: The ID of the fine-tuning job to cancel. */ class CancelCreateParams diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt index baa33ff6..2daf7ab5 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiCreateParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/google_ai_studio) */ class GeminiCreateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt index 66a7a866..39bc96aa 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiDeleteParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/google_ai_studio) */ class GeminiDeleteParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt index ed8e67b4..d6765588 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiPatchParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/google_ai_studio) */ class GeminiPatchParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt index 4734e604..a92d85d9 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiRetrieveParams.kt @@ -9,7 +9,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/google_ai_studio) */ class GeminiRetrieveParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt index edbf90f3..cc690022 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/gemini/GeminiUpdateParams.kt @@ -11,7 +11,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** [Docs](https://docs.hanzo.ai/docs/pass_through/google_ai_studio) */ +/** [Docs](https://docs.litellm.ai/docs/pass_through/google_ai_studio) */ class GeminiUpdateParams private constructor( private val endpoint: String?, diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParams.kt index 0ff066d8..ba4554f2 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsParams.kt @@ -10,7 +10,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * LLM Enterprise - View Spend Per Request Tag. Used by LLM UI + * LiteLLM Enterprise - View Spend Per Request Tag. Used by LiteLLM UI * * Example Request: * ``` diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt index 8df5a212..3decd35e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendListTagsResponse.kt @@ -175,6 +175,12 @@ private constructor( */ fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = spendListTagsResponse.metadata().convert(MyClass.class); + * ``` + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata /** @@ -189,6 +195,12 @@ private constructor( */ fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = spendListTagsResponse.requestTags().convert(MyClass.class); + * ``` + */ @JsonProperty("request_tags") @ExcludeMissing fun _requestTags(): JsonValue = requestTags /** @@ -482,8 +494,9 @@ private constructor( fun messagesOfJsonValues(jsonValues: List) = messages(Messages.ofJsonValues(jsonValues)) - /** Alias for calling [messages] with `Messages.ofJsonValue(jsonValue)`. */ - fun messages(jsonValue: JsonValue) = messages(Messages.ofJsonValue(jsonValue)) + /** Alias for calling [messages] with `Messages.ofUnionMember2(unionMember2)`. */ + fun messages(unionMember2: Messages.UnionMember2) = + messages(Messages.ofUnionMember2(unionMember2)) fun requestId(requestId: String) = requestId(JsonField.of(requestId)) @@ -517,8 +530,9 @@ private constructor( fun responseOfJsonValues(jsonValues: List) = response(Response.ofJsonValues(jsonValues)) - /** Alias for calling [response] with `Response.ofJsonValue(jsonValue)`. */ - fun response(jsonValue: JsonValue) = response(Response.ofJsonValue(jsonValue)) + /** Alias for calling [response] with `Response.ofUnionMember2(unionMember2)`. */ + fun response(unionMember2: Response.UnionMember2) = + response(Response.ofUnionMember2(unionMember2)) fun startTime(startTime: StartTime?) = startTime(JsonField.ofNullable(startTime)) @@ -968,19 +982,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - EndTime(string = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { EndTime(offsetDate = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> EndTime(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1014,7 +1028,7 @@ private constructor( private constructor( private val string: String? = null, private val jsonValues: List? = null, - private val jsonValue: JsonValue? = null, + private val unionMember2: UnionMember2? = null, private val _json: JsonValue? = null, ) { @@ -1022,19 +1036,19 @@ private constructor( fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) fun isString(): Boolean = string != null fun isJsonValues(): Boolean = jsonValues != null - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember2(): Boolean = unionMember2 != null fun asString(): String = string.getOrThrow("string") fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") fun _json(): Optional = Optional.ofNullable(_json) @@ -1042,7 +1056,7 @@ private constructor( when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) else -> visitor.unknown(_json) } @@ -1059,7 +1073,9 @@ private constructor( override fun visitJsonValues(jsonValues: List) {} - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } } ) validated = true @@ -1087,7 +1103,8 @@ private constructor( override fun visitJsonValues(jsonValues: List) = jsonValues.size - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember2(unionMember2: UnionMember2) = + unionMember2.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1101,16 +1118,16 @@ private constructor( return other is Messages && string == other.string && jsonValues == other.jsonValues && - jsonValue == other.jsonValue + unionMember2 == other.unionMember2 } - override fun hashCode(): Int = Objects.hash(string, jsonValues, jsonValue) + override fun hashCode(): Int = Objects.hash(string, jsonValues, unionMember2) override fun toString(): String = when { string != null -> "Messages{string=$string}" jsonValues != null -> "Messages{jsonValues=$jsonValues}" - jsonValue != null -> "Messages{jsonValue=$jsonValue}" + unionMember2 != null -> "Messages{unionMember2=$unionMember2}" _json != null -> "Messages{_unknown=$_json}" else -> throw IllegalStateException("Invalid Messages") } @@ -1123,7 +1140,8 @@ private constructor( fun ofJsonValues(jsonValues: List) = Messages(jsonValues = jsonValues.toImmutable()) - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Messages(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = Messages(unionMember2 = unionMember2) } /** @@ -1135,7 +1153,7 @@ private constructor( fun visitJsonValues(jsonValues: List): T - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember2(unionMember2: UnionMember2): T /** * Maps an unknown variant of [Messages] to a value of type [T]. @@ -1159,22 +1177,22 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(unionMember2 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Messages(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef>())?.let { Messages(jsonValues = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Messages(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> Messages(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1195,12 +1213,114 @@ private constructor( when { value.string != null -> generator.writeObject(value.string) value.jsonValues != null -> generator.writeObject(value.jsonValues) - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Messages") } } } + + class UnionMember2 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = UnionMember2(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = Response.Deserializer::class) @@ -1209,7 +1329,7 @@ private constructor( private constructor( private val string: String? = null, private val jsonValues: List? = null, - private val jsonValue: JsonValue? = null, + private val unionMember2: UnionMember2? = null, private val _json: JsonValue? = null, ) { @@ -1217,19 +1337,19 @@ private constructor( fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) fun isString(): Boolean = string != null fun isJsonValues(): Boolean = jsonValues != null - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember2(): Boolean = unionMember2 != null fun asString(): String = string.getOrThrow("string") fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") fun _json(): Optional = Optional.ofNullable(_json) @@ -1237,7 +1357,7 @@ private constructor( when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) else -> visitor.unknown(_json) } @@ -1254,7 +1374,9 @@ private constructor( override fun visitJsonValues(jsonValues: List) {} - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } } ) validated = true @@ -1282,7 +1404,8 @@ private constructor( override fun visitJsonValues(jsonValues: List) = jsonValues.size - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember2(unionMember2: UnionMember2) = + unionMember2.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1296,16 +1419,16 @@ private constructor( return other is Response && string == other.string && jsonValues == other.jsonValues && - jsonValue == other.jsonValue + unionMember2 == other.unionMember2 } - override fun hashCode(): Int = Objects.hash(string, jsonValues, jsonValue) + override fun hashCode(): Int = Objects.hash(string, jsonValues, unionMember2) override fun toString(): String = when { string != null -> "Response{string=$string}" jsonValues != null -> "Response{jsonValues=$jsonValues}" - jsonValue != null -> "Response{jsonValue=$jsonValue}" + unionMember2 != null -> "Response{unionMember2=$unionMember2}" _json != null -> "Response{_unknown=$_json}" else -> throw IllegalStateException("Invalid Response") } @@ -1318,7 +1441,8 @@ private constructor( fun ofJsonValues(jsonValues: List) = Response(jsonValues = jsonValues.toImmutable()) - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Response(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = Response(unionMember2 = unionMember2) } /** @@ -1330,7 +1454,7 @@ private constructor( fun visitJsonValues(jsonValues: List): T - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember2(unionMember2: UnionMember2): T /** * Maps an unknown variant of [Response] to a value of type [T]. @@ -1354,22 +1478,22 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Response(unionMember2 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Response(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef>())?.let { Response(jsonValues = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Response(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> Response(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1390,12 +1514,114 @@ private constructor( when { value.string != null -> generator.writeObject(value.string) value.jsonValues != null -> generator.writeObject(value.jsonValues) - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Response") } } } + + class UnionMember2 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = UnionMember2(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = StartTime.Deserializer::class) @@ -1528,19 +1754,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - StartTime(string = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { StartTime(offsetDate = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> StartTime(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt index 68a3920a..eb3710c7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendResetParams.kt @@ -13,10 +13,10 @@ import java.util.Optional /** * ADMIN ONLY / MASTER KEY Only Endpoint * - * Globally reset spend for All API Keys and Teams, maintain LLM_SpendLogs - * 1. LLM_SpendLogs will maintain the logs on spend, no data gets deleted from there - * 2. LLM_VerificationTokens spend will be set = 0 - * 3. LLM_TeamTable spend will be set = 0 + * Globally reset spend for All API Keys and Teams, maintain LiteLLM_SpendLogs + * 1. LiteLLM_SpendLogs will maintain the logs on spend, no data gets deleted from there + * 2. LiteLLM_VerificationTokens spend will be set = 0 + * 3. LiteLLM_TeamTable spend will be set = 0 */ class SpendResetParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt index e5db44d4..fc34cdda 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/global/spend/SpendRetrieveReportResponse.kt @@ -175,6 +175,12 @@ private constructor( */ fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = spendRetrieveReportResponse.metadata().convert(MyClass.class); + * ``` + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata /** @@ -189,6 +195,12 @@ private constructor( */ fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = spendRetrieveReportResponse.requestTags().convert(MyClass.class); + * ``` + */ @JsonProperty("request_tags") @ExcludeMissing fun _requestTags(): JsonValue = requestTags /** @@ -482,8 +494,9 @@ private constructor( fun messagesOfJsonValues(jsonValues: List) = messages(Messages.ofJsonValues(jsonValues)) - /** Alias for calling [messages] with `Messages.ofJsonValue(jsonValue)`. */ - fun messages(jsonValue: JsonValue) = messages(Messages.ofJsonValue(jsonValue)) + /** Alias for calling [messages] with `Messages.ofUnionMember2(unionMember2)`. */ + fun messages(unionMember2: Messages.UnionMember2) = + messages(Messages.ofUnionMember2(unionMember2)) fun requestId(requestId: String) = requestId(JsonField.of(requestId)) @@ -517,8 +530,9 @@ private constructor( fun responseOfJsonValues(jsonValues: List) = response(Response.ofJsonValues(jsonValues)) - /** Alias for calling [response] with `Response.ofJsonValue(jsonValue)`. */ - fun response(jsonValue: JsonValue) = response(Response.ofJsonValue(jsonValue)) + /** Alias for calling [response] with `Response.ofUnionMember2(unionMember2)`. */ + fun response(unionMember2: Response.UnionMember2) = + response(Response.ofUnionMember2(unionMember2)) fun startTime(startTime: StartTime?) = startTime(JsonField.ofNullable(startTime)) @@ -968,19 +982,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - EndTime(string = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { EndTime(offsetDate = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndTime(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> EndTime(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1014,7 +1028,7 @@ private constructor( private constructor( private val string: String? = null, private val jsonValues: List? = null, - private val jsonValue: JsonValue? = null, + private val unionMember2: UnionMember2? = null, private val _json: JsonValue? = null, ) { @@ -1022,19 +1036,19 @@ private constructor( fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) fun isString(): Boolean = string != null fun isJsonValues(): Boolean = jsonValues != null - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember2(): Boolean = unionMember2 != null fun asString(): String = string.getOrThrow("string") fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") fun _json(): Optional = Optional.ofNullable(_json) @@ -1042,7 +1056,7 @@ private constructor( when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) else -> visitor.unknown(_json) } @@ -1059,7 +1073,9 @@ private constructor( override fun visitJsonValues(jsonValues: List) {} - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } } ) validated = true @@ -1087,7 +1103,8 @@ private constructor( override fun visitJsonValues(jsonValues: List) = jsonValues.size - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember2(unionMember2: UnionMember2) = + unionMember2.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1101,16 +1118,16 @@ private constructor( return other is Messages && string == other.string && jsonValues == other.jsonValues && - jsonValue == other.jsonValue + unionMember2 == other.unionMember2 } - override fun hashCode(): Int = Objects.hash(string, jsonValues, jsonValue) + override fun hashCode(): Int = Objects.hash(string, jsonValues, unionMember2) override fun toString(): String = when { string != null -> "Messages{string=$string}" jsonValues != null -> "Messages{jsonValues=$jsonValues}" - jsonValue != null -> "Messages{jsonValue=$jsonValue}" + unionMember2 != null -> "Messages{unionMember2=$unionMember2}" _json != null -> "Messages{_unknown=$_json}" else -> throw IllegalStateException("Invalid Messages") } @@ -1123,7 +1140,8 @@ private constructor( fun ofJsonValues(jsonValues: List) = Messages(jsonValues = jsonValues.toImmutable()) - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Messages(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = Messages(unionMember2 = unionMember2) } /** @@ -1135,7 +1153,7 @@ private constructor( fun visitJsonValues(jsonValues: List): T - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember2(unionMember2: UnionMember2): T /** * Maps an unknown variant of [Messages] to a value of type [T]. @@ -1159,22 +1177,22 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Messages(unionMember2 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Messages(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef>())?.let { Messages(jsonValues = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Messages(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> Messages(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1195,12 +1213,114 @@ private constructor( when { value.string != null -> generator.writeObject(value.string) value.jsonValues != null -> generator.writeObject(value.jsonValues) - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Messages") } } } + + class UnionMember2 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = UnionMember2(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = Response.Deserializer::class) @@ -1209,7 +1329,7 @@ private constructor( private constructor( private val string: String? = null, private val jsonValues: List? = null, - private val jsonValue: JsonValue? = null, + private val unionMember2: UnionMember2? = null, private val _json: JsonValue? = null, ) { @@ -1217,19 +1337,19 @@ private constructor( fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) fun isString(): Boolean = string != null fun isJsonValues(): Boolean = jsonValues != null - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember2(): Boolean = unionMember2 != null fun asString(): String = string.getOrThrow("string") fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") fun _json(): Optional = Optional.ofNullable(_json) @@ -1237,7 +1357,7 @@ private constructor( when { string != null -> visitor.visitString(string) jsonValues != null -> visitor.visitJsonValues(jsonValues) - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) else -> visitor.unknown(_json) } @@ -1254,7 +1374,9 @@ private constructor( override fun visitJsonValues(jsonValues: List) {} - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } } ) validated = true @@ -1282,7 +1404,8 @@ private constructor( override fun visitJsonValues(jsonValues: List) = jsonValues.size - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember2(unionMember2: UnionMember2) = + unionMember2.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1296,16 +1419,16 @@ private constructor( return other is Response && string == other.string && jsonValues == other.jsonValues && - jsonValue == other.jsonValue + unionMember2 == other.unionMember2 } - override fun hashCode(): Int = Objects.hash(string, jsonValues, jsonValue) + override fun hashCode(): Int = Objects.hash(string, jsonValues, unionMember2) override fun toString(): String = when { string != null -> "Response{string=$string}" jsonValues != null -> "Response{jsonValues=$jsonValues}" - jsonValue != null -> "Response{jsonValue=$jsonValue}" + unionMember2 != null -> "Response{unionMember2=$unionMember2}" _json != null -> "Response{_unknown=$_json}" else -> throw IllegalStateException("Invalid Response") } @@ -1318,7 +1441,8 @@ private constructor( fun ofJsonValues(jsonValues: List) = Response(jsonValues = jsonValues.toImmutable()) - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Response(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = Response(unionMember2 = unionMember2) } /** @@ -1330,7 +1454,7 @@ private constructor( fun visitJsonValues(jsonValues: List): T - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember2(unionMember2: UnionMember2): T /** * Maps an unknown variant of [Response] to a value of type [T]. @@ -1354,22 +1478,22 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Response(unionMember2 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Response(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef>())?.let { Response(jsonValues = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Response(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> Response(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1390,12 +1514,114 @@ private constructor( when { value.string != null -> generator.writeObject(value.string) value.jsonValues != null -> generator.writeObject(value.jsonValues) - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Response") } } } + + class UnionMember2 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = UnionMember2(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = StartTime.Deserializer::class) @@ -1528,19 +1754,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - StartTime(string = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { StartTime(offsetDate = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartTime(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> StartTime(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt index 394f3b10..29ac864a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListParams.kt @@ -10,7 +10,7 @@ import java.util.Objects /** * List the guardrails that are available on the proxy server * - * 👉 [Guardrail docs](https://docs.hanzo.ai/docs/proxy/guardrails/quick_start) + * 👉 [Guardrail docs](https://docs.litellm.ai/docs/proxy/guardrails/quick_start) * * Example Request: * ```bash diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt index 8eaf8624..964ac072 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/guardrails/GuardrailListResponse.kt @@ -2,29 +2,20 @@ package ai.hanzo.api.models.guardrails -import ai.hanzo.api.core.BaseDeserializer -import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.Enum import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown import ai.hanzo.api.core.checkRequired -import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -190,28 +181,49 @@ private constructor( class Guardrail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val guardrailInfo: JsonValue, private val guardrailName: JsonField, - private val llmParams: JsonField, + private val createdAt: JsonField, + private val guardrailDefinitionLocation: JsonField, + private val guardrailId: JsonField, + private val guardrailInfo: JsonField, + private val litellmParams: JsonField, + private val updatedAt: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("guardrail_info") - @ExcludeMissing - guardrailInfo: JsonValue = JsonMissing.of(), @JsonProperty("guardrail_name") @ExcludeMissing guardrailName: JsonField = JsonMissing.of(), - @JsonProperty("llm_params") + @JsonProperty("created_at") @ExcludeMissing - llmParams: JsonField = JsonMissing.of(), - ) : this(guardrailInfo, guardrailName, llmParams, mutableMapOf()) - - @JsonProperty("guardrail_info") - @ExcludeMissing - fun _guardrailInfo(): JsonValue = guardrailInfo + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("guardrail_definition_location") + @ExcludeMissing + guardrailDefinitionLocation: JsonField = JsonMissing.of(), + @JsonProperty("guardrail_id") + @ExcludeMissing + guardrailId: JsonField = JsonMissing.of(), + @JsonProperty("guardrail_info") + @ExcludeMissing + guardrailInfo: JsonField = JsonMissing.of(), + @JsonProperty("litellm_params") + @ExcludeMissing + litellmParams: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + guardrailName, + createdAt, + guardrailDefinitionLocation, + guardrailId, + guardrailInfo, + litellmParams, + updatedAt, + mutableMapOf(), + ) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is @@ -220,12 +232,41 @@ private constructor( fun guardrailName(): String = guardrailName.getRequired("guardrail_name") /** - * The returned LLM Params object for /guardrails/list - * - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrailDefinitionLocation(): Optional = + guardrailDefinitionLocation.getOptional("guardrail_definition_location") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrailId(): Optional = guardrailId.getOptional("guardrail_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun guardrailInfo(): Optional = guardrailInfo.getOptional("guardrail_info") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmParams(): Optional = litellmParams.getOptional("litellm_params") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun llmParams(): LlmParams = llmParams.getRequired("llm_params") + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") /** * Returns the raw JSON value of [guardrailName]. @@ -238,13 +279,62 @@ private constructor( fun _guardrailName(): JsonField = guardrailName /** - * Returns the raw JSON value of [llmParams]. + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [guardrailDefinitionLocation]. + * + * Unlike [guardrailDefinitionLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("guardrail_definition_location") + @ExcludeMissing + fun _guardrailDefinitionLocation(): JsonField = + guardrailDefinitionLocation + + /** + * Returns the raw JSON value of [guardrailId]. + * + * Unlike [guardrailId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("guardrail_id") + @ExcludeMissing + fun _guardrailId(): JsonField = guardrailId + + /** + * Returns the raw JSON value of [guardrailInfo]. + * + * Unlike [guardrailInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("guardrail_info") + @ExcludeMissing + fun _guardrailInfo(): JsonField = guardrailInfo + + /** + * Returns the raw JSON value of [litellmParams]. + * + * Unlike [litellmParams], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_params") + @ExcludeMissing + fun _litellmParams(): JsonField = litellmParams + + /** + * Returns the raw JSON value of [updatedAt]. * - * Unlike [llmParams], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("llm_params") + @JsonProperty("updated_at") @ExcludeMissing - fun _llmParams(): JsonField = llmParams + fun _updatedAt(): JsonField = updatedAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -265,9 +355,7 @@ private constructor( * * The following fields are required: * ```java - * .guardrailInfo() * .guardrailName() - * .llmParams() * ``` */ @JvmStatic fun builder() = Builder() @@ -276,23 +364,28 @@ private constructor( /** A builder for [Guardrail]. */ class Builder internal constructor() { - private var guardrailInfo: JsonValue? = null private var guardrailName: JsonField? = null - private var llmParams: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var guardrailDefinitionLocation: JsonField = + JsonMissing.of() + private var guardrailId: JsonField = JsonMissing.of() + private var guardrailInfo: JsonField = JsonMissing.of() + private var litellmParams: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(guardrail: Guardrail) = apply { - guardrailInfo = guardrail.guardrailInfo guardrailName = guardrail.guardrailName - llmParams = guardrail.llmParams + createdAt = guardrail.createdAt + guardrailDefinitionLocation = guardrail.guardrailDefinitionLocation + guardrailId = guardrail.guardrailId + guardrailInfo = guardrail.guardrailInfo + litellmParams = guardrail.litellmParams + updatedAt = guardrail.updatedAt additionalProperties = guardrail.additionalProperties.toMutableMap() } - fun guardrailInfo(guardrailInfo: JsonValue) = apply { - this.guardrailInfo = guardrailInfo - } - fun guardrailName(guardrailName: String) = guardrailName(JsonField.of(guardrailName)) /** @@ -306,17 +399,104 @@ private constructor( this.guardrailName = guardrailName } - /** The returned LLM Params object for /guardrails/list */ - fun llmParams(llmParams: LlmParams) = llmParams(JsonField.of(llmParams)) + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun guardrailDefinitionLocation( + guardrailDefinitionLocation: GuardrailDefinitionLocation + ) = guardrailDefinitionLocation(JsonField.of(guardrailDefinitionLocation)) + + /** + * Sets [Builder.guardrailDefinitionLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrailDefinitionLocation] with a well-typed + * [GuardrailDefinitionLocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun guardrailDefinitionLocation( + guardrailDefinitionLocation: JsonField + ) = apply { this.guardrailDefinitionLocation = guardrailDefinitionLocation } + + fun guardrailId(guardrailId: String?) = guardrailId(JsonField.ofNullable(guardrailId)) + + /** Alias for calling [Builder.guardrailId] with `guardrailId.orElse(null)`. */ + fun guardrailId(guardrailId: Optional) = guardrailId(guardrailId.getOrNull()) + + /** + * Sets [Builder.guardrailId] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrailId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun guardrailId(guardrailId: JsonField) = apply { + this.guardrailId = guardrailId + } + + fun guardrailInfo(guardrailInfo: GuardrailInfo?) = + guardrailInfo(JsonField.ofNullable(guardrailInfo)) + + /** Alias for calling [Builder.guardrailInfo] with `guardrailInfo.orElse(null)`. */ + fun guardrailInfo(guardrailInfo: Optional) = + guardrailInfo(guardrailInfo.getOrNull()) + + /** + * Sets [Builder.guardrailInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.guardrailInfo] with a well-typed [GuardrailInfo] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun guardrailInfo(guardrailInfo: JsonField) = apply { + this.guardrailInfo = guardrailInfo + } + + fun litellmParams(litellmParams: LitellmParams?) = + litellmParams(JsonField.ofNullable(litellmParams)) + + /** Alias for calling [Builder.litellmParams] with `litellmParams.orElse(null)`. */ + fun litellmParams(litellmParams: Optional) = + litellmParams(litellmParams.getOrNull()) + + /** + * Sets [Builder.litellmParams] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmParams] with a well-typed [LitellmParams] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun litellmParams(litellmParams: JsonField) = apply { + this.litellmParams = litellmParams + } + + fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) + + /** Alias for calling [Builder.updatedAt] with `updatedAt.orElse(null)`. */ + fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) /** - * Sets [Builder.llmParams] to an arbitrary JSON value. + * Sets [Builder.updatedAt] to an arbitrary JSON value. * - * You should usually call [Builder.llmParams] with a well-typed [LlmParams] value + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun llmParams(llmParams: JsonField) = apply { this.llmParams = llmParams } + fun updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -344,18 +524,20 @@ private constructor( * * The following fields are required: * ```java - * .guardrailInfo() * .guardrailName() - * .llmParams() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): Guardrail = Guardrail( - checkRequired("guardrailInfo", guardrailInfo), checkRequired("guardrailName", guardrailName), - checkRequired("llmParams", llmParams), + createdAt, + guardrailDefinitionLocation, + guardrailId, + guardrailInfo, + litellmParams, + updatedAt, additionalProperties.toMutableMap(), ) } @@ -368,7 +550,12 @@ private constructor( } guardrailName() - llmParams().validate() + createdAt() + guardrailDefinitionLocation().ifPresent { it.validate() } + guardrailId() + guardrailInfo().ifPresent { it.validate() } + litellmParams().ifPresent { it.validate() } + updatedAt() validated = true } @@ -389,157 +576,179 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (guardrailName.asKnown().isPresent) 1 else 0) + - (llmParams.asKnown().getOrNull()?.validity() ?: 0) - - /** The returned LLM Params object for /guardrails/list */ - class LlmParams - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val guardrail: JsonField, - private val mode: JsonField, - private val defaultOn: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("guardrail") - @ExcludeMissing - guardrail: JsonField = JsonMissing.of(), - @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), - @JsonProperty("default_on") - @ExcludeMissing - defaultOn: JsonField = JsonMissing.of(), - ) : this(guardrail, mode, defaultOn, mutableMapOf()) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (guardrailDefinitionLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (guardrailId.asKnown().isPresent) 1 else 0) + + (guardrailInfo.asKnown().getOrNull()?.validity() ?: 0) + + (litellmParams.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + class GuardrailDefinitionLocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - fun guardrail(): String = guardrail.getRequired("guardrail") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DB = of("db") + + @JvmField val CONFIG = of("config") + + @JvmStatic fun of(value: String) = GuardrailDefinitionLocation(JsonField.of(value)) + } + + /** An enum containing [GuardrailDefinitionLocation]'s known values. */ + enum class Known { + DB, + CONFIG, + } /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * An enum containing [GuardrailDefinitionLocation]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [GuardrailDefinitionLocation] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun mode(): Mode = mode.getRequired("mode") + enum class Value { + DB, + CONFIG, + /** + * An enum member indicating that [GuardrailDefinitionLocation] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun defaultOn(): Optional = defaultOn.getOptional("default_on") + fun value(): Value = + when (this) { + DB -> Value.DB + CONFIG -> Value.CONFIG + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [guardrail]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [guardrail], this method doesn't throw if the JSON field has an unexpected - * type. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known + * member. */ - @JsonProperty("guardrail") - @ExcludeMissing - fun _guardrail(): JsonField = guardrail + fun known(): Known = + when (this) { + DB -> Known.DB + CONFIG -> Known.CONFIG + else -> + throw HanzoInvalidDataException( + "Unknown GuardrailDefinitionLocation: $value" + ) + } /** - * Returns the raw JSON value of [mode]. + * Returns this class instance's primitive wire representation. * - * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GuardrailDefinitionLocation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } /** - * Returns the raw JSON value of [defaultOn]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [defaultOn], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("default_on") - @ExcludeMissing - fun _defaultOn(): JsonField = defaultOn + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GuardrailDefinitionLocation && value == other.value } + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GuardrailInfo + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [LlmParams]. - * - * The following fields are required: - * ```java - * .guardrail() - * .mode() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [GuardrailInfo]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [LlmParams]. */ + /** A builder for [GuardrailInfo]. */ class Builder internal constructor() { - private var guardrail: JsonField? = null - private var mode: JsonField? = null - private var defaultOn: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(llmParams: LlmParams) = apply { - guardrail = llmParams.guardrail - mode = llmParams.mode - defaultOn = llmParams.defaultOn - additionalProperties = llmParams.additionalProperties.toMutableMap() + internal fun from(guardrailInfo: GuardrailInfo) = apply { + additionalProperties = guardrailInfo.additionalProperties.toMutableMap() } - fun guardrail(guardrail: String) = guardrail(JsonField.of(guardrail)) - - /** - * Sets [Builder.guardrail] to an arbitrary JSON value. - * - * You should usually call [Builder.guardrail] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun guardrail(guardrail: JsonField) = apply { this.guardrail = guardrail } - - fun mode(mode: Mode) = mode(JsonField.of(mode)) - - /** - * Sets [Builder.mode] to an arbitrary JSON value. - * - * You should usually call [Builder.mode] with a well-typed [Mode] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun mode(mode: JsonField) = apply { this.mode = mode } - - /** Alias for calling [mode] with `Mode.ofString(string)`. */ - fun mode(string: String) = mode(Mode.ofString(string)) - - /** Alias for calling [mode] with `Mode.ofStrings(strings)`. */ - fun modeOfStrings(strings: List) = mode(Mode.ofStrings(strings)) - - fun defaultOn(defaultOn: Boolean) = defaultOn(JsonField.of(defaultOn)) - - /** - * Sets [Builder.defaultOn] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultOn] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun defaultOn(defaultOn: JsonField) = apply { this.defaultOn = defaultOn } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -563,37 +772,20 @@ private constructor( } /** - * Returns an immutable instance of [LlmParams]. + * Returns an immutable instance of [GuardrailInfo]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .guardrail() - * .mode() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): LlmParams = - LlmParams( - checkRequired("guardrail", guardrail), - checkRequired("mode", mode), - defaultOn, - additionalProperties.toMutableMap(), - ) + fun build(): GuardrailInfo = GuardrailInfo(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): LlmParams = apply { + fun validate(): GuardrailInfo = apply { if (validated) { return@apply } - guardrail() - mode().validate() - defaultOn() validated = true } @@ -613,54 +805,1166 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (guardrail.asKnown().isPresent) 1 else 0) + - (mode.asKnown().getOrNull()?.validity() ?: 0) + - (if (defaultOn.asKnown().isPresent) 1 else 0) + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - @JsonDeserialize(using = Mode.Deserializer::class) - @JsonSerialize(using = Mode.Serializer::class) - class Mode - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun string(): Optional = Optional.ofNullable(string) + return other is GuardrailInfo && additionalProperties == other.additionalProperties + } - fun strings(): Optional> = Optional.ofNullable(strings) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun isString(): Boolean = string != null + override fun hashCode(): Int = hashCode - fun isStrings(): Boolean = strings != null + override fun toString() = "GuardrailInfo{additionalProperties=$additionalProperties}" + } - fun asString(): String = string.getOrThrow("string") + class LitellmParams + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalProviderSpecificParams: + JsonField, + private val apiBase: JsonField, + private val apiEndpoint: JsonField, + private val apiKey: JsonField, + private val categoryThresholds: JsonField, + private val credentials: JsonField, + private val defaultOn: JsonField, + private val detectSecretsConfig: JsonField, + private val experimentalUseLatestRoleMessageOnly: JsonField, + private val failOnError: JsonField, + private val guardName: JsonField, + private val location: JsonField, + private val maskRequestContent: JsonField, + private val maskResponseContent: JsonField, + private val model: JsonField, + private val pangeaInputRecipe: JsonField, + private val pangeaOutputRecipe: JsonField, + private val templateId: JsonField, + private val violationMessageTemplate: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asStrings(): List = strings.getOrThrow("strings") + @JsonCreator + private constructor( + @JsonProperty("additional_provider_specific_params") + @ExcludeMissing + additionalProviderSpecificParams: JsonField = + JsonMissing.of(), + @JsonProperty("api_base") + @ExcludeMissing + apiBase: JsonField = JsonMissing.of(), + @JsonProperty("api_endpoint") + @ExcludeMissing + apiEndpoint: JsonField = JsonMissing.of(), + @JsonProperty("api_key") + @ExcludeMissing + apiKey: JsonField = JsonMissing.of(), + @JsonProperty("category_thresholds") + @ExcludeMissing + categoryThresholds: JsonField = JsonMissing.of(), + @JsonProperty("credentials") + @ExcludeMissing + credentials: JsonField = JsonMissing.of(), + @JsonProperty("default_on") + @ExcludeMissing + defaultOn: JsonField = JsonMissing.of(), + @JsonProperty("detect_secrets_config") + @ExcludeMissing + detectSecretsConfig: JsonField = JsonMissing.of(), + @JsonProperty("experimental_use_latest_role_message_only") + @ExcludeMissing + experimentalUseLatestRoleMessageOnly: JsonField = JsonMissing.of(), + @JsonProperty("fail_on_error") + @ExcludeMissing + failOnError: JsonField = JsonMissing.of(), + @JsonProperty("guard_name") + @ExcludeMissing + guardName: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("mask_request_content") + @ExcludeMissing + maskRequestContent: JsonField = JsonMissing.of(), + @JsonProperty("mask_response_content") + @ExcludeMissing + maskResponseContent: JsonField = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("pangea_input_recipe") + @ExcludeMissing + pangeaInputRecipe: JsonField = JsonMissing.of(), + @JsonProperty("pangea_output_recipe") + @ExcludeMissing + pangeaOutputRecipe: JsonField = JsonMissing.of(), + @JsonProperty("template_id") + @ExcludeMissing + templateId: JsonField = JsonMissing.of(), + @JsonProperty("violation_message_template") + @ExcludeMissing + violationMessageTemplate: JsonField = JsonMissing.of(), + ) : this( + additionalProviderSpecificParams, + apiBase, + apiEndpoint, + apiKey, + categoryThresholds, + credentials, + defaultOn, + detectSecretsConfig, + experimentalUseLatestRoleMessageOnly, + failOnError, + guardName, + location, + maskRequestContent, + maskResponseContent, + model, + pangeaInputRecipe, + pangeaOutputRecipe, + templateId, + violationMessageTemplate, + mutableMapOf(), + ) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Additional provider-specific parameters for generic guardrail APIs + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun additionalProviderSpecificParams(): Optional = + additionalProviderSpecificParams.getOptional("additional_provider_specific_params") + + /** + * Base URL for the guardrail service API + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun apiBase(): Optional = apiBase.getOptional("api_base") + + /** + * Optional custom API endpoint for Model Armor + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun apiEndpoint(): Optional = apiEndpoint.getOptional("api_endpoint") + + /** + * API key for the guardrail service + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("api_key") + + /** + * Threshold configuration for Lakera guardrail categories + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun categoryThresholds(): Optional = + categoryThresholds.getOptional("category_thresholds") + + /** + * Path to Google Cloud credentials JSON file or JSON string + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credentials(): Optional = credentials.getOptional("credentials") + + /** + * Whether the guardrail is enabled by default + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultOn(): Optional = defaultOn.getOptional("default_on") + + /** + * Configuration for detect-secrets guardrail + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun detectSecretsConfig(): Optional = + detectSecretsConfig.getOptional("detect_secrets_config") + + /** + * When True, guardrails only receive the latest message for the relevant role (e.g., + * newest user input pre-call, newest assistant output post-call) + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun experimentalUseLatestRoleMessageOnly(): Optional = + experimentalUseLatestRoleMessageOnly.getOptional( + "experimental_use_latest_role_message_only" + ) + + /** + * Whether to fail the request if Model Armor encounters an error + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun failOnError(): Optional = failOnError.getOptional("fail_on_error") + + /** + * Name of the guardrail in guardrails.ai + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun guardName(): Optional = guardName.getOptional("guard_name") + + /** + * Google Cloud location/region (e.g., us-central1) + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun location(): Optional = location.getOptional("location") + + /** + * Will mask request content if guardrail makes any changes + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maskRequestContent(): Optional = + maskRequestContent.getOptional("mask_request_content") + + /** + * Will mask response content if guardrail makes any changes + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maskResponseContent(): Optional = + maskResponseContent.getOptional("mask_response_content") + + /** + * Optional field if guardrail requires a 'model' parameter + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") + + /** + * Recipe for input (LLM request) + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pangeaInputRecipe(): Optional = + pangeaInputRecipe.getOptional("pangea_input_recipe") + + /** + * Recipe for output (LLM response) + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pangeaOutputRecipe(): Optional = + pangeaOutputRecipe.getOptional("pangea_output_recipe") + + /** + * The ID of your Model Armor template + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun templateId(): Optional = templateId.getOptional("template_id") + + /** + * Custom message when a guardrail blocks an action. Supports placeholders like + * {tool_name}, {rule_id}, and {default_message}. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun violationMessageTemplate(): Optional = + violationMessageTemplate.getOptional("violation_message_template") + + /** + * Returns the raw JSON value of [additionalProviderSpecificParams]. + * + * Unlike [additionalProviderSpecificParams], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("additional_provider_specific_params") + @ExcludeMissing + fun _additionalProviderSpecificParams(): JsonField = + additionalProviderSpecificParams + + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_base") @ExcludeMissing fun _apiBase(): JsonField = apiBase + + /** + * Returns the raw JSON value of [apiEndpoint]. + * + * Unlike [apiEndpoint], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("api_endpoint") + @ExcludeMissing + fun _apiEndpoint(): JsonField = apiEndpoint + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [categoryThresholds]. + * + * Unlike [categoryThresholds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("category_thresholds") + @ExcludeMissing + fun _categoryThresholds(): JsonField = categoryThresholds + + /** + * Returns the raw JSON value of [credentials]. + * + * Unlike [credentials], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credentials") + @ExcludeMissing + fun _credentials(): JsonField = credentials + + /** + * Returns the raw JSON value of [defaultOn]. + * + * Unlike [defaultOn], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_on") + @ExcludeMissing + fun _defaultOn(): JsonField = defaultOn + + /** + * Returns the raw JSON value of [detectSecretsConfig]. + * + * Unlike [detectSecretsConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("detect_secrets_config") + @ExcludeMissing + fun _detectSecretsConfig(): JsonField = detectSecretsConfig + + /** + * Returns the raw JSON value of [experimentalUseLatestRoleMessageOnly]. + * + * Unlike [experimentalUseLatestRoleMessageOnly], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("experimental_use_latest_role_message_only") + @ExcludeMissing + fun _experimentalUseLatestRoleMessageOnly(): JsonField = + experimentalUseLatestRoleMessageOnly + + /** + * Returns the raw JSON value of [failOnError]. + * + * Unlike [failOnError], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fail_on_error") + @ExcludeMissing + fun _failOnError(): JsonField = failOnError + + /** + * Returns the raw JSON value of [guardName]. + * + * Unlike [guardName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("guard_name") + @ExcludeMissing + fun _guardName(): JsonField = guardName + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + + /** + * Returns the raw JSON value of [maskRequestContent]. + * + * Unlike [maskRequestContent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mask_request_content") + @ExcludeMissing + fun _maskRequestContent(): JsonField = maskRequestContent + + /** + * Returns the raw JSON value of [maskResponseContent]. + * + * Unlike [maskResponseContent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mask_response_content") + @ExcludeMissing + fun _maskResponseContent(): JsonField = maskResponseContent + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [pangeaInputRecipe]. + * + * Unlike [pangeaInputRecipe], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pangea_input_recipe") + @ExcludeMissing + fun _pangeaInputRecipe(): JsonField = pangeaInputRecipe + + /** + * Returns the raw JSON value of [pangeaOutputRecipe]. + * + * Unlike [pangeaOutputRecipe], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pangea_output_recipe") + @ExcludeMissing + fun _pangeaOutputRecipe(): JsonField = pangeaOutputRecipe + + /** + * Returns the raw JSON value of [templateId]. + * + * Unlike [templateId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template_id") + @ExcludeMissing + fun _templateId(): JsonField = templateId + + /** + * Returns the raw JSON value of [violationMessageTemplate]. + * + * Unlike [violationMessageTemplate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("violation_message_template") + @ExcludeMissing + fun _violationMessageTemplate(): JsonField = violationMessageTemplate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LitellmParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LitellmParams]. */ + class Builder internal constructor() { + + private var additionalProviderSpecificParams: + JsonField = + JsonMissing.of() + private var apiBase: JsonField = JsonMissing.of() + private var apiEndpoint: JsonField = JsonMissing.of() + private var apiKey: JsonField = JsonMissing.of() + private var categoryThresholds: JsonField = JsonMissing.of() + private var credentials: JsonField = JsonMissing.of() + private var defaultOn: JsonField = JsonMissing.of() + private var detectSecretsConfig: JsonField = JsonMissing.of() + private var experimentalUseLatestRoleMessageOnly: JsonField = + JsonMissing.of() + private var failOnError: JsonField = JsonMissing.of() + private var guardName: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var maskRequestContent: JsonField = JsonMissing.of() + private var maskResponseContent: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var pangeaInputRecipe: JsonField = JsonMissing.of() + private var pangeaOutputRecipe: JsonField = JsonMissing.of() + private var templateId: JsonField = JsonMissing.of() + private var violationMessageTemplate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(litellmParams: LitellmParams) = apply { + additionalProviderSpecificParams = + litellmParams.additionalProviderSpecificParams + apiBase = litellmParams.apiBase + apiEndpoint = litellmParams.apiEndpoint + apiKey = litellmParams.apiKey + categoryThresholds = litellmParams.categoryThresholds + credentials = litellmParams.credentials + defaultOn = litellmParams.defaultOn + detectSecretsConfig = litellmParams.detectSecretsConfig + experimentalUseLatestRoleMessageOnly = + litellmParams.experimentalUseLatestRoleMessageOnly + failOnError = litellmParams.failOnError + guardName = litellmParams.guardName + location = litellmParams.location + maskRequestContent = litellmParams.maskRequestContent + maskResponseContent = litellmParams.maskResponseContent + model = litellmParams.model + pangeaInputRecipe = litellmParams.pangeaInputRecipe + pangeaOutputRecipe = litellmParams.pangeaOutputRecipe + templateId = litellmParams.templateId + violationMessageTemplate = litellmParams.violationMessageTemplate + additionalProperties = litellmParams.additionalProperties.toMutableMap() + } + + /** Additional provider-specific parameters for generic guardrail APIs */ + fun additionalProviderSpecificParams( + additionalProviderSpecificParams: AdditionalProviderSpecificParams? + ) = + additionalProviderSpecificParams( + JsonField.ofNullable(additionalProviderSpecificParams) + ) + + /** + * Alias for calling [Builder.additionalProviderSpecificParams] with + * `additionalProviderSpecificParams.orElse(null)`. + */ + fun additionalProviderSpecificParams( + additionalProviderSpecificParams: Optional + ) = additionalProviderSpecificParams(additionalProviderSpecificParams.getOrNull()) + + /** + * Sets [Builder.additionalProviderSpecificParams] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalProviderSpecificParams] with a + * well-typed [AdditionalProviderSpecificParams] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun additionalProviderSpecificParams( + additionalProviderSpecificParams: JsonField + ) = apply { + this.additionalProviderSpecificParams = additionalProviderSpecificParams + } + + /** Base URL for the guardrail service API */ + fun apiBase(apiBase: String?) = apiBase(JsonField.ofNullable(apiBase)) + + /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ + fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } + + /** Optional custom API endpoint for Model Armor */ + fun apiEndpoint(apiEndpoint: String?) = + apiEndpoint(JsonField.ofNullable(apiEndpoint)) + + /** Alias for calling [Builder.apiEndpoint] with `apiEndpoint.orElse(null)`. */ + fun apiEndpoint(apiEndpoint: Optional) = + apiEndpoint(apiEndpoint.getOrNull()) + + /** + * Sets [Builder.apiEndpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.apiEndpoint] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun apiEndpoint(apiEndpoint: JsonField) = apply { + this.apiEndpoint = apiEndpoint + } + + /** API key for the guardrail service */ + fun apiKey(apiKey: String?) = apiKey(JsonField.ofNullable(apiKey)) + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + /** Threshold configuration for Lakera guardrail categories */ + fun categoryThresholds(categoryThresholds: CategoryThresholds?) = + categoryThresholds(JsonField.ofNullable(categoryThresholds)) + + /** + * Alias for calling [Builder.categoryThresholds] with + * `categoryThresholds.orElse(null)`. + */ + fun categoryThresholds(categoryThresholds: Optional) = + categoryThresholds(categoryThresholds.getOrNull()) + + /** + * Sets [Builder.categoryThresholds] to an arbitrary JSON value. + * + * You should usually call [Builder.categoryThresholds] with a well-typed + * [CategoryThresholds] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun categoryThresholds(categoryThresholds: JsonField) = apply { + this.categoryThresholds = categoryThresholds + } + + /** Path to Google Cloud credentials JSON file or JSON string */ + fun credentials(credentials: String?) = + credentials(JsonField.ofNullable(credentials)) + + /** Alias for calling [Builder.credentials] with `credentials.orElse(null)`. */ + fun credentials(credentials: Optional) = + credentials(credentials.getOrNull()) + + /** + * Sets [Builder.credentials] to an arbitrary JSON value. + * + * You should usually call [Builder.credentials] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun credentials(credentials: JsonField) = apply { + this.credentials = credentials + } + + /** Whether the guardrail is enabled by default */ + fun defaultOn(defaultOn: Boolean?) = defaultOn(JsonField.ofNullable(defaultOn)) + + /** + * Alias for [Builder.defaultOn]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun defaultOn(defaultOn: Boolean) = defaultOn(defaultOn as Boolean?) + + /** Alias for calling [Builder.defaultOn] with `defaultOn.orElse(null)`. */ + fun defaultOn(defaultOn: Optional) = defaultOn(defaultOn.getOrNull()) + + /** + * Sets [Builder.defaultOn] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultOn] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun defaultOn(defaultOn: JsonField) = apply { this.defaultOn = defaultOn } + + /** Configuration for detect-secrets guardrail */ + fun detectSecretsConfig(detectSecretsConfig: DetectSecretsConfig?) = + detectSecretsConfig(JsonField.ofNullable(detectSecretsConfig)) + + /** + * Alias for calling [Builder.detectSecretsConfig] with + * `detectSecretsConfig.orElse(null)`. + */ + fun detectSecretsConfig(detectSecretsConfig: Optional) = + detectSecretsConfig(detectSecretsConfig.getOrNull()) + + /** + * Sets [Builder.detectSecretsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.detectSecretsConfig] with a well-typed + * [DetectSecretsConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun detectSecretsConfig(detectSecretsConfig: JsonField) = + apply { + this.detectSecretsConfig = detectSecretsConfig + } + + /** + * When True, guardrails only receive the latest message for the relevant role + * (e.g., newest user input pre-call, newest assistant output post-call) + */ + fun experimentalUseLatestRoleMessageOnly( + experimentalUseLatestRoleMessageOnly: Boolean? + ) = + experimentalUseLatestRoleMessageOnly( + JsonField.ofNullable(experimentalUseLatestRoleMessageOnly) + ) + + /** + * Alias for [Builder.experimentalUseLatestRoleMessageOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun experimentalUseLatestRoleMessageOnly( + experimentalUseLatestRoleMessageOnly: Boolean + ) = + experimentalUseLatestRoleMessageOnly( + experimentalUseLatestRoleMessageOnly as Boolean? + ) + + /** + * Alias for calling [Builder.experimentalUseLatestRoleMessageOnly] with + * `experimentalUseLatestRoleMessageOnly.orElse(null)`. + */ + fun experimentalUseLatestRoleMessageOnly( + experimentalUseLatestRoleMessageOnly: Optional + ) = + experimentalUseLatestRoleMessageOnly( + experimentalUseLatestRoleMessageOnly.getOrNull() + ) + + /** + * Sets [Builder.experimentalUseLatestRoleMessageOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentalUseLatestRoleMessageOnly] with a + * well-typed [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun experimentalUseLatestRoleMessageOnly( + experimentalUseLatestRoleMessageOnly: JsonField + ) = apply { + this.experimentalUseLatestRoleMessageOnly = experimentalUseLatestRoleMessageOnly + } + + /** Whether to fail the request if Model Armor encounters an error */ + fun failOnError(failOnError: Boolean?) = + failOnError(JsonField.ofNullable(failOnError)) + + /** + * Alias for [Builder.failOnError]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun failOnError(failOnError: Boolean) = failOnError(failOnError as Boolean?) + + /** Alias for calling [Builder.failOnError] with `failOnError.orElse(null)`. */ + fun failOnError(failOnError: Optional) = + failOnError(failOnError.getOrNull()) + + /** + * Sets [Builder.failOnError] to an arbitrary JSON value. + * + * You should usually call [Builder.failOnError] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun failOnError(failOnError: JsonField) = apply { + this.failOnError = failOnError + } + + /** Name of the guardrail in guardrails.ai */ + fun guardName(guardName: String?) = guardName(JsonField.ofNullable(guardName)) + + /** Alias for calling [Builder.guardName] with `guardName.orElse(null)`. */ + fun guardName(guardName: Optional) = guardName(guardName.getOrNull()) + + /** + * Sets [Builder.guardName] to an arbitrary JSON value. + * + * You should usually call [Builder.guardName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun guardName(guardName: JsonField) = apply { this.guardName = guardName } + + /** Google Cloud location/region (e.g., us-central1) */ + fun location(location: String?) = location(JsonField.ofNullable(location)) + + /** Alias for calling [Builder.location] with `location.orElse(null)`. */ + fun location(location: Optional) = location(location.getOrNull()) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun location(location: JsonField) = apply { this.location = location } + + /** Will mask request content if guardrail makes any changes */ + fun maskRequestContent(maskRequestContent: Boolean?) = + maskRequestContent(JsonField.ofNullable(maskRequestContent)) + + /** + * Alias for [Builder.maskRequestContent]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maskRequestContent(maskRequestContent: Boolean) = + maskRequestContent(maskRequestContent as Boolean?) + + /** + * Alias for calling [Builder.maskRequestContent] with + * `maskRequestContent.orElse(null)`. + */ + fun maskRequestContent(maskRequestContent: Optional) = + maskRequestContent(maskRequestContent.getOrNull()) + + /** + * Sets [Builder.maskRequestContent] to an arbitrary JSON value. + * + * You should usually call [Builder.maskRequestContent] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun maskRequestContent(maskRequestContent: JsonField) = apply { + this.maskRequestContent = maskRequestContent + } + + /** Will mask response content if guardrail makes any changes */ + fun maskResponseContent(maskResponseContent: Boolean?) = + maskResponseContent(JsonField.ofNullable(maskResponseContent)) + + /** + * Alias for [Builder.maskResponseContent]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maskResponseContent(maskResponseContent: Boolean) = + maskResponseContent(maskResponseContent as Boolean?) + + /** + * Alias for calling [Builder.maskResponseContent] with + * `maskResponseContent.orElse(null)`. + */ + fun maskResponseContent(maskResponseContent: Optional) = + maskResponseContent(maskResponseContent.getOrNull()) + + /** + * Sets [Builder.maskResponseContent] to an arbitrary JSON value. + * + * You should usually call [Builder.maskResponseContent] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun maskResponseContent(maskResponseContent: JsonField) = apply { + this.maskResponseContent = maskResponseContent + } + + /** Optional field if guardrail requires a 'model' parameter */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + /** Recipe for input (LLM request) */ + fun pangeaInputRecipe(pangeaInputRecipe: String?) = + pangeaInputRecipe(JsonField.ofNullable(pangeaInputRecipe)) + + /** + * Alias for calling [Builder.pangeaInputRecipe] with + * `pangeaInputRecipe.orElse(null)`. + */ + fun pangeaInputRecipe(pangeaInputRecipe: Optional) = + pangeaInputRecipe(pangeaInputRecipe.getOrNull()) + + /** + * Sets [Builder.pangeaInputRecipe] to an arbitrary JSON value. + * + * You should usually call [Builder.pangeaInputRecipe] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun pangeaInputRecipe(pangeaInputRecipe: JsonField) = apply { + this.pangeaInputRecipe = pangeaInputRecipe + } + + /** Recipe for output (LLM response) */ + fun pangeaOutputRecipe(pangeaOutputRecipe: String?) = + pangeaOutputRecipe(JsonField.ofNullable(pangeaOutputRecipe)) + + /** + * Alias for calling [Builder.pangeaOutputRecipe] with + * `pangeaOutputRecipe.orElse(null)`. + */ + fun pangeaOutputRecipe(pangeaOutputRecipe: Optional) = + pangeaOutputRecipe(pangeaOutputRecipe.getOrNull()) + + /** + * Sets [Builder.pangeaOutputRecipe] to an arbitrary JSON value. + * + * You should usually call [Builder.pangeaOutputRecipe] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun pangeaOutputRecipe(pangeaOutputRecipe: JsonField) = apply { + this.pangeaOutputRecipe = pangeaOutputRecipe + } + + /** The ID of your Model Armor template */ + fun templateId(templateId: String?) = templateId(JsonField.ofNullable(templateId)) + + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) + + /** + * Sets [Builder.templateId] to an arbitrary JSON value. + * + * You should usually call [Builder.templateId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun templateId(templateId: JsonField) = apply { + this.templateId = templateId + } + + /** + * Custom message when a guardrail blocks an action. Supports placeholders like + * {tool_name}, {rule_id}, and {default_message}. + */ + fun violationMessageTemplate(violationMessageTemplate: String?) = + violationMessageTemplate(JsonField.ofNullable(violationMessageTemplate)) + + /** + * Alias for calling [Builder.violationMessageTemplate] with + * `violationMessageTemplate.orElse(null)`. + */ + fun violationMessageTemplate(violationMessageTemplate: Optional) = + violationMessageTemplate(violationMessageTemplate.getOrNull()) + + /** + * Sets [Builder.violationMessageTemplate] to an arbitrary JSON value. + * + * You should usually call [Builder.violationMessageTemplate] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun violationMessageTemplate(violationMessageTemplate: JsonField) = apply { + this.violationMessageTemplate = violationMessageTemplate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LitellmParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LitellmParams = + LitellmParams( + additionalProviderSpecificParams, + apiBase, + apiEndpoint, + apiKey, + categoryThresholds, + credentials, + defaultOn, + detectSecretsConfig, + experimentalUseLatestRoleMessageOnly, + failOnError, + guardName, + location, + maskRequestContent, + maskResponseContent, + model, + pangeaInputRecipe, + pangeaOutputRecipe, + templateId, + violationMessageTemplate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LitellmParams = apply { + if (validated) { + return@apply + } + + additionalProviderSpecificParams().ifPresent { it.validate() } + apiBase() + apiEndpoint() + apiKey() + categoryThresholds().ifPresent { it.validate() } + credentials() + defaultOn() + detectSecretsConfig().ifPresent { it.validate() } + experimentalUseLatestRoleMessageOnly() + failOnError() + guardName() + location() + maskRequestContent() + maskResponseContent() + model() + pangeaInputRecipe() + pangeaOutputRecipe() + templateId() + violationMessageTemplate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (additionalProviderSpecificParams.asKnown().getOrNull()?.validity() ?: 0) + + (if (apiBase.asKnown().isPresent) 1 else 0) + + (if (apiEndpoint.asKnown().isPresent) 1 else 0) + + (if (apiKey.asKnown().isPresent) 1 else 0) + + (categoryThresholds.asKnown().getOrNull()?.validity() ?: 0) + + (if (credentials.asKnown().isPresent) 1 else 0) + + (if (defaultOn.asKnown().isPresent) 1 else 0) + + (detectSecretsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (experimentalUseLatestRoleMessageOnly.asKnown().isPresent) 1 else 0) + + (if (failOnError.asKnown().isPresent) 1 else 0) + + (if (guardName.asKnown().isPresent) 1 else 0) + + (if (location.asKnown().isPresent) 1 else 0) + + (if (maskRequestContent.asKnown().isPresent) 1 else 0) + + (if (maskResponseContent.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (pangeaInputRecipe.asKnown().isPresent) 1 else 0) + + (if (pangeaOutputRecipe.asKnown().isPresent) 1 else 0) + + (if (templateId.asKnown().isPresent) 1 else 0) + + (if (violationMessageTemplate.asKnown().isPresent) 1 else 0) + + /** Additional provider-specific parameters for generic guardrail APIs */ + class AdditionalProviderSpecificParams + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AdditionalProviderSpecificParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdditionalProviderSpecificParams]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + additionalProviderSpecificParams: AdditionalProviderSpecificParams + ) = apply { + additionalProperties = + additionalProviderSpecificParams.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AdditionalProviderSpecificParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AdditionalProviderSpecificParams = + AdditionalProviderSpecificParams(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): Mode = apply { + fun validate(): AdditionalProviderSpecificParams = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitStrings(strings: List) {} - } - ) validated = true } @@ -680,113 +1984,339 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitStrings(strings: List) = strings.size - - override fun unknown(json: JsonValue?) = 0 - } - ) + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Mode && string == other.string && strings == other.strings + return other is AdditionalProviderSpecificParams && + additionalProperties == other.additionalProperties } - override fun hashCode(): Int = Objects.hash(string, strings) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString(): String = - when { - string != null -> "Mode{string=$string}" - strings != null -> "Mode{strings=$strings}" - _json != null -> "Mode{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Mode") - } + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "AdditionalProviderSpecificParams{additionalProperties=$additionalProperties}" + } + + /** Threshold configuration for Lakera guardrail categories */ + class CategoryThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val jailbreak: JsonField, + private val promptInjection: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmStatic fun ofString(string: String) = Mode(string = string) + @JsonCreator + private constructor( + @JsonProperty("jailbreak") + @ExcludeMissing + jailbreak: JsonField = JsonMissing.of(), + @JsonProperty("prompt_injection") + @ExcludeMissing + promptInjection: JsonField = JsonMissing.of(), + ) : this(jailbreak, promptInjection, mutableMapOf()) - @JvmStatic - fun ofStrings(strings: List) = Mode(strings = strings.toImmutable()) - } + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun jailbreak(): Optional = jailbreak.getOptional("jailbreak") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptInjection(): Optional = + promptInjection.getOptional("prompt_injection") + + /** + * Returns the raw JSON value of [jailbreak]. + * + * Unlike [jailbreak], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("jailbreak") + @ExcludeMissing + fun _jailbreak(): JsonField = jailbreak /** - * An interface that defines how to map each variant of [Mode] to a value of type - * [T]. + * Returns the raw JSON value of [promptInjection]. + * + * Unlike [promptInjection], this method doesn't throw if the JSON field has an + * unexpected type. */ - interface Visitor { + @JsonProperty("prompt_injection") + @ExcludeMissing + fun _promptInjection(): JsonField = promptInjection + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CategoryThresholds]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CategoryThresholds]. */ + class Builder internal constructor() { + + private var jailbreak: JsonField = JsonMissing.of() + private var promptInjection: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun visitString(string: String): T + @JvmSynthetic + internal fun from(categoryThresholds: CategoryThresholds) = apply { + jailbreak = categoryThresholds.jailbreak + promptInjection = categoryThresholds.promptInjection + additionalProperties = + categoryThresholds.additionalProperties.toMutableMap() + } - fun visitStrings(strings: List): T + fun jailbreak(jailbreak: Double) = jailbreak(JsonField.of(jailbreak)) /** - * Maps an unknown variant of [Mode] to a value of type [T]. + * Sets [Builder.jailbreak] to an arbitrary JSON value. * - * An instance of [Mode] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * You should usually call [Builder.jailbreak] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun jailbreak(jailbreak: JsonField) = apply { + this.jailbreak = jailbreak + } + + fun promptInjection(promptInjection: Double) = + promptInjection(JsonField.of(promptInjection)) + + /** + * Sets [Builder.promptInjection] to an arbitrary JSON value. * - * @throws HanzoInvalidDataException in the default implementation. + * You should usually call [Builder.promptInjection] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unknown(json: JsonValue?): T { - throw HanzoInvalidDataException("Unknown Mode: $json") + fun promptInjection(promptInjection: JsonField) = apply { + this.promptInjection = promptInjection + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - } - internal class Deserializer : BaseDeserializer(Mode::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Mode { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Mode(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef>())?.let { - Mode(strings = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> Mode(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CategoryThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CategoryThresholds = + CategoryThresholds( + jailbreak, + promptInjection, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CategoryThresholds = apply { + if (validated) { + return@apply + } + + jailbreak() + promptInjection() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (jailbreak.asKnown().isPresent) 1 else 0) + + (if (promptInjection.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is CategoryThresholds && + jailbreak == other.jailbreak && + promptInjection == other.promptInjection && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(jailbreak, promptInjection, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CategoryThresholds{jailbreak=$jailbreak, promptInjection=$promptInjection, additionalProperties=$additionalProperties}" + } + + /** Configuration for detect-secrets guardrail */ + class DetectSecretsConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DetectSecretsConfig]. + */ + @JvmStatic fun builder() = Builder() } - internal class Serializer : BaseSerializer(Mode::class) { + /** A builder for [DetectSecretsConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(detectSecretsConfig: DetectSecretsConfig) = apply { + additionalProperties = + detectSecretsConfig.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun serialize( - value: Mode, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Mode") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DetectSecretsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DetectSecretsConfig = + DetectSecretsConfig(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): DetectSecretsConfig = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is DetectSecretsConfig && + additionalProperties == other.additionalProperties } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DetectSecretsConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -794,21 +2324,59 @@ private constructor( return true } - return other is LlmParams && - guardrail == other.guardrail && - mode == other.mode && + return other is LitellmParams && + additionalProviderSpecificParams == other.additionalProviderSpecificParams && + apiBase == other.apiBase && + apiEndpoint == other.apiEndpoint && + apiKey == other.apiKey && + categoryThresholds == other.categoryThresholds && + credentials == other.credentials && defaultOn == other.defaultOn && + detectSecretsConfig == other.detectSecretsConfig && + experimentalUseLatestRoleMessageOnly == + other.experimentalUseLatestRoleMessageOnly && + failOnError == other.failOnError && + guardName == other.guardName && + location == other.location && + maskRequestContent == other.maskRequestContent && + maskResponseContent == other.maskResponseContent && + model == other.model && + pangeaInputRecipe == other.pangeaInputRecipe && + pangeaOutputRecipe == other.pangeaOutputRecipe && + templateId == other.templateId && + violationMessageTemplate == other.violationMessageTemplate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(guardrail, mode, defaultOn, additionalProperties) + Objects.hash( + additionalProviderSpecificParams, + apiBase, + apiEndpoint, + apiKey, + categoryThresholds, + credentials, + defaultOn, + detectSecretsConfig, + experimentalUseLatestRoleMessageOnly, + failOnError, + guardName, + location, + maskRequestContent, + maskResponseContent, + model, + pangeaInputRecipe, + pangeaOutputRecipe, + templateId, + violationMessageTemplate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "LlmParams{guardrail=$guardrail, mode=$mode, defaultOn=$defaultOn, additionalProperties=$additionalProperties}" + "LitellmParams{additionalProviderSpecificParams=$additionalProviderSpecificParams, apiBase=$apiBase, apiEndpoint=$apiEndpoint, apiKey=$apiKey, categoryThresholds=$categoryThresholds, credentials=$credentials, defaultOn=$defaultOn, detectSecretsConfig=$detectSecretsConfig, experimentalUseLatestRoleMessageOnly=$experimentalUseLatestRoleMessageOnly, failOnError=$failOnError, guardName=$guardName, location=$location, maskRequestContent=$maskRequestContent, maskResponseContent=$maskResponseContent, model=$model, pangeaInputRecipe=$pangeaInputRecipe, pangeaOutputRecipe=$pangeaOutputRecipe, templateId=$templateId, violationMessageTemplate=$violationMessageTemplate, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -817,20 +2385,33 @@ private constructor( } return other is Guardrail && - guardrailInfo == other.guardrailInfo && guardrailName == other.guardrailName && - llmParams == other.llmParams && + createdAt == other.createdAt && + guardrailDefinitionLocation == other.guardrailDefinitionLocation && + guardrailId == other.guardrailId && + guardrailInfo == other.guardrailInfo && + litellmParams == other.litellmParams && + updatedAt == other.updatedAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(guardrailInfo, guardrailName, llmParams, additionalProperties) + Objects.hash( + guardrailName, + createdAt, + guardrailDefinitionLocation, + guardrailId, + guardrailInfo, + litellmParams, + updatedAt, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Guardrail{guardrailInfo=$guardrailInfo, guardrailName=$guardrailName, llmParams=$llmParams, additionalProperties=$additionalProperties}" + "Guardrail{guardrailName=$guardrailName, createdAt=$createdAt, guardrailDefinitionLocation=$guardrailDefinitionLocation, guardrailId=$guardrailId, guardrailInfo=$guardrailInfo, litellmParams=$litellmParams, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllParams.kt index 359fbe40..26f71784 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckAllParams.kt @@ -12,7 +12,7 @@ import kotlin.jvm.optionals.getOrNull /** * 🚨 USE `/health/liveliness` to health check the proxy 🚨 * - * See more 👉 https://docs.hanzo.ai/docs/proxy/health + * See more 👉 https://docs.litellm.ai/docs/proxy/health * * Check the health of all the endpoints in config.yaml * @@ -28,6 +28,7 @@ import kotlin.jvm.optionals.getOrNull class HealthCheckAllParams private constructor( private val model: String?, + private val modelId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -35,6 +36,9 @@ private constructor( /** Specify the model name (optional) */ fun model(): Optional = Optional.ofNullable(model) + /** Specify the model ID (optional) */ + fun modelId(): Optional = Optional.ofNullable(modelId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -55,12 +59,14 @@ private constructor( class Builder internal constructor() { private var model: String? = null + private var modelId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(healthCheckAllParams: HealthCheckAllParams) = apply { model = healthCheckAllParams.model + modelId = healthCheckAllParams.modelId additionalHeaders = healthCheckAllParams.additionalHeaders.toBuilder() additionalQueryParams = healthCheckAllParams.additionalQueryParams.toBuilder() } @@ -71,6 +77,12 @@ private constructor( /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) + /** Specify the model ID (optional) */ + fun modelId(modelId: String?) = apply { this.modelId = modelId } + + /** Alias for calling [Builder.modelId] with `modelId.orElse(null)`. */ + fun modelId(modelId: Optional) = modelId(modelId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -175,7 +187,12 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): HealthCheckAllParams = - HealthCheckAllParams(model, additionalHeaders.build(), additionalQueryParams.build()) + HealthCheckAllParams( + model, + modelId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) } override fun _headers(): Headers = additionalHeaders @@ -184,6 +201,7 @@ private constructor( QueryParams.builder() .apply { model?.let { put("model", it) } + modelId?.let { put("model_id", it) } putAll(additionalQueryParams) } .build() @@ -195,12 +213,14 @@ private constructor( return other is HealthCheckAllParams && model == other.model && + modelId == other.modelId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(model, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(model, modelId, additionalHeaders, additionalQueryParams) override fun toString() = - "HealthCheckAllParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "HealthCheckAllParams{model=$model, modelId=$modelId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParams.kt index 8f361bff..ca9b250e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/health/HealthCheckServicesParams.kt @@ -223,6 +223,8 @@ private constructor( @JvmField val LANGFUSE = of("langfuse") + @JvmField val LANGFUSE_OTEL = of("langfuse_otel") + @JvmField val SLACK = of("slack") @JvmField val OPENMETER = of("openmeter") @@ -235,6 +237,12 @@ private constructor( @JvmField val DATADOG = of("datadog") + @JvmField val GENERIC_API = of("generic_api") + + @JvmField val ARIZE = of("arize") + + @JvmField val SQS = of("sqs") + @JvmStatic fun of(value: String) = Service(JsonField.of(value)) } @@ -242,12 +250,16 @@ private constructor( enum class Known { SLACK_BUDGET_ALERTS, LANGFUSE, + LANGFUSE_OTEL, SLACK, OPENMETER, WEBHOOK, EMAIL, BRAINTRUST, DATADOG, + GENERIC_API, + ARIZE, + SQS, } /** @@ -262,12 +274,16 @@ private constructor( enum class Value { SLACK_BUDGET_ALERTS, LANGFUSE, + LANGFUSE_OTEL, SLACK, OPENMETER, WEBHOOK, EMAIL, BRAINTRUST, DATADOG, + GENERIC_API, + ARIZE, + SQS, /** An enum member indicating that [Service] was instantiated with an unknown value. */ _UNKNOWN, } @@ -283,12 +299,16 @@ private constructor( when (this) { SLACK_BUDGET_ALERTS -> Value.SLACK_BUDGET_ALERTS LANGFUSE -> Value.LANGFUSE + LANGFUSE_OTEL -> Value.LANGFUSE_OTEL SLACK -> Value.SLACK OPENMETER -> Value.OPENMETER WEBHOOK -> Value.WEBHOOK EMAIL -> Value.EMAIL BRAINTRUST -> Value.BRAINTRUST DATADOG -> Value.DATADOG + GENERIC_API -> Value.GENERIC_API + ARIZE -> Value.ARIZE + SQS -> Value.SQS else -> Value._UNKNOWN } @@ -304,12 +324,16 @@ private constructor( when (this) { SLACK_BUDGET_ALERTS -> Known.SLACK_BUDGET_ALERTS LANGFUSE -> Known.LANGFUSE + LANGFUSE_OTEL -> Known.LANGFUSE_OTEL SLACK -> Known.SLACK OPENMETER -> Known.OPENMETER WEBHOOK -> Known.WEBHOOK EMAIL -> Known.EMAIL BRAINTRUST -> Known.BRAINTRUST DATADOG -> Known.DATADOG + GENERIC_API -> Known.GENERIC_API + ARIZE -> Known.ARIZE + SQS -> Known.SQS else -> throw HanzoInvalidDataException("Unknown Service: $value") } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt index 5bad6c25..8c1f1a74 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/images/generations/GenerationCreateParams.kt @@ -9,15 +9,19 @@ import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Image Generation */ class GenerationCreateParams private constructor( + private val model: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { + fun model(): Optional = Optional.ofNullable(model) + /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -40,18 +44,25 @@ private constructor( /** A builder for [GenerationCreateParams]. */ class Builder internal constructor() { + private var model: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(generationCreateParams: GenerationCreateParams) = apply { + model = generationCreateParams.model additionalHeaders = generationCreateParams.additionalHeaders.toBuilder() additionalQueryParams = generationCreateParams.additionalQueryParams.toBuilder() additionalBodyProperties = generationCreateParams.additionalBodyProperties.toMutableMap() } + fun model(model: String?) = apply { this.model = model } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -179,6 +190,7 @@ private constructor( */ fun build(): GenerationCreateParams = GenerationCreateParams( + model, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -190,7 +202,13 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + model?.let { put("model", it) } + putAll(additionalQueryParams) + } + .build() override fun equals(other: Any?): Boolean { if (this === other) { @@ -198,14 +216,15 @@ private constructor( } return other is GenerationCreateParams && + model == other.model && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int = - Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(model, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = - "GenerationCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "GenerationCreateParams{model=$model, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt index 1f7a9433..71936677 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/GenerateKeyResponse.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.Enum import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing @@ -23,36 +24,47 @@ import kotlin.jvm.optionals.getOrNull class GenerateKeyResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val expires: JsonField, private val key: JsonField, private val token: JsonField, - private val aliases: JsonValue, + private val aliases: JsonField, private val allowedCacheControls: JsonField>, + private val allowedPassthroughRoutes: JsonField>, + private val allowedRoutes: JsonField>, + private val allowedVectorStoreIndexes: JsonField>, private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetId: JsonField, - private val config: JsonValue, + private val config: JsonField, + private val createdAt: JsonField, private val createdBy: JsonField, private val duration: JsonField, private val enforcedParams: JsonField>, + private val expires: JsonField, private val guardrails: JsonField>, private val keyAlias: JsonField, private val keyName: JsonField, - private val llmBudgetTable: JsonValue, + private val litellmBudgetTable: JsonValue, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, - private val metadata: JsonValue, - private val modelMaxBudget: JsonValue, - private val modelRpmLimit: JsonValue, - private val modelTpmLimit: JsonValue, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelRpmLimit: JsonField, + private val modelTpmLimit: JsonField, private val models: JsonField>, - private val permissions: JsonValue, + private val objectPermission: JsonField, + private val organizationId: JsonField, + private val permissions: JsonField, + private val prompts: JsonField>, + private val routerSettings: JsonField, private val rpmLimit: JsonField, + private val rpmLimitType: JsonField, private val spend: JsonField, private val tags: JsonField>, private val teamId: JsonField, private val tokenId: JsonField, private val tpmLimit: JsonField, + private val tpmLimitType: JsonField, + private val updatedAt: JsonField, private val updatedBy: JsonField, private val userId: JsonField, private val additionalProperties: MutableMap, @@ -60,77 +72,116 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("expires") - @ExcludeMissing - expires: JsonField = JsonMissing.of(), @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("aliases") @ExcludeMissing aliases: JsonValue = JsonMissing.of(), + @JsonProperty("aliases") @ExcludeMissing aliases: JsonField = JsonMissing.of(), @JsonProperty("allowed_cache_controls") @ExcludeMissing allowedCacheControls: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + allowedPassthroughRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + allowedVectorStoreIndexes: JsonField> = JsonMissing.of(), @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), @JsonProperty("budget_duration") @ExcludeMissing budgetDuration: JsonField = JsonMissing.of(), @JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("enforced_params") @ExcludeMissing enforcedParams: JsonField> = JsonMissing.of(), + @JsonProperty("expires") + @ExcludeMissing + expires: JsonField = JsonMissing.of(), @JsonProperty("guardrails") @ExcludeMissing guardrails: JsonField> = JsonMissing.of(), @JsonProperty("key_alias") @ExcludeMissing keyAlias: JsonField = JsonMissing.of(), @JsonProperty("key_name") @ExcludeMissing keyName: JsonField = JsonMissing.of(), - @JsonProperty("llm_budget_table") + @JsonProperty("litellm_budget_table") @ExcludeMissing - llmBudgetTable: JsonValue = JsonMissing.of(), + litellmBudgetTable: JsonValue = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @JsonProperty("max_parallel_requests") @ExcludeMissing maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("model_max_budget") @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), + modelMaxBudget: JsonField = JsonMissing.of(), @JsonProperty("model_rpm_limit") @ExcludeMissing - modelRpmLimit: JsonValue = JsonMissing.of(), + modelRpmLimit: JsonField = JsonMissing.of(), @JsonProperty("model_tpm_limit") @ExcludeMissing - modelTpmLimit: JsonValue = JsonMissing.of(), + modelTpmLimit: JsonField = JsonMissing.of(), @JsonProperty("models") @ExcludeMissing models: JsonField> = JsonMissing.of(), - @JsonProperty("permissions") @ExcludeMissing permissions: JsonValue = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField = JsonMissing.of(), + @JsonProperty("prompts") + @ExcludeMissing + prompts: JsonField> = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("rpm_limit_type") + @ExcludeMissing + rpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("team_id") @ExcludeMissing teamId: JsonField = JsonMissing.of(), @JsonProperty("token_id") @ExcludeMissing tokenId: JsonField = JsonMissing.of(), @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("tpm_limit_type") + @ExcludeMissing + tpmLimitType: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("updated_by") @ExcludeMissing updatedBy: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), ) : this( - expires, key, token, aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, blocked, budgetDuration, budgetId, config, + createdAt, createdBy, duration, enforcedParams, + expires, guardrails, keyAlias, keyName, - llmBudgetTable, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, @@ -138,24 +189,25 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + objectPermission, + organizationId, permissions, + prompts, + routerSettings, rpmLimit, + rpmLimitType, spend, tags, teamId, tokenId, tpmLimit, + tpmLimitType, + updatedAt, updatedBy, userId, mutableMapOf(), ) - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expires(): Optional = expires.getOptional("expires") - /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -168,7 +220,11 @@ private constructor( */ fun token(): Optional = token.getOptional("token") - @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -177,6 +233,26 @@ private constructor( fun allowedCacheControls(): Optional> = allowedCacheControls.getOptional("allowed_cache_controls") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedPassthroughRoutes(): Optional> = + allowedPassthroughRoutes.getOptional("allowed_passthrough_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = allowedRoutes.getOptional("allowed_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedVectorStoreIndexes(): Optional> = + allowedVectorStoreIndexes.getOptional("allowed_vector_store_indexes") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -195,7 +271,17 @@ private constructor( */ fun budgetId(): Optional = budgetId.getOptional("budget_id") - @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -215,6 +301,12 @@ private constructor( */ fun enforcedParams(): Optional> = enforcedParams.getOptional("enforced_params") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expires(): Optional = expires.getOptional("expires") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -233,9 +325,15 @@ private constructor( */ fun keyName(): Optional = keyName.getOptional("key_name") - @JsonProperty("llm_budget_table") + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = generateKeyResponse.litellmBudgetTable().convert(MyClass.class); + * ``` + */ + @JsonProperty("litellm_budget_table") @ExcludeMissing - fun _llmBudgetTable(): JsonValue = llmBudgetTable + fun _litellmBudgetTable(): JsonValue = litellmBudgetTable /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -250,15 +348,29 @@ private constructor( fun maxParallelRequests(): Optional = maxParallelRequests.getOptional("max_parallel_requests") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = modelMaxBudget.getOptional("model_max_budget") - @JsonProperty("model_rpm_limit") @ExcludeMissing fun _modelRpmLimit(): JsonValue = modelRpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelRpmLimit(): Optional = modelRpmLimit.getOptional("model_rpm_limit") - @JsonProperty("model_tpm_limit") @ExcludeMissing fun _modelTpmLimit(): JsonValue = modelTpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelTpmLimit(): Optional = modelTpmLimit.getOptional("model_tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -266,7 +378,38 @@ private constructor( */ fun models(): Optional> = models.getOptional("models") - @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun organizationId(): Optional = organizationId.getOptional("organization_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompts(): Optional> = prompts.getOptional("prompts") + + /** + * Set of params that you can modify via `router.update_settings()`. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = routerSettings.getOptional("router_settings") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -274,6 +417,12 @@ private constructor( */ fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpmLimitType(): Optional = rpmLimitType.getOptional("rpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -308,20 +457,25 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updatedBy(): Optional = updatedBy.getOptional("updated_by") + fun tpmLimitType(): Optional = tpmLimitType.getOptional("tpm_limit_type") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun userId(): Optional = userId.getOptional("user_id") + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") /** - * Returns the raw JSON value of [expires]. - * - * Unlike [expires], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("expires") @ExcludeMissing fun _expires(): JsonField = expires + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("user_id") /** * Returns the raw JSON value of [key]. @@ -337,6 +491,13 @@ private constructor( */ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -347,6 +508,36 @@ private constructor( @ExcludeMissing fun _allowedCacheControls(): JsonField> = allowedCacheControls + /** + * Returns the raw JSON value of [allowedPassthroughRoutes]. + * + * Unlike [allowedPassthroughRoutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + fun _allowedPassthroughRoutes(): JsonField> = allowedPassthroughRoutes + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + + /** + * Returns the raw JSON value of [allowedVectorStoreIndexes]. + * + * Unlike [allowedVectorStoreIndexes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + fun _allowedVectorStoreIndexes(): JsonField> = + allowedVectorStoreIndexes + /** * Returns the raw JSON value of [blocked]. * @@ -370,6 +561,22 @@ private constructor( */ @JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + /** * Returns the raw JSON value of [createdBy]. * @@ -393,6 +600,13 @@ private constructor( @ExcludeMissing fun _enforcedParams(): JsonField> = enforcedParams + /** + * Returns the raw JSON value of [expires]. + * + * Unlike [expires], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires") @ExcludeMissing fun _expires(): JsonField = expires + /** * Returns the raw JSON value of [guardrails]. * @@ -433,6 +647,40 @@ private constructor( @ExcludeMissing fun _maxParallelRequests(): JsonField = maxParallelRequests + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget + + /** + * Returns the raw JSON value of [modelRpmLimit]. + * + * Unlike [modelRpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_rpm_limit") + @ExcludeMissing + fun _modelRpmLimit(): JsonField = modelRpmLimit + + /** + * Returns the raw JSON value of [modelTpmLimit]. + * + * Unlike [modelTpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_tpm_limit") + @ExcludeMissing + fun _modelTpmLimit(): JsonField = modelTpmLimit + /** * Returns the raw JSON value of [models]. * @@ -440,6 +688,50 @@ private constructor( */ @JsonProperty("models") @ExcludeMissing fun _models(): JsonField> = models + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object_permission") + @ExcludeMissing + fun _objectPermission(): JsonField = objectPermission + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField = organizationId + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompts") @ExcludeMissing fun _prompts(): JsonField> = prompts + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + /** * Returns the raw JSON value of [rpmLimit]. * @@ -447,6 +739,15 @@ private constructor( */ @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + /** + * Returns the raw JSON value of [rpmLimitType]. + * + * Unlike [rpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rpm_limit_type") + @ExcludeMissing + fun _rpmLimitType(): JsonField = rpmLimitType + /** * Returns the raw JSON value of [spend]. * @@ -482,6 +783,24 @@ private constructor( */ @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit + /** + * Returns the raw JSON value of [tpmLimitType]. + * + * Unlike [tpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tpm_limit_type") + @ExcludeMissing + fun _tpmLimitType(): JsonField = tpmLimitType + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + /** * Returns the raw JSON value of [updatedBy]. * @@ -515,7 +834,6 @@ private constructor( * * The following fields are required: * ```java - * .expires() * .key() * ``` */ @@ -525,59 +843,77 @@ private constructor( /** A builder for [GenerateKeyResponse]. */ class Builder internal constructor() { - private var expires: JsonField? = null private var key: JsonField? = null private var token: JsonField = JsonMissing.of() - private var aliases: JsonValue = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() private var allowedCacheControls: JsonField>? = null + private var allowedPassthroughRoutes: JsonField>? = null + private var allowedRoutes: JsonField>? = null + private var allowedVectorStoreIndexes: JsonField>? = + null private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetId: JsonField = JsonMissing.of() - private var config: JsonValue = JsonMissing.of() + private var config: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var createdBy: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var enforcedParams: JsonField>? = null + private var expires: JsonField = JsonMissing.of() private var guardrails: JsonField>? = null private var keyAlias: JsonField = JsonMissing.of() private var keyName: JsonField = JsonMissing.of() - private var llmBudgetTable: JsonValue = JsonMissing.of() + private var litellmBudgetTable: JsonValue = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var modelRpmLimit: JsonValue = JsonMissing.of() - private var modelTpmLimit: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelRpmLimit: JsonField = JsonMissing.of() + private var modelTpmLimit: JsonField = JsonMissing.of() private var models: JsonField>? = null - private var permissions: JsonValue = JsonMissing.of() + private var objectPermission: JsonField = JsonMissing.of() + private var organizationId: JsonField = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var prompts: JsonField>? = null + private var routerSettings: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() + private var rpmLimitType: JsonField = JsonMissing.of() private var spend: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var teamId: JsonField = JsonMissing.of() private var tokenId: JsonField = JsonMissing.of() private var tpmLimit: JsonField = JsonMissing.of() + private var tpmLimitType: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() private var updatedBy: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(generateKeyResponse: GenerateKeyResponse) = apply { - expires = generateKeyResponse.expires key = generateKeyResponse.key token = generateKeyResponse.token aliases = generateKeyResponse.aliases allowedCacheControls = generateKeyResponse.allowedCacheControls.map { it.toMutableList() } + allowedPassthroughRoutes = + generateKeyResponse.allowedPassthroughRoutes.map { it.toMutableList() } + allowedRoutes = generateKeyResponse.allowedRoutes.map { it.toMutableList() } + allowedVectorStoreIndexes = + generateKeyResponse.allowedVectorStoreIndexes.map { it.toMutableList() } blocked = generateKeyResponse.blocked budgetDuration = generateKeyResponse.budgetDuration budgetId = generateKeyResponse.budgetId config = generateKeyResponse.config + createdAt = generateKeyResponse.createdAt createdBy = generateKeyResponse.createdBy duration = generateKeyResponse.duration enforcedParams = generateKeyResponse.enforcedParams.map { it.toMutableList() } + expires = generateKeyResponse.expires guardrails = generateKeyResponse.guardrails.map { it.toMutableList() } keyAlias = generateKeyResponse.keyAlias keyName = generateKeyResponse.keyName - llmBudgetTable = generateKeyResponse.llmBudgetTable + litellmBudgetTable = generateKeyResponse.litellmBudgetTable maxBudget = generateKeyResponse.maxBudget maxParallelRequests = generateKeyResponse.maxParallelRequests metadata = generateKeyResponse.metadata @@ -585,32 +921,25 @@ private constructor( modelRpmLimit = generateKeyResponse.modelRpmLimit modelTpmLimit = generateKeyResponse.modelTpmLimit models = generateKeyResponse.models.map { it.toMutableList() } + objectPermission = generateKeyResponse.objectPermission + organizationId = generateKeyResponse.organizationId permissions = generateKeyResponse.permissions + prompts = generateKeyResponse.prompts.map { it.toMutableList() } + routerSettings = generateKeyResponse.routerSettings rpmLimit = generateKeyResponse.rpmLimit + rpmLimitType = generateKeyResponse.rpmLimitType spend = generateKeyResponse.spend tags = generateKeyResponse.tags.map { it.toMutableList() } teamId = generateKeyResponse.teamId tokenId = generateKeyResponse.tokenId tpmLimit = generateKeyResponse.tpmLimit + tpmLimitType = generateKeyResponse.tpmLimitType + updatedAt = generateKeyResponse.updatedAt updatedBy = generateKeyResponse.updatedBy userId = generateKeyResponse.userId additionalProperties = generateKeyResponse.additionalProperties.toMutableMap() } - fun expires(expires: OffsetDateTime?) = expires(JsonField.ofNullable(expires)) - - /** Alias for calling [Builder.expires] with `expires.orElse(null)`. */ - fun expires(expires: Optional) = expires(expires.getOrNull()) - - /** - * Sets [Builder.expires] to an arbitrary JSON value. - * - * You should usually call [Builder.expires] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expires(expires: JsonField) = apply { this.expires = expires } - fun key(key: String) = key(JsonField.of(key)) /** @@ -634,7 +963,18 @@ private constructor( */ fun token(token: JsonField) = apply { this.token = token } - fun aliases(aliases: JsonValue) = apply { this.aliases = aliases } + fun aliases(aliases: Aliases?) = aliases(JsonField.ofNullable(aliases)) + + /** Alias for calling [Builder.aliases] with `aliases.orElse(null)`. */ + fun aliases(aliases: Optional) = aliases(aliases.getOrNull()) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } fun allowedCacheControls(allowedCacheControls: List?) = allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) @@ -669,24 +1009,123 @@ private constructor( } } - fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) + fun allowedPassthroughRoutes(allowedPassthroughRoutes: List?) = + allowedPassthroughRoutes(JsonField.ofNullable(allowedPassthroughRoutes)) /** - * Alias for [Builder.blocked]. - * - * This unboxed primitive overload exists for backwards compatibility. + * Alias for calling [Builder.allowedPassthroughRoutes] with + * `allowedPassthroughRoutes.orElse(null)`. */ - fun blocked(blocked: Boolean) = blocked(blocked as Boolean?) - - /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ - fun blocked(blocked: Optional) = blocked(blocked.getOrNull()) + fun allowedPassthroughRoutes(allowedPassthroughRoutes: Optional>) = + allowedPassthroughRoutes(allowedPassthroughRoutes.getOrNull()) /** - * Sets [Builder.blocked] to an arbitrary JSON value. + * Sets [Builder.allowedPassthroughRoutes] to an arbitrary JSON value. * - * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ + * You should usually call [Builder.allowedPassthroughRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: JsonField>) = apply { + this.allowedPassthroughRoutes = allowedPassthroughRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedPassthroughRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedPassthroughRoute(allowedPassthroughRoute: JsonValue) = apply { + allowedPassthroughRoutes = + (allowedPassthroughRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedPassthroughRoutes", it).add(allowedPassthroughRoute) + } + } + + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } + + fun allowedVectorStoreIndexes(allowedVectorStoreIndexes: List?) = + allowedVectorStoreIndexes(JsonField.ofNullable(allowedVectorStoreIndexes)) + + /** + * Alias for calling [Builder.allowedVectorStoreIndexes] with + * `allowedVectorStoreIndexes.orElse(null)`. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: Optional> + ) = allowedVectorStoreIndexes(allowedVectorStoreIndexes.getOrNull()) + + /** + * Sets [Builder.allowedVectorStoreIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedVectorStoreIndexes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: JsonField> + ) = apply { + this.allowedVectorStoreIndexes = allowedVectorStoreIndexes.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedVectorStoreIndex] to [allowedVectorStoreIndexes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedVectorStoreIndex(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + allowedVectorStoreIndexes = + (allowedVectorStoreIndexes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedVectorStoreIndexes", it).add(allowedVectorStoreIndex) + } + } + + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) + + /** + * Alias for [Builder.blocked]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun blocked(blocked: Boolean) = blocked(blocked as Boolean?) + + /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ + fun blocked(blocked: Optional) = blocked(blocked.getOrNull()) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun blocked(blocked: JsonField) = apply { this.blocked = blocked } fun budgetDuration(budgetDuration: String?) = @@ -720,7 +1159,32 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } - fun config(config: JsonValue) = apply { this.config = config } + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } fun createdBy(createdBy: String?) = createdBy(JsonField.ofNullable(createdBy)) @@ -779,6 +1243,20 @@ private constructor( } } + fun expires(expires: OffsetDateTime?) = expires(JsonField.ofNullable(expires)) + + /** Alias for calling [Builder.expires] with `expires.orElse(null)`. */ + fun expires(expires: Optional) = expires(expires.getOrNull()) + + /** + * Sets [Builder.expires] to an arbitrary JSON value. + * + * You should usually call [Builder.expires] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expires(expires: JsonField) = apply { this.expires = expires } + fun guardrails(guardrails: List?) = guardrails(JsonField.ofNullable(guardrails)) /** Alias for calling [Builder.guardrails] with `guardrails.orElse(null)`. */ @@ -833,8 +1311,8 @@ private constructor( */ fun keyName(keyName: JsonField) = apply { this.keyName = keyName } - fun llmBudgetTable(llmBudgetTable: JsonValue) = apply { - this.llmBudgetTable = llmBudgetTable + fun litellmBudgetTable(litellmBudgetTable: JsonValue) = apply { + this.litellmBudgetTable = litellmBudgetTable } fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) @@ -886,15 +1364,73 @@ private constructor( this.maxParallelRequests = maxParallelRequests } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget?) = + modelMaxBudget(JsonField.ofNullable(modelMaxBudget)) - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { + /** Alias for calling [Builder.modelMaxBudget] with `modelMaxBudget.orElse(null)`. */ + fun modelMaxBudget(modelMaxBudget: Optional) = + modelMaxBudget(modelMaxBudget.getOrNull()) + + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { this.modelMaxBudget = modelMaxBudget } - fun modelRpmLimit(modelRpmLimit: JsonValue) = apply { this.modelRpmLimit = modelRpmLimit } + fun modelRpmLimit(modelRpmLimit: ModelRpmLimit?) = + modelRpmLimit(JsonField.ofNullable(modelRpmLimit)) + + /** Alias for calling [Builder.modelRpmLimit] with `modelRpmLimit.orElse(null)`. */ + fun modelRpmLimit(modelRpmLimit: Optional) = + modelRpmLimit(modelRpmLimit.getOrNull()) + + /** + * Sets [Builder.modelRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelRpmLimit] with a well-typed [ModelRpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelRpmLimit(modelRpmLimit: JsonField) = apply { + this.modelRpmLimit = modelRpmLimit + } + + fun modelTpmLimit(modelTpmLimit: ModelTpmLimit?) = + modelTpmLimit(JsonField.ofNullable(modelTpmLimit)) + + /** Alias for calling [Builder.modelTpmLimit] with `modelTpmLimit.orElse(null)`. */ + fun modelTpmLimit(modelTpmLimit: Optional) = + modelTpmLimit(modelTpmLimit.getOrNull()) - fun modelTpmLimit(modelTpmLimit: JsonValue) = apply { this.modelTpmLimit = modelTpmLimit } + /** + * Sets [Builder.modelTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelTpmLimit] with a well-typed [ModelTpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelTpmLimit(modelTpmLimit: JsonField) = apply { + this.modelTpmLimit = modelTpmLimit + } fun models(models: List?) = models(JsonField.ofNullable(models)) @@ -924,7 +1460,104 @@ private constructor( } } - fun permissions(permissions: JsonValue) = apply { this.permissions = permissions } + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) + + /** Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed [ObjectPermission] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField) = apply { + this.organizationId = organizationId + } + + fun permissions(permissions: Permissions?) = permissions(JsonField.ofNullable(permissions)) + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional) = permissions(permissions.getOrNull()) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } + + fun prompts(prompts: List?) = prompts(JsonField.ofNullable(prompts)) + + /** Alias for calling [Builder.prompts] with `prompts.orElse(null)`. */ + fun prompts(prompts: Optional>) = prompts(prompts.getOrNull()) + + /** + * Sets [Builder.prompts] to an arbitrary JSON value. + * + * You should usually call [Builder.prompts] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prompts(prompts: JsonField>) = apply { + this.prompts = prompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [prompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: String) = apply { + prompts = + (prompts ?: JsonField.of(mutableListOf())).also { + checkKnown("prompts", it).add(prompt) + } + } + + /** Set of params that you can modify via `router.update_settings()`. */ + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) @@ -946,6 +1579,24 @@ private constructor( */ fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } + fun rpmLimitType(rpmLimitType: RpmLimitType?) = + rpmLimitType(JsonField.ofNullable(rpmLimitType)) + + /** Alias for calling [Builder.rpmLimitType] with `rpmLimitType.orElse(null)`. */ + fun rpmLimitType(rpmLimitType: Optional) = + rpmLimitType(rpmLimitType.getOrNull()) + + /** + * Sets [Builder.rpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimitType] with a well-typed [RpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimitType(rpmLimitType: JsonField) = apply { + this.rpmLimitType = rpmLimitType + } + fun spend(spend: Double?) = spend(JsonField.ofNullable(spend)) /** @@ -1037,6 +1688,38 @@ private constructor( */ fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } + fun tpmLimitType(tpmLimitType: TpmLimitType?) = + tpmLimitType(JsonField.ofNullable(tpmLimitType)) + + /** Alias for calling [Builder.tpmLimitType] with `tpmLimitType.orElse(null)`. */ + fun tpmLimitType(tpmLimitType: Optional) = + tpmLimitType(tpmLimitType.getOrNull()) + + /** + * Sets [Builder.tpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimitType] with a well-typed [TpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tpmLimitType(tpmLimitType: JsonField) = apply { + this.tpmLimitType = tpmLimitType + } + + fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) + + /** Alias for calling [Builder.updatedAt] with `updatedAt.orElse(null)`. */ + fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + fun updatedBy(updatedBy: String?) = updatedBy(JsonField.ofNullable(updatedBy)) /** Alias for calling [Builder.updatedBy] with `updatedBy.orElse(null)`. */ @@ -1090,7 +1773,6 @@ private constructor( * * The following fields are required: * ```java - * .expires() * .key() * ``` * @@ -1098,22 +1780,26 @@ private constructor( */ fun build(): GenerateKeyResponse = GenerateKeyResponse( - checkRequired("expires", expires), checkRequired("key", key), token, aliases, (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedPassthroughRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedVectorStoreIndexes ?: JsonMissing.of()).map { it.toImmutable() }, blocked, budgetDuration, budgetId, config, + createdAt, createdBy, duration, (enforcedParams ?: JsonMissing.of()).map { it.toImmutable() }, + expires, (guardrails ?: JsonMissing.of()).map { it.toImmutable() }, keyAlias, keyName, - llmBudgetTable, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, @@ -1121,13 +1807,20 @@ private constructor( modelRpmLimit, modelTpmLimit, (models ?: JsonMissing.of()).map { it.toImmutable() }, + objectPermission, + organizationId, permissions, + (prompts ?: JsonMissing.of()).map { it.toImmutable() }, + routerSettings, rpmLimit, + rpmLimitType, spend, (tags ?: JsonMissing.of()).map { it.toImmutable() }, teamId, tokenId, tpmLimit, + tpmLimitType, + updatedAt, updatedBy, userId, additionalProperties.toMutableMap(), @@ -1141,28 +1834,46 @@ private constructor( return@apply } - expires() key() token() + aliases().ifPresent { it.validate() } allowedCacheControls() + allowedPassthroughRoutes() + allowedRoutes() + allowedVectorStoreIndexes().ifPresent { it.forEach { it.validate() } } blocked() budgetDuration() budgetId() + config().ifPresent { it.validate() } + createdAt() createdBy() duration() enforcedParams() + expires() guardrails() keyAlias() keyName() maxBudget() maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelRpmLimit().ifPresent { it.validate() } + modelTpmLimit().ifPresent { it.validate() } models() + objectPermission().ifPresent { it.validate() } + organizationId() + permissions().ifPresent { it.validate() } + prompts() + routerSettings().ifPresent { it.validate() } rpmLimit() + rpmLimitType().ifPresent { it.validate() } spend() tags() teamId() tokenId() tpmLimit() + tpmLimitType().ifPresent { it.validate() } + updatedAt() updatedBy() userId() validated = true @@ -1183,90 +1894,3247 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (expires.asKnown().isPresent) 1 else 0) + - (if (key.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + (if (token.asKnown().isPresent) 1 else 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedPassthroughRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedVectorStoreIndexes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetId.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (createdBy.asKnown().isPresent) 1 else 0) + (if (duration.asKnown().isPresent) 1 else 0) + (enforcedParams.asKnown().getOrNull()?.size ?: 0) + + (if (expires.asKnown().isPresent) 1 else 0) + (guardrails.asKnown().getOrNull()?.size ?: 0) + (if (keyAlias.asKnown().isPresent) 1 else 0) + (if (keyName.asKnown().isPresent) 1 else 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelRpmLimit.asKnown().getOrNull()?.validity() ?: 0) + + (modelTpmLimit.asKnown().getOrNull()?.validity() ?: 0) + (models.asKnown().getOrNull()?.size ?: 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (prompts.asKnown().getOrNull()?.size ?: 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (rpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (spend.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (teamId.asKnown().isPresent) 1 else 0) + (if (tokenId.asKnown().isPresent) 1 else 0) + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (tpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + (if (updatedBy.asKnown().isPresent) 1 else 0) + (if (userId.asKnown().isPresent) 1 else 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + class Aliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() } - return other is GenerateKeyResponse && - expires == other.expires && - key == other.key && - token == other.token && - aliases == other.aliases && - allowedCacheControls == other.allowedCacheControls && - blocked == other.blocked && - budgetDuration == other.budgetDuration && - budgetId == other.budgetId && - config == other.config && - createdBy == other.createdBy && - duration == other.duration && - enforcedParams == other.enforcedParams && - guardrails == other.guardrails && - keyAlias == other.keyAlias && - keyName == other.keyName && - llmBudgetTable == other.llmBudgetTable && - maxBudget == other.maxBudget && - maxParallelRequests == other.maxParallelRequests && - metadata == other.metadata && - modelMaxBudget == other.modelMaxBudget && - modelRpmLimit == other.modelRpmLimit && - modelTpmLimit == other.modelTpmLimit && - models == other.models && - permissions == other.permissions && - rpmLimit == other.rpmLimit && - spend == other.spend && - tags == other.tags && - teamId == other.teamId && - tokenId == other.tokenId && - tpmLimit == other.tpmLimit && - updatedBy == other.updatedBy && - userId == other.userId && - additionalProperties == other.additionalProperties - } + /** A builder for [Aliases]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { - Objects.hash( - expires, - key, - token, - aliases, - allowedCacheControls, - blocked, - budgetDuration, - budgetId, - config, - createdBy, - duration, - enforcedParams, + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class AllowedVectorStoreIndex + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val indexName: JsonField, + private val indexPermissions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("index_name") + @ExcludeMissing + indexName: JsonField = JsonMissing.of(), + @JsonProperty("index_permissions") + @ExcludeMissing + indexPermissions: JsonField> = JsonMissing.of(), + ) : this(indexName, indexPermissions, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexName(): String = indexName.getRequired("index_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexPermissions(): List = + indexPermissions.getRequired("index_permissions") + + /** + * Returns the raw JSON value of [indexName]. + * + * Unlike [indexName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index_name") @ExcludeMissing fun _indexName(): JsonField = indexName + + /** + * Returns the raw JSON value of [indexPermissions]. + * + * Unlike [indexPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("index_permissions") + @ExcludeMissing + fun _indexPermissions(): JsonField> = indexPermissions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AllowedVectorStoreIndex]. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AllowedVectorStoreIndex]. */ + class Builder internal constructor() { + + private var indexName: JsonField? = null + private var indexPermissions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + indexName = allowedVectorStoreIndex.indexName + indexPermissions = + allowedVectorStoreIndex.indexPermissions.map { it.toMutableList() } + additionalProperties = allowedVectorStoreIndex.additionalProperties.toMutableMap() + } + + fun indexName(indexName: String) = indexName(JsonField.of(indexName)) + + /** + * Sets [Builder.indexName] to an arbitrary JSON value. + * + * You should usually call [Builder.indexName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun indexName(indexName: JsonField) = apply { this.indexName = indexName } + + fun indexPermissions(indexPermissions: List) = + indexPermissions(JsonField.of(indexPermissions)) + + /** + * Sets [Builder.indexPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.indexPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun indexPermissions(indexPermissions: JsonField>) = apply { + this.indexPermissions = indexPermissions.map { it.toMutableList() } + } + + /** + * Adds a single [IndexPermission] to [indexPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndexPermission(indexPermission: IndexPermission) = apply { + indexPermissions = + (indexPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("indexPermissions", it).add(indexPermission) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AllowedVectorStoreIndex]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AllowedVectorStoreIndex = + AllowedVectorStoreIndex( + checkRequired("indexName", indexName), + checkRequired("indexPermissions", indexPermissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AllowedVectorStoreIndex = apply { + if (validated) { + return@apply + } + + indexName() + indexPermissions().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (indexName.asKnown().isPresent) 1 else 0) + + (indexPermissions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class IndexPermission + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val READ = of("read") + + @JvmField val WRITE = of("write") + + @JvmStatic fun of(value: String) = IndexPermission(JsonField.of(value)) + } + + /** An enum containing [IndexPermission]'s known values. */ + enum class Known { + READ, + WRITE, + } + + /** + * An enum containing [IndexPermission]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IndexPermission] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + READ, + WRITE, + /** + * An enum member indicating that [IndexPermission] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + READ -> Value.READ + WRITE -> Value.WRITE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + READ -> Known.READ + WRITE -> Known.WRITE + else -> throw HanzoInvalidDataException("Unknown IndexPermission: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): IndexPermission = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexPermission && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedVectorStoreIndex && + indexName == other.indexName && + indexPermissions == other.indexPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(indexName, indexPermissions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AllowedVectorStoreIndex{indexName=$indexName, indexPermissions=$indexPermissions, additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelMaxBudget]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelRpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelRpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelRpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelRpmLimit: ModelRpmLimit) = apply { + additionalProperties = modelRpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelRpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelRpmLimit = ModelRpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelRpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelRpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelRpmLimit{additionalProperties=$additionalProperties}" + } + + class ModelTpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelTpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelTpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelTpmLimit: ModelTpmLimit) = apply { + additionalProperties = modelTpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelTpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelTpmLimit = ModelTpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelTpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelTpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelTpmLimit{additionalProperties=$additionalProperties}" + } + + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vectorStores(): Optional> = vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agents") @ExcludeMissing fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ObjectPermission]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + agentAccessGroups = objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** Alias for calling [Builder.mcpAccessGroups] with `mcpAccessGroups.orElse(null)`. */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ObjectPermission = + ObjectPermission( + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + /** Set of params that you can modify via `router.update_settings()`. */ + class RouterSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowedFails: JsonField, + private val contextWindowFallbacks: JsonField>, + private val cooldownTime: JsonField, + private val fallbacks: JsonField>, + private val maxRetries: JsonField, + private val modelGroupAlias: JsonField, + private val modelGroupRetryPolicy: JsonField, + private val numRetries: JsonField, + private val retryAfter: JsonField, + private val routingStrategy: JsonField, + private val routingStrategyArgs: JsonField, + private val timeout: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_fails") + @ExcludeMissing + allowedFails: JsonField = JsonMissing.of(), + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + contextWindowFallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("cooldown_time") + @ExcludeMissing + cooldownTime: JsonField = JsonMissing.of(), + @JsonProperty("fallbacks") + @ExcludeMissing + fallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("max_retries") + @ExcludeMissing + maxRetries: JsonField = JsonMissing.of(), + @JsonProperty("model_group_alias") + @ExcludeMissing + modelGroupAlias: JsonField = JsonMissing.of(), + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + modelGroupRetryPolicy: JsonField = JsonMissing.of(), + @JsonProperty("num_retries") + @ExcludeMissing + numRetries: JsonField = JsonMissing.of(), + @JsonProperty("retry_after") + @ExcludeMissing + retryAfter: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy") + @ExcludeMissing + routingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy_args") + @ExcludeMissing + routingStrategyArgs: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + ) : this( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedFails(): Optional = allowedFails.getOptional("allowed_fails") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbacks(): Optional> = + contextWindowFallbacks.getOptional("context_window_fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cooldownTime(): Optional = cooldownTime.getOptional("cooldown_time") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = fallbacks.getOptional("fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupAlias(): Optional = + modelGroupAlias.getOptional("model_group_alias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupRetryPolicy(): Optional = + modelGroupRetryPolicy.getOptional("model_group_retry_policy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = numRetries.getOptional("num_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun retryAfter(): Optional = retryAfter.getOptional("retry_after") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategy(): Optional = routingStrategy.getOptional("routing_strategy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategyArgs(): Optional = + routingStrategyArgs.getOptional("routing_strategy_args") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * Returns the raw JSON value of [allowedFails]. + * + * Unlike [allowedFails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_fails") + @ExcludeMissing + fun _allowedFails(): JsonField = allowedFails + + /** + * Returns the raw JSON value of [contextWindowFallbacks]. + * + * Unlike [contextWindowFallbacks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + fun _contextWindowFallbacks(): JsonField> = + contextWindowFallbacks + + /** + * Returns the raw JSON value of [cooldownTime]. + * + * Unlike [cooldownTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cooldown_time") + @ExcludeMissing + fun _cooldownTime(): JsonField = cooldownTime + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fallbacks") + @ExcludeMissing + fun _fallbacks(): JsonField> = fallbacks + + /** + * Returns the raw JSON value of [maxRetries]. + * + * Unlike [maxRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_retries") @ExcludeMissing fun _maxRetries(): JsonField = maxRetries + + /** + * Returns the raw JSON value of [modelGroupAlias]. + * + * Unlike [modelGroupAlias], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_group_alias") + @ExcludeMissing + fun _modelGroupAlias(): JsonField = modelGroupAlias + + /** + * Returns the raw JSON value of [modelGroupRetryPolicy]. + * + * Unlike [modelGroupRetryPolicy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + fun _modelGroupRetryPolicy(): JsonField = modelGroupRetryPolicy + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_retries") @ExcludeMissing fun _numRetries(): JsonField = numRetries + + /** + * Returns the raw JSON value of [retryAfter]. + * + * Unlike [retryAfter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retry_after") + @ExcludeMissing + fun _retryAfter(): JsonField = retryAfter + + /** + * Returns the raw JSON value of [routingStrategy]. + * + * Unlike [routingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_strategy") + @ExcludeMissing + fun _routingStrategy(): JsonField = routingStrategy + + /** + * Returns the raw JSON value of [routingStrategyArgs]. + * + * Unlike [routingStrategyArgs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routing_strategy_args") + @ExcludeMissing + fun _routingStrategyArgs(): JsonField = routingStrategyArgs + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RouterSettings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var allowedFails: JsonField = JsonMissing.of() + private var contextWindowFallbacks: JsonField>? = + null + private var cooldownTime: JsonField = JsonMissing.of() + private var fallbacks: JsonField>? = null + private var maxRetries: JsonField = JsonMissing.of() + private var modelGroupAlias: JsonField = JsonMissing.of() + private var modelGroupRetryPolicy: JsonField = JsonMissing.of() + private var numRetries: JsonField = JsonMissing.of() + private var retryAfter: JsonField = JsonMissing.of() + private var routingStrategy: JsonField = JsonMissing.of() + private var routingStrategyArgs: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + allowedFails = routerSettings.allowedFails + contextWindowFallbacks = + routerSettings.contextWindowFallbacks.map { it.toMutableList() } + cooldownTime = routerSettings.cooldownTime + fallbacks = routerSettings.fallbacks.map { it.toMutableList() } + maxRetries = routerSettings.maxRetries + modelGroupAlias = routerSettings.modelGroupAlias + modelGroupRetryPolicy = routerSettings.modelGroupRetryPolicy + numRetries = routerSettings.numRetries + retryAfter = routerSettings.retryAfter + routingStrategy = routerSettings.routingStrategy + routingStrategyArgs = routerSettings.routingStrategyArgs + timeout = routerSettings.timeout + additionalProperties = routerSettings.additionalProperties.toMutableMap() + } + + fun allowedFails(allowedFails: Long?) = allowedFails(JsonField.ofNullable(allowedFails)) + + /** + * Alias for [Builder.allowedFails]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allowedFails(allowedFails: Long) = allowedFails(allowedFails as Long?) + + /** Alias for calling [Builder.allowedFails] with `allowedFails.orElse(null)`. */ + fun allowedFails(allowedFails: Optional) = allowedFails(allowedFails.getOrNull()) + + /** + * Sets [Builder.allowedFails] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedFails] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedFails(allowedFails: JsonField) = apply { + this.allowedFails = allowedFails + } + + fun contextWindowFallbacks(contextWindowFallbacks: List?) = + contextWindowFallbacks(JsonField.ofNullable(contextWindowFallbacks)) + + /** + * Alias for calling [Builder.contextWindowFallbacks] with + * `contextWindowFallbacks.orElse(null)`. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: Optional> + ) = contextWindowFallbacks(contextWindowFallbacks.getOrNull()) + + /** + * Sets [Builder.contextWindowFallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbacks] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: JsonField> + ) = apply { + this.contextWindowFallbacks = contextWindowFallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [ContextWindowFallback] to [contextWindowFallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContextWindowFallback(contextWindowFallback: ContextWindowFallback) = apply { + contextWindowFallbacks = + (contextWindowFallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("contextWindowFallbacks", it).add(contextWindowFallback) + } + } + + fun cooldownTime(cooldownTime: Double?) = + cooldownTime(JsonField.ofNullable(cooldownTime)) + + /** + * Alias for [Builder.cooldownTime]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cooldownTime(cooldownTime: Double) = cooldownTime(cooldownTime as Double?) + + /** Alias for calling [Builder.cooldownTime] with `cooldownTime.orElse(null)`. */ + fun cooldownTime(cooldownTime: Optional) = + cooldownTime(cooldownTime.getOrNull()) + + /** + * Sets [Builder.cooldownTime] to an arbitrary JSON value. + * + * You should usually call [Builder.cooldownTime] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cooldownTime(cooldownTime: JsonField) = apply { + this.cooldownTime = cooldownTime + } + + fun fallbacks(fallbacks: List?) = fallbacks(JsonField.ofNullable(fallbacks)) + + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) + + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { + this.fallbacks = fallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [Fallback] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: Fallback) = apply { + fallbacks = + (fallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("fallbacks", it).add(fallback) + } + } + + fun maxRetries(maxRetries: Long?) = maxRetries(JsonField.ofNullable(maxRetries)) + + /** + * Alias for [Builder.maxRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxRetries(maxRetries: Long) = maxRetries(maxRetries as Long?) + + /** Alias for calling [Builder.maxRetries] with `maxRetries.orElse(null)`. */ + fun maxRetries(maxRetries: Optional) = maxRetries(maxRetries.getOrNull()) + + /** + * Sets [Builder.maxRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.maxRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxRetries(maxRetries: JsonField) = apply { this.maxRetries = maxRetries } + + fun modelGroupAlias(modelGroupAlias: ModelGroupAlias?) = + modelGroupAlias(JsonField.ofNullable(modelGroupAlias)) + + /** Alias for calling [Builder.modelGroupAlias] with `modelGroupAlias.orElse(null)`. */ + fun modelGroupAlias(modelGroupAlias: Optional) = + modelGroupAlias(modelGroupAlias.getOrNull()) + + /** + * Sets [Builder.modelGroupAlias] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupAlias] with a well-typed [ModelGroupAlias] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelGroupAlias(modelGroupAlias: JsonField) = apply { + this.modelGroupAlias = modelGroupAlias + } + + fun modelGroupRetryPolicy(modelGroupRetryPolicy: ModelGroupRetryPolicy?) = + modelGroupRetryPolicy(JsonField.ofNullable(modelGroupRetryPolicy)) + + /** + * Alias for calling [Builder.modelGroupRetryPolicy] with + * `modelGroupRetryPolicy.orElse(null)`. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: Optional) = + modelGroupRetryPolicy(modelGroupRetryPolicy.getOrNull()) + + /** + * Sets [Builder.modelGroupRetryPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupRetryPolicy] with a well-typed + * [ModelGroupRetryPolicy] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: JsonField) = + apply { + this.modelGroupRetryPolicy = modelGroupRetryPolicy + } + + fun numRetries(numRetries: Long?) = numRetries(JsonField.ofNullable(numRetries)) + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numRetries(numRetries: JsonField) = apply { this.numRetries = numRetries } + + fun retryAfter(retryAfter: Double?) = retryAfter(JsonField.ofNullable(retryAfter)) + + /** + * Alias for [Builder.retryAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun retryAfter(retryAfter: Double) = retryAfter(retryAfter as Double?) + + /** Alias for calling [Builder.retryAfter] with `retryAfter.orElse(null)`. */ + fun retryAfter(retryAfter: Optional) = retryAfter(retryAfter.getOrNull()) + + /** + * Sets [Builder.retryAfter] to an arbitrary JSON value. + * + * You should usually call [Builder.retryAfter] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retryAfter(retryAfter: JsonField) = apply { this.retryAfter = retryAfter } + + fun routingStrategy(routingStrategy: String?) = + routingStrategy(JsonField.ofNullable(routingStrategy)) + + /** Alias for calling [Builder.routingStrategy] with `routingStrategy.orElse(null)`. */ + fun routingStrategy(routingStrategy: Optional) = + routingStrategy(routingStrategy.getOrNull()) + + /** + * Sets [Builder.routingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routingStrategy(routingStrategy: JsonField) = apply { + this.routingStrategy = routingStrategy + } + + fun routingStrategyArgs(routingStrategyArgs: RoutingStrategyArgs?) = + routingStrategyArgs(JsonField.ofNullable(routingStrategyArgs)) + + /** + * Alias for calling [Builder.routingStrategyArgs] with + * `routingStrategyArgs.orElse(null)`. + */ + fun routingStrategyArgs(routingStrategyArgs: Optional) = + routingStrategyArgs(routingStrategyArgs.getOrNull()) + + /** + * Sets [Builder.routingStrategyArgs] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategyArgs] with a well-typed + * [RoutingStrategyArgs] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun routingStrategyArgs(routingStrategyArgs: JsonField) = apply { + this.routingStrategyArgs = routingStrategyArgs + } + + fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) + + /** + * Alias for [Builder.timeout]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun timeout(timeout: Double) = timeout(timeout as Double?) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = + RouterSettings( + allowedFails, + (contextWindowFallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + cooldownTime, + (fallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouterSettings = apply { + if (validated) { + return@apply + } + + allowedFails() + contextWindowFallbacks().ifPresent { it.forEach { it.validate() } } + cooldownTime() + fallbacks().ifPresent { it.forEach { it.validate() } } + maxRetries() + modelGroupAlias().ifPresent { it.validate() } + modelGroupRetryPolicy().ifPresent { it.validate() } + numRetries() + retryAfter() + routingStrategy() + routingStrategyArgs().ifPresent { it.validate() } + timeout() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowedFails.asKnown().isPresent) 1 else 0) + + (contextWindowFallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (cooldownTime.asKnown().isPresent) 1 else 0) + + (fallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maxRetries.asKnown().isPresent) 1 else 0) + + (modelGroupAlias.asKnown().getOrNull()?.validity() ?: 0) + + (modelGroupRetryPolicy.asKnown().getOrNull()?.validity() ?: 0) + + (if (numRetries.asKnown().isPresent) 1 else 0) + + (if (retryAfter.asKnown().isPresent) 1 else 0) + + (if (routingStrategy.asKnown().isPresent) 1 else 0) + + (routingStrategyArgs.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeout.asKnown().isPresent) 1 else 0) + + class ContextWindowFallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContextWindowFallback]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContextWindowFallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contextWindowFallback: ContextWindowFallback) = apply { + additionalProperties = contextWindowFallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContextWindowFallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContextWindowFallback = + ContextWindowFallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ContextWindowFallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContextWindowFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContextWindowFallback{additionalProperties=$additionalProperties}" + } + + class Fallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Fallback]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + additionalProperties = fallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Fallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Fallback = Fallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Fallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Fallback && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Fallback{additionalProperties=$additionalProperties}" + } + + class ModelGroupAlias + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelGroupAlias]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupAlias]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupAlias: ModelGroupAlias) = apply { + additionalProperties = modelGroupAlias.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupAlias]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupAlias = ModelGroupAlias(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupAlias = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupAlias && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelGroupAlias{additionalProperties=$additionalProperties}" + } + + class ModelGroupRetryPolicy + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelGroupRetryPolicy]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupRetryPolicy]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupRetryPolicy: ModelGroupRetryPolicy) = apply { + additionalProperties = modelGroupRetryPolicy.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupRetryPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupRetryPolicy = + ModelGroupRetryPolicy(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupRetryPolicy = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupRetryPolicy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelGroupRetryPolicy{additionalProperties=$additionalProperties}" + } + + class RoutingStrategyArgs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoutingStrategyArgs]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutingStrategyArgs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routingStrategyArgs: RoutingStrategyArgs) = apply { + additionalProperties = routingStrategyArgs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutingStrategyArgs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoutingStrategyArgs = + RoutingStrategyArgs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RoutingStrategyArgs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingStrategyArgs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutingStrategyArgs{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouterSettings && + allowedFails == other.allowedFails && + contextWindowFallbacks == other.contextWindowFallbacks && + cooldownTime == other.cooldownTime && + fallbacks == other.fallbacks && + maxRetries == other.maxRetries && + modelGroupAlias == other.modelGroupAlias && + modelGroupRetryPolicy == other.modelGroupRetryPolicy && + numRetries == other.numRetries && + retryAfter == other.retryAfter && + routingStrategy == other.routingStrategy && + routingStrategyArgs == other.routingStrategyArgs && + timeout == other.timeout && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouterSettings{allowedFails=$allowedFails, contextWindowFallbacks=$contextWindowFallbacks, cooldownTime=$cooldownTime, fallbacks=$fallbacks, maxRetries=$maxRetries, modelGroupAlias=$modelGroupAlias, modelGroupRetryPolicy=$modelGroupRetryPolicy, numRetries=$numRetries, retryAfter=$retryAfter, routingStrategy=$routingStrategy, routingStrategyArgs=$routingStrategyArgs, timeout=$timeout, additionalProperties=$additionalProperties}" + } + + class RpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = RpmLimitType(JsonField.of(value)) + } + + /** An enum containing [RpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [RpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [RpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown RpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = TpmLimitType(JsonField.of(value)) + } + + /** An enum containing [TpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [TpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [TpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown TpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GenerateKeyResponse && + key == other.key && + token == other.token && + aliases == other.aliases && + allowedCacheControls == other.allowedCacheControls && + allowedPassthroughRoutes == other.allowedPassthroughRoutes && + allowedRoutes == other.allowedRoutes && + allowedVectorStoreIndexes == other.allowedVectorStoreIndexes && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + budgetId == other.budgetId && + config == other.config && + createdAt == other.createdAt && + createdBy == other.createdBy && + duration == other.duration && + enforcedParams == other.enforcedParams && + expires == other.expires && + guardrails == other.guardrails && + keyAlias == other.keyAlias && + keyName == other.keyName && + litellmBudgetTable == other.litellmBudgetTable && + maxBudget == other.maxBudget && + maxParallelRequests == other.maxParallelRequests && + metadata == other.metadata && + modelMaxBudget == other.modelMaxBudget && + modelRpmLimit == other.modelRpmLimit && + modelTpmLimit == other.modelTpmLimit && + models == other.models && + objectPermission == other.objectPermission && + organizationId == other.organizationId && + permissions == other.permissions && + prompts == other.prompts && + routerSettings == other.routerSettings && + rpmLimit == other.rpmLimit && + rpmLimitType == other.rpmLimitType && + spend == other.spend && + tags == other.tags && + teamId == other.teamId && + tokenId == other.tokenId && + tpmLimit == other.tpmLimit && + tpmLimitType == other.tpmLimitType && + updatedAt == other.updatedAt && + updatedBy == other.updatedBy && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + key, + token, + aliases, + allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + blocked, + budgetDuration, + budgetId, + config, + createdAt, + createdBy, + duration, + enforcedParams, + expires, guardrails, keyAlias, keyName, - llmBudgetTable, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, @@ -1274,13 +5142,20 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + objectPermission, + organizationId, permissions, + prompts, + routerSettings, rpmLimit, + rpmLimitType, spend, tags, teamId, tokenId, tpmLimit, + tpmLimitType, + updatedAt, updatedBy, userId, additionalProperties, @@ -1290,5 +5165,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GenerateKeyResponse{expires=$expires, key=$key, token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, createdBy=$createdBy, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, keyAlias=$keyAlias, keyName=$keyName, llmBudgetTable=$llmBudgetTable, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, permissions=$permissions, rpmLimit=$rpmLimit, spend=$spend, tags=$tags, teamId=$teamId, tokenId=$tokenId, tpmLimit=$tpmLimit, updatedBy=$updatedBy, userId=$userId, additionalProperties=$additionalProperties}" + "GenerateKeyResponse{key=$key, token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedPassthroughRoutes=$allowedPassthroughRoutes, allowedRoutes=$allowedRoutes, allowedVectorStoreIndexes=$allowedVectorStoreIndexes, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, createdAt=$createdAt, createdBy=$createdBy, duration=$duration, enforcedParams=$enforcedParams, expires=$expires, guardrails=$guardrails, keyAlias=$keyAlias, keyName=$keyName, litellmBudgetTable=$litellmBudgetTable, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, objectPermission=$objectPermission, organizationId=$organizationId, permissions=$permissions, prompts=$prompts, routerSettings=$routerSettings, rpmLimit=$rpmLimit, rpmLimitType=$rpmLimitType, spend=$spend, tags=$tags, teamId=$teamId, tokenId=$tokenId, tpmLimit=$tpmLimit, tpmLimitType=$tpmLimitType, updatedAt=$updatedAt, updatedBy=$updatedBy, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt index c7ce29e7..7de583c7 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockParams.kt @@ -28,17 +28,17 @@ import kotlin.jvm.optionals.getOrNull */ class KeyBlockParams private constructor( - private val llmChangedBy: String?, + private val litellmChangedBy: String?, private val blockKeyRequest: BlockKeyRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The llm-changed-by header enables tracking of actions performed by authorized users on behalf - * of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users on + * behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(): Optional = Optional.ofNullable(llmChangedBy) + fun litellmChangedBy(): Optional = Optional.ofNullable(litellmChangedBy) fun blockKeyRequest(): BlockKeyRequest = blockKeyRequest @@ -69,27 +69,30 @@ private constructor( /** A builder for [KeyBlockParams]. */ class Builder internal constructor() { - private var llmChangedBy: String? = null + private var litellmChangedBy: String? = null private var blockKeyRequest: BlockKeyRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(keyBlockParams: KeyBlockParams) = apply { - llmChangedBy = keyBlockParams.llmChangedBy + litellmChangedBy = keyBlockParams.litellmChangedBy blockKeyRequest = keyBlockParams.blockKeyRequest additionalHeaders = keyBlockParams.additionalHeaders.toBuilder() additionalQueryParams = keyBlockParams.additionalQueryParams.toBuilder() } /** - * The llm-changed-by header enables tracking of actions performed by authorized users on - * behalf of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users + * on behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(llmChangedBy: String?) = apply { this.llmChangedBy = llmChangedBy } + fun litellmChangedBy(litellmChangedBy: String?) = apply { + this.litellmChangedBy = litellmChangedBy + } - /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ - fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** Alias for calling [Builder.litellmChangedBy] with `litellmChangedBy.orElse(null)`. */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) fun blockKeyRequest(blockKeyRequest: BlockKeyRequest) = apply { this.blockKeyRequest = blockKeyRequest @@ -207,7 +210,7 @@ private constructor( */ fun build(): KeyBlockParams = KeyBlockParams( - llmChangedBy, + litellmChangedBy, checkRequired("blockKeyRequest", blockKeyRequest), additionalHeaders.build(), additionalQueryParams.build(), @@ -219,7 +222,7 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - llmChangedBy?.let { put("llm-changed-by", it) } + litellmChangedBy?.let { put("litellm-changed-by", it) } putAll(additionalHeaders) } .build() @@ -232,15 +235,15 @@ private constructor( } return other is KeyBlockParams && - llmChangedBy == other.llmChangedBy && + litellmChangedBy == other.litellmChangedBy && blockKeyRequest == other.blockKeyRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(llmChangedBy, blockKeyRequest, additionalHeaders, additionalQueryParams) + Objects.hash(litellmChangedBy, blockKeyRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "KeyBlockParams{llmChangedBy=$llmChangedBy, blockKeyRequest=$blockKeyRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyBlockParams{litellmChangedBy=$litellmChangedBy, blockKeyRequest=$blockKeyRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt index b829c05d..90a72357 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyBlockResponse.kt @@ -10,6 +10,7 @@ import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException @@ -34,26 +35,35 @@ class KeyBlockResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, - private val aliases: JsonValue, + private val aliases: JsonField, private val allowedCacheControls: JsonField>, + private val allowedRoutes: JsonField>, + private val autoRotate: JsonField, private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetResetAt: JsonField, - private val config: JsonValue, + private val config: JsonField, private val createdAt: JsonField, private val createdBy: JsonField, private val expires: JsonField, private val keyAlias: JsonField, private val keyName: JsonField, - private val llmBudgetTable: JsonValue, + private val keyRotationAt: JsonField, + private val lastRotationAt: JsonField, + private val litellmBudgetTable: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, - private val metadata: JsonValue, - private val modelMaxBudget: JsonValue, - private val modelSpend: JsonValue, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelSpend: JsonField, private val models: JsonField>, + private val objectPermission: JsonField, + private val objectPermissionId: JsonField, private val orgId: JsonField, - private val permissions: JsonValue, + private val permissions: JsonField, + private val rotationCount: JsonField, + private val rotationInterval: JsonField, + private val routerSettings: JsonField, private val rpmLimit: JsonField, private val softBudgetCooldown: JsonField, private val spend: JsonField, @@ -68,10 +78,16 @@ private constructor( @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("aliases") @ExcludeMissing aliases: JsonValue = JsonMissing.of(), + @JsonProperty("aliases") @ExcludeMissing aliases: JsonField = JsonMissing.of(), @JsonProperty("allowed_cache_controls") @ExcludeMissing allowedCacheControls: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), @JsonProperty("budget_duration") @ExcludeMissing @@ -79,7 +95,7 @@ private constructor( @JsonProperty("budget_reset_at") @ExcludeMissing budgetResetAt: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -87,23 +103,48 @@ private constructor( @JsonProperty("expires") @ExcludeMissing expires: JsonField = JsonMissing.of(), @JsonProperty("key_alias") @ExcludeMissing keyAlias: JsonField = JsonMissing.of(), @JsonProperty("key_name") @ExcludeMissing keyName: JsonField = JsonMissing.of(), - @JsonProperty("llm_budget_table") + @JsonProperty("key_rotation_at") + @ExcludeMissing + keyRotationAt: JsonField = JsonMissing.of(), + @JsonProperty("last_rotation_at") + @ExcludeMissing + lastRotationAt: JsonField = JsonMissing.of(), + @JsonProperty("litellm_budget_table") @ExcludeMissing - llmBudgetTable: JsonValue = JsonMissing.of(), + litellmBudgetTable: JsonField = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @JsonProperty("max_parallel_requests") @ExcludeMissing maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("model_max_budget") @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), - @JsonProperty("model_spend") @ExcludeMissing modelSpend: JsonValue = JsonMissing.of(), + modelMaxBudget: JsonField = JsonMissing.of(), + @JsonProperty("model_spend") + @ExcludeMissing + modelSpend: JsonField = JsonMissing.of(), @JsonProperty("models") @ExcludeMissing models: JsonField> = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("object_permission_id") + @ExcludeMissing + objectPermissionId: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing orgId: JsonField = JsonMissing.of(), - @JsonProperty("permissions") @ExcludeMissing permissions: JsonValue = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField = JsonMissing.of(), + @JsonProperty("rotation_count") + @ExcludeMissing + rotationCount: JsonField = JsonMissing.of(), + @JsonProperty("rotation_interval") + @ExcludeMissing + rotationInterval: JsonField = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), @JsonProperty("soft_budget_cooldown") @ExcludeMissing @@ -120,6 +161,8 @@ private constructor( token, aliases, allowedCacheControls, + allowedRoutes, + autoRotate, blocked, budgetDuration, budgetResetAt, @@ -129,15 +172,22 @@ private constructor( expires, keyAlias, keyName, - llmBudgetTable, + keyRotationAt, + lastRotationAt, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelSpend, models, + objectPermission, + objectPermissionId, orgId, permissions, + rotationCount, + rotationInterval, + routerSettings, rpmLimit, softBudgetCooldown, spend, @@ -155,7 +205,11 @@ private constructor( */ fun token(): Optional = token.getOptional("token") - @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -164,6 +218,18 @@ private constructor( fun allowedCacheControls(): Optional> = allowedCacheControls.getOptional("allowed_cache_controls") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = allowedRoutes.getOptional("allowed_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -182,7 +248,11 @@ private constructor( */ fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") - @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -214,9 +284,24 @@ private constructor( */ fun keyName(): Optional = keyName.getOptional("key_name") - @JsonProperty("llm_budget_table") - @ExcludeMissing - fun _llmBudgetTable(): JsonValue = llmBudgetTable + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun keyRotationAt(): Optional = keyRotationAt.getOptional("key_rotation_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastRotationAt(): Optional = lastRotationAt.getOptional("last_rotation_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun litellmBudgetTable(): Optional = + litellmBudgetTable.getOptional("litellm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -231,13 +316,23 @@ private constructor( fun maxParallelRequests(): Optional = maxParallelRequests.getOptional("max_parallel_requests") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = modelMaxBudget.getOptional("model_max_budget") - @JsonProperty("model_spend") @ExcludeMissing fun _modelSpend(): JsonValue = modelSpend + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelSpend(): Optional = modelSpend.getOptional("model_spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -245,13 +340,51 @@ private constructor( */ fun models(): Optional> = models.getOptional("models") + /** + * Represents a LiteLLM_ObjectPermissionTable record + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermissionId(): Optional = + objectPermissionId.getOptional("object_permission_id") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun orgId(): Optional = orgId.getOptional("org_id") - @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationCount(): Optional = rotationCount.getOptional("rotation_count") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationInterval(): Optional = rotationInterval.getOptional("rotation_interval") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = routerSettings.getOptional("router_settings") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -309,6 +442,13 @@ private constructor( */ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -319,6 +459,22 @@ private constructor( @ExcludeMissing fun _allowedCacheControls(): JsonField> = allowedCacheControls + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_rotate") @ExcludeMissing fun _autoRotate(): JsonField = autoRotate + /** * Returns the raw JSON value of [blocked]. * @@ -344,6 +500,13 @@ private constructor( @ExcludeMissing fun _budgetResetAt(): JsonField = budgetResetAt + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + /** * Returns the raw JSON value of [createdAt]. * @@ -381,6 +544,34 @@ private constructor( */ @JsonProperty("key_name") @ExcludeMissing fun _keyName(): JsonField = keyName + /** + * Returns the raw JSON value of [keyRotationAt]. + * + * Unlike [keyRotationAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key_rotation_at") + @ExcludeMissing + fun _keyRotationAt(): JsonField = keyRotationAt + + /** + * Returns the raw JSON value of [lastRotationAt]. + * + * Unlike [lastRotationAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_rotation_at") + @ExcludeMissing + fun _lastRotationAt(): JsonField = lastRotationAt + + /** + * Returns the raw JSON value of [litellmBudgetTable]. + * + * Unlike [litellmBudgetTable], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_budget_table") + @ExcludeMissing + fun _litellmBudgetTable(): JsonField = litellmBudgetTable + /** * Returns the raw JSON value of [maxBudget]. * @@ -398,6 +589,31 @@ private constructor( @ExcludeMissing fun _maxParallelRequests(): JsonField = maxParallelRequests + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget + + /** + * Returns the raw JSON value of [modelSpend]. + * + * Unlike [modelSpend], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_spend") + @ExcludeMissing + fun _modelSpend(): JsonField = modelSpend + /** * Returns the raw JSON value of [models]. * @@ -405,6 +621,26 @@ private constructor( */ @JsonProperty("models") @ExcludeMissing fun _models(): JsonField> = models + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object_permission") + @ExcludeMissing + fun _objectPermission(): JsonField = objectPermission + + /** + * Returns the raw JSON value of [objectPermissionId]. + * + * Unlike [objectPermissionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object_permission_id") + @ExcludeMissing + fun _objectPermissionId(): JsonField = objectPermissionId + /** * Returns the raw JSON value of [orgId]. * @@ -412,6 +648,43 @@ private constructor( */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [rotationCount]. + * + * Unlike [rotationCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rotation_count") + @ExcludeMissing + fun _rotationCount(): JsonField = rotationCount + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rotation_interval") + @ExcludeMissing + fun _rotationInterval(): JsonField = rotationInterval + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + /** * Returns the raw JSON value of [rpmLimit]. * @@ -495,26 +768,35 @@ private constructor( class Builder internal constructor() { private var token: JsonField = JsonMissing.of() - private var aliases: JsonValue = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() private var allowedCacheControls: JsonField>? = null + private var allowedRoutes: JsonField>? = null + private var autoRotate: JsonField = JsonMissing.of() private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetResetAt: JsonField = JsonMissing.of() - private var config: JsonValue = JsonMissing.of() + private var config: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var createdBy: JsonField = JsonMissing.of() private var expires: JsonField = JsonMissing.of() private var keyAlias: JsonField = JsonMissing.of() private var keyName: JsonField = JsonMissing.of() - private var llmBudgetTable: JsonValue = JsonMissing.of() + private var keyRotationAt: JsonField = JsonMissing.of() + private var lastRotationAt: JsonField = JsonMissing.of() + private var litellmBudgetTable: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var modelSpend: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelSpend: JsonField = JsonMissing.of() private var models: JsonField>? = null + private var objectPermission: JsonField = JsonMissing.of() + private var objectPermissionId: JsonField = JsonMissing.of() private var orgId: JsonField = JsonMissing.of() - private var permissions: JsonValue = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var rotationCount: JsonField = JsonMissing.of() + private var rotationInterval: JsonField = JsonMissing.of() + private var routerSettings: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() private var softBudgetCooldown: JsonField = JsonMissing.of() private var spend: JsonField = JsonMissing.of() @@ -530,6 +812,8 @@ private constructor( token = keyBlockResponse.token aliases = keyBlockResponse.aliases allowedCacheControls = keyBlockResponse.allowedCacheControls.map { it.toMutableList() } + allowedRoutes = keyBlockResponse.allowedRoutes.map { it.toMutableList() } + autoRotate = keyBlockResponse.autoRotate blocked = keyBlockResponse.blocked budgetDuration = keyBlockResponse.budgetDuration budgetResetAt = keyBlockResponse.budgetResetAt @@ -539,15 +823,22 @@ private constructor( expires = keyBlockResponse.expires keyAlias = keyBlockResponse.keyAlias keyName = keyBlockResponse.keyName - llmBudgetTable = keyBlockResponse.llmBudgetTable + keyRotationAt = keyBlockResponse.keyRotationAt + lastRotationAt = keyBlockResponse.lastRotationAt + litellmBudgetTable = keyBlockResponse.litellmBudgetTable maxBudget = keyBlockResponse.maxBudget maxParallelRequests = keyBlockResponse.maxParallelRequests metadata = keyBlockResponse.metadata modelMaxBudget = keyBlockResponse.modelMaxBudget modelSpend = keyBlockResponse.modelSpend models = keyBlockResponse.models.map { it.toMutableList() } + objectPermission = keyBlockResponse.objectPermission + objectPermissionId = keyBlockResponse.objectPermissionId orgId = keyBlockResponse.orgId permissions = keyBlockResponse.permissions + rotationCount = keyBlockResponse.rotationCount + rotationInterval = keyBlockResponse.rotationInterval + routerSettings = keyBlockResponse.routerSettings rpmLimit = keyBlockResponse.rpmLimit softBudgetCooldown = keyBlockResponse.softBudgetCooldown spend = keyBlockResponse.spend @@ -572,7 +863,15 @@ private constructor( */ fun token(token: JsonField) = apply { this.token = token } - fun aliases(aliases: JsonValue) = apply { this.aliases = aliases } + fun aliases(aliases: Aliases) = aliases(JsonField.of(aliases)) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } fun allowedCacheControls(allowedCacheControls: List?) = allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) @@ -607,6 +906,57 @@ private constructor( } } + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } + + fun autoRotate(autoRotate: Boolean?) = autoRotate(JsonField.ofNullable(autoRotate)) + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoRotate(autoRotate: JsonField) = apply { this.autoRotate = autoRotate } + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) /** @@ -663,7 +1013,15 @@ private constructor( this.budgetResetAt = budgetResetAt } - fun config(config: JsonValue) = apply { this.config = config } + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) @@ -739,8 +1097,60 @@ private constructor( */ fun keyName(keyName: JsonField) = apply { this.keyName = keyName } - fun llmBudgetTable(llmBudgetTable: JsonValue) = apply { - this.llmBudgetTable = llmBudgetTable + fun keyRotationAt(keyRotationAt: OffsetDateTime?) = + keyRotationAt(JsonField.ofNullable(keyRotationAt)) + + /** Alias for calling [Builder.keyRotationAt] with `keyRotationAt.orElse(null)`. */ + fun keyRotationAt(keyRotationAt: Optional) = + keyRotationAt(keyRotationAt.getOrNull()) + + /** + * Sets [Builder.keyRotationAt] to an arbitrary JSON value. + * + * You should usually call [Builder.keyRotationAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun keyRotationAt(keyRotationAt: JsonField) = apply { + this.keyRotationAt = keyRotationAt + } + + fun lastRotationAt(lastRotationAt: OffsetDateTime?) = + lastRotationAt(JsonField.ofNullable(lastRotationAt)) + + /** Alias for calling [Builder.lastRotationAt] with `lastRotationAt.orElse(null)`. */ + fun lastRotationAt(lastRotationAt: Optional) = + lastRotationAt(lastRotationAt.getOrNull()) + + /** + * Sets [Builder.lastRotationAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRotationAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastRotationAt(lastRotationAt: JsonField) = apply { + this.lastRotationAt = lastRotationAt + } + + fun litellmBudgetTable(litellmBudgetTable: LitellmBudgetTable?) = + litellmBudgetTable(JsonField.ofNullable(litellmBudgetTable)) + + /** + * Alias for calling [Builder.litellmBudgetTable] with `litellmBudgetTable.orElse(null)`. + */ + fun litellmBudgetTable(litellmBudgetTable: Optional) = + litellmBudgetTable(litellmBudgetTable.getOrNull()) + + /** + * Sets [Builder.litellmBudgetTable] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmBudgetTable] with a well-typed + * [LitellmBudgetTable] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun litellmBudgetTable(litellmBudgetTable: JsonField) = apply { + this.litellmBudgetTable = litellmBudgetTable } fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) @@ -792,13 +1202,41 @@ private constructor( this.maxParallelRequests = maxParallelRequests } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget) = + modelMaxBudget(JsonField.of(modelMaxBudget)) - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { this.modelMaxBudget = modelMaxBudget } - fun modelSpend(modelSpend: JsonValue) = apply { this.modelSpend = modelSpend } + fun modelSpend(modelSpend: ModelSpend) = modelSpend(JsonField.of(modelSpend)) + + /** + * Sets [Builder.modelSpend] to an arbitrary JSON value. + * + * You should usually call [Builder.modelSpend] with a well-typed [ModelSpend] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelSpend(modelSpend: JsonField) = apply { this.modelSpend = modelSpend } fun models(models: List) = models(JsonField.of(models)) @@ -825,20 +1263,129 @@ private constructor( } } - fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) + /** Represents a LiteLLM_ObjectPermissionTable record */ + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) - /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ - fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) + /** Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) /** - * Sets [Builder.orgId] to an arbitrary JSON value. + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed [ObjectPermission] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } + + fun objectPermissionId(objectPermissionId: String?) = + objectPermissionId(JsonField.ofNullable(objectPermissionId)) + + /** + * Alias for calling [Builder.objectPermissionId] with `objectPermissionId.orElse(null)`. + */ + fun objectPermissionId(objectPermissionId: Optional) = + objectPermissionId(objectPermissionId.getOrNull()) + + /** + * Sets [Builder.objectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermissionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun objectPermissionId(objectPermissionId: JsonField) = apply { + this.objectPermissionId = objectPermissionId + } + + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) + + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) + + /** + * Sets [Builder.orgId] to an arbitrary JSON value. * * You should usually call [Builder.orgId] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - fun permissions(permissions: JsonValue) = apply { this.permissions = permissions } + fun permissions(permissions: Permissions) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } + + fun rotationCount(rotationCount: Long?) = rotationCount(JsonField.ofNullable(rotationCount)) + + /** + * Alias for [Builder.rotationCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rotationCount(rotationCount: Long) = rotationCount(rotationCount as Long?) + + /** Alias for calling [Builder.rotationCount] with `rotationCount.orElse(null)`. */ + fun rotationCount(rotationCount: Optional) = rotationCount(rotationCount.getOrNull()) + + /** + * Sets [Builder.rotationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rotationCount(rotationCount: JsonField) = apply { + this.rotationCount = rotationCount + } + + fun rotationInterval(rotationInterval: String?) = + rotationInterval(JsonField.ofNullable(rotationInterval)) + + /** Alias for calling [Builder.rotationInterval] with `rotationInterval.orElse(null)`. */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + this.rotationInterval = rotationInterval + } + + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) @@ -987,6 +1534,8 @@ private constructor( token, aliases, (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + autoRotate, blocked, budgetDuration, budgetResetAt, @@ -996,15 +1545,22 @@ private constructor( expires, keyAlias, keyName, - llmBudgetTable, + keyRotationAt, + lastRotationAt, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelSpend, (models ?: JsonMissing.of()).map { it.toImmutable() }, + objectPermission, + objectPermissionId, orgId, permissions, + rotationCount, + rotationInterval, + routerSettings, rpmLimit, softBudgetCooldown, spend, @@ -1025,19 +1581,35 @@ private constructor( } token() + aliases().ifPresent { it.validate() } allowedCacheControls() + allowedRoutes() + autoRotate() blocked() budgetDuration() budgetResetAt() + config().ifPresent { it.validate() } createdAt() createdBy() expires().ifPresent { it.validate() } keyAlias() keyName() + keyRotationAt() + lastRotationAt() + litellmBudgetTable().ifPresent { it.validate() } maxBudget() maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelSpend().ifPresent { it.validate() } models() + objectPermission().ifPresent { it.validate() } + objectPermissionId() orgId() + permissions().ifPresent { it.validate() } + rotationCount() + rotationInterval() + routerSettings().ifPresent { it.validate() } rpmLimit() softBudgetCooldown() spend() @@ -1065,19 +1637,35 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (createdBy.asKnown().isPresent) 1 else 0) + (expires.asKnown().getOrNull()?.validity() ?: 0) + (if (keyAlias.asKnown().isPresent) 1 else 0) + (if (keyName.asKnown().isPresent) 1 else 0) + + (if (keyRotationAt.asKnown().isPresent) 1 else 0) + + (if (lastRotationAt.asKnown().isPresent) 1 else 0) + + (litellmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelSpend.asKnown().getOrNull()?.validity() ?: 0) + (models.asKnown().getOrNull()?.size ?: 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (if (objectPermissionId.asKnown().isPresent) 1 else 0) + (if (orgId.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (if (rotationCount.asKnown().isPresent) 1 else 0) + + (if (rotationInterval.asKnown().isPresent) 1 else 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + (if (softBudgetCooldown.asKnown().isPresent) 1 else 0) + (if (spend.asKnown().isPresent) 1 else 0) + @@ -1087,6 +1675,204 @@ private constructor( (if (updatedBy.asKnown().isPresent) 1 else 0) + (if (userId.asKnown().isPresent) 1 else 0) + class Aliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Aliases]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Expires.Deserializer::class) @JsonSerialize(using = Expires.Serializer::class) class Expires @@ -1220,19 +2006,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Expires(string = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Expires(offsetDateTime = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Expires(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1260,6 +2046,1218 @@ private constructor( } } + class LitellmBudgetTable + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LitellmBudgetTable]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LitellmBudgetTable]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(litellmBudgetTable: LitellmBudgetTable) = apply { + additionalProperties = litellmBudgetTable.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LitellmBudgetTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LitellmBudgetTable = LitellmBudgetTable(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LitellmBudgetTable = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LitellmBudgetTable && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LitellmBudgetTable{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelMaxBudget]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelSpend + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelSpend]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelSpend]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelSpend: ModelSpend) = apply { + additionalProperties = modelSpend.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelSpend]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelSpend = ModelSpend(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelSpend = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelSpend && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelSpend{additionalProperties=$additionalProperties}" + } + + /** Represents a LiteLLM_ObjectPermissionTable record */ + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val objectPermissionId: JsonField, + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("object_permission_id") + @ExcludeMissing + objectPermissionId: JsonField = JsonMissing.of(), + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + objectPermissionId, + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun objectPermissionId(): String = objectPermissionId.getRequired("object_permission_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vectorStores(): Optional> = vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [objectPermissionId]. + * + * Unlike [objectPermissionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("object_permission_id") + @ExcludeMissing + fun _objectPermissionId(): JsonField = objectPermissionId + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agents") @ExcludeMissing fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ObjectPermission]. + * + * The following fields are required: + * ```java + * .objectPermissionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var objectPermissionId: JsonField? = null + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + objectPermissionId = objectPermission.objectPermissionId + agentAccessGroups = objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun objectPermissionId(objectPermissionId: String) = + objectPermissionId(JsonField.of(objectPermissionId)) + + /** + * Sets [Builder.objectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermissionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun objectPermissionId(objectPermissionId: JsonField) = apply { + this.objectPermissionId = objectPermissionId + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** Alias for calling [Builder.mcpAccessGroups] with `mcpAccessGroups.orElse(null)`. */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectPermissionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ObjectPermission = + ObjectPermission( + checkRequired("objectPermissionId", objectPermissionId), + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + objectPermissionId() + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (objectPermissionId.asKnown().isPresent) 1 else 0) + + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + objectPermissionId == other.objectPermissionId && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + objectPermissionId, + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{objectPermissionId=$objectPermissionId, agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + class RouterSettings + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RouterSettings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + additionalProperties = routerSettings.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = RouterSettings(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RouterSettings = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouterSettings && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RouterSettings{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1269,6 +3267,8 @@ private constructor( token == other.token && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && + allowedRoutes == other.allowedRoutes && + autoRotate == other.autoRotate && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetResetAt == other.budgetResetAt && @@ -1278,15 +3278,22 @@ private constructor( expires == other.expires && keyAlias == other.keyAlias && keyName == other.keyName && - llmBudgetTable == other.llmBudgetTable && + keyRotationAt == other.keyRotationAt && + lastRotationAt == other.lastRotationAt && + litellmBudgetTable == other.litellmBudgetTable && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && modelMaxBudget == other.modelMaxBudget && modelSpend == other.modelSpend && models == other.models && + objectPermission == other.objectPermission && + objectPermissionId == other.objectPermissionId && orgId == other.orgId && permissions == other.permissions && + rotationCount == other.rotationCount && + rotationInterval == other.rotationInterval && + routerSettings == other.routerSettings && rpmLimit == other.rpmLimit && softBudgetCooldown == other.softBudgetCooldown && spend == other.spend && @@ -1303,6 +3310,8 @@ private constructor( token, aliases, allowedCacheControls, + allowedRoutes, + autoRotate, blocked, budgetDuration, budgetResetAt, @@ -1312,15 +3321,22 @@ private constructor( expires, keyAlias, keyName, - llmBudgetTable, + keyRotationAt, + lastRotationAt, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelSpend, models, + objectPermission, + objectPermissionId, orgId, permissions, + rotationCount, + rotationInterval, + routerSettings, rpmLimit, softBudgetCooldown, spend, @@ -1336,5 +3352,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "KeyBlockResponse{token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, blocked=$blocked, budgetDuration=$budgetDuration, budgetResetAt=$budgetResetAt, config=$config, createdAt=$createdAt, createdBy=$createdBy, expires=$expires, keyAlias=$keyAlias, keyName=$keyName, llmBudgetTable=$llmBudgetTable, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelSpend=$modelSpend, models=$models, orgId=$orgId, permissions=$permissions, rpmLimit=$rpmLimit, softBudgetCooldown=$softBudgetCooldown, spend=$spend, teamId=$teamId, tpmLimit=$tpmLimit, updatedAt=$updatedAt, updatedBy=$updatedBy, userId=$userId, additionalProperties=$additionalProperties}" + "KeyBlockResponse{token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedRoutes=$allowedRoutes, autoRotate=$autoRotate, blocked=$blocked, budgetDuration=$budgetDuration, budgetResetAt=$budgetResetAt, config=$config, createdAt=$createdAt, createdBy=$createdBy, expires=$expires, keyAlias=$keyAlias, keyName=$keyName, keyRotationAt=$keyRotationAt, lastRotationAt=$lastRotationAt, litellmBudgetTable=$litellmBudgetTable, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelSpend=$modelSpend, models=$models, objectPermission=$objectPermission, objectPermissionId=$objectPermissionId, orgId=$orgId, permissions=$permissions, rotationCount=$rotationCount, rotationInterval=$rotationInterval, routerSettings=$routerSettings, rpmLimit=$rpmLimit, softBudgetCooldown=$softBudgetCooldown, spend=$spend, teamId=$teamId, tpmLimit=$tpmLimit, updatedAt=$updatedAt, updatedBy=$updatedBy, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt index bd1b8eca..71dcc893 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyDeleteParams.kt @@ -45,17 +45,17 @@ import kotlin.jvm.optionals.getOrNull */ class KeyDeleteParams private constructor( - private val llmChangedBy: String?, + private val litellmChangedBy: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The llm-changed-by header enables tracking of actions performed by authorized users on behalf - * of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users on + * behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(): Optional = Optional.ofNullable(llmChangedBy) + fun litellmChangedBy(): Optional = Optional.ofNullable(litellmChangedBy) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -104,27 +104,30 @@ private constructor( /** A builder for [KeyDeleteParams]. */ class Builder internal constructor() { - private var llmChangedBy: String? = null + private var litellmChangedBy: String? = null private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(keyDeleteParams: KeyDeleteParams) = apply { - llmChangedBy = keyDeleteParams.llmChangedBy + litellmChangedBy = keyDeleteParams.litellmChangedBy body = keyDeleteParams.body.toBuilder() additionalHeaders = keyDeleteParams.additionalHeaders.toBuilder() additionalQueryParams = keyDeleteParams.additionalQueryParams.toBuilder() } /** - * The llm-changed-by header enables tracking of actions performed by authorized users on - * behalf of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users + * on behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(llmChangedBy: String?) = apply { this.llmChangedBy = llmChangedBy } + fun litellmChangedBy(litellmChangedBy: String?) = apply { + this.litellmChangedBy = litellmChangedBy + } - /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ - fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** Alias for calling [Builder.litellmChangedBy] with `litellmChangedBy.orElse(null)`. */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) /** * Sets the entire request body. @@ -302,7 +305,7 @@ private constructor( */ fun build(): KeyDeleteParams = KeyDeleteParams( - llmChangedBy, + litellmChangedBy, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -314,7 +317,7 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - llmChangedBy?.let { put("llm-changed-by", it) } + litellmChangedBy?.let { put("litellm-changed-by", it) } putAll(additionalHeaders) } .build() @@ -538,15 +541,15 @@ private constructor( } return other is KeyDeleteParams && - llmChangedBy == other.llmChangedBy && + litellmChangedBy == other.litellmChangedBy && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) + Objects.hash(litellmChangedBy, body, additionalHeaders, additionalQueryParams) override fun toString() = - "KeyDeleteParams{llmChangedBy=$llmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyDeleteParams{litellmChangedBy=$litellmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt index 30666b92..9e453b71 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyGenerateParams.kt @@ -2,12 +2,14 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.Enum import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.Params import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams import ai.hanzo.api.core.toImmutable @@ -24,7 +26,7 @@ import kotlin.jvm.optionals.getOrNull /** * Generate an API key based on the provided data. * - * Docs: https://docs.hanzo.ai/docs/proxy/virtual_keys + * Docs: https://docs.litellm.ai/docs/proxy/virtual_keys * * Parameters: * - duration: Optional[str] - Specify the length of time the token is valid for. You can set @@ -34,15 +36,17 @@ import kotlin.jvm.optionals.getOrNull * for you. * - team_id: Optional[str] - The team id of the key * - user_id: Optional[str] - The user id of the key + * - organization_id: Optional[str] - The organization id of the key. If not set, and team_id is + * set, the organization id will be the same as the team id. If conflict, an error will be raised. * - budget_id: Optional[str] - The budget id associated with the key. Created by calling * `/budget/new`. * - models: Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed to * call all models) * - aliases: Optional[dict] - Any alias mappings, on top of anything in the config.yaml model - * list. - https://docs.hanzo.ai/docs/proxy/virtual_keys#managing-auth---upgradedowngrade-models + * list. - https://docs.litellm.ai/docs/proxy/virtual_keys#managing-auth---upgradedowngrade-models * - config: Optional[dict] - any key-specific configs, overrides config in config.yaml * - spend: Optional[int] - Amount spent by key. Default is 0. Will be updated by proxy whenever key - * is used. https://docs.hanzo.ai/docs/proxy/virtual_keys#managing-auth---tracking-spend + * is used. https://docs.litellm.ai/docs/proxy/virtual_keys#managing-auth---tracking-spend * - send_invite_email: Optional[bool] - Whether to send an invite email to the user_id, with the * generate key * - max_budget: Optional[float] - Specify max budget for a given key. @@ -52,8 +56,9 @@ import kotlin.jvm.optionals.getOrNull * - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel * requests. Raises 429 error, if user's parallel requests > x. * - metadata: Optional[dict] - Metadata for key, store information for key. Example metadata = - * {"team": "core-infra", "app": "app2", "email": "z@hanzo.ai" } + * {"team": "core-infra", "app": "app2", "email": "ishaan@berri.ai" } * - guardrails: Optional[List[str]] - List of active guardrails for the key + * - disable_global_guardrails: Optional[bool] - Whether to disable global guardrails for the key. * - permissions: Optional[dict] - key-specific permissions. Currently just used for turning off pii * masking (if connected). Example - {"pii": false} * - model_max_budget: Optional[Dict[str, BudgetConfig]] - Model-specific budgets {"gpt-4": @@ -62,19 +67,56 @@ import kotlin.jvm.optionals.getOrNull * 1000, "gpt-3.5-turbo": 1000}. IF null or {} then no model specific rpm limit. * - model_tpm_limit: Optional[dict] - key-specific model tpm limit. Example - {"text-davinci-002": * 1000, "gpt-3.5-turbo": 1000}. IF null or {} then no model specific tpm limit. + * - tpm_limit_type: Optional[str] - Type of tpm limit. Options: "best_effort_throughput" (no error + * if we're overallocating tpm), "guaranteed_throughput" (raise an error if we're overallocating + * tpm), "dynamic" (dynamically exceed limit when no 429 errors). Defaults to + * "best_effort_throughput". + * - rpm_limit_type: Optional[str] - Type of rpm limit. Options: "best_effort_throughput" (no error + * if we're overallocating rpm), "guaranteed_throughput" (raise an error if we're overallocating + * rpm), "dynamic" (dynamically exceed limit when no 429 errors). Defaults to + * "best_effort_throughput". * - allowed_cache_controls: Optional[list] - List of allowed cache control values. * Example - ["no-cache", "no-store"]. See all values - - * https://docs.hanzo.ai/docs/proxy/caching#turn-on--off-caching-per-request + * https://docs.litellm.ai/docs/proxy/caching#turn-on--off-caching-per-request * - blocked: Optional[bool] - Whether the key is blocked. * - rpm_limit: Optional[int] - Specify rpm limit for a given key (Requests per minute) * - tpm_limit: Optional[int] - Specify tpm limit for a given key (Tokens per minute) * - soft_budget: Optional[float] - Specify soft budget for a given key. Will trigger a slack alert * when this soft budget is reached. * - tags: Optional[List[str]] - Tags for - * [tracking spend](https://llm.vercel.app/docs/proxy/enterprise#tracking-spend-for-custom-tags) - * and/or doing [tag-based routing](https://llm.vercel.app/docs/proxy/tag_routing). + * [tracking spend](https://litellm.vercel.app/docs/proxy/enterprise#tracking-spend-for-custom-tags) + * and/or doing [tag-based routing](https://litellm.vercel.app/docs/proxy/tag_routing). + * - prompts: Optional[List[str]] - List of prompts that the key is allowed to use. * - enforced_params: Optional[List[str]] - List of enforced params for the key (Enterprise only). - * [Docs](https://docs.hanzo.ai/docs/proxy/enterprise#enforce-required-params-for-llm-requests) + * [Docs](https://docs.litellm.ai/docs/proxy/enterprise#enforce-required-params-for-llm-requests) + * - prompts: Optional[List[str]] - List of prompts that the key is allowed to use. + * - allowed_routes: Optional[list] - List of allowed routes for the key. Store the actual route or + * store a wildcard pattern for a set of routes. + * Example - ["/chat/completions", "/embeddings", "/keys/*"] + * - allowed_passthrough_routes: Optional[list] - List of allowed pass through endpoints for the + * key. Store the actual endpoint or store a wildcard pattern for a set of endpoints. + * Example - ["/my-custom-endpoint"]. Use this instead of allowed_routes, if you just want to + * specify which pass through endpoints the key can access, without specifying the routes. If + * allowed_routes is specified, allowed_pass_through_endpoints is ignored. + * - object_permission: Optional[LiteLLM_ObjectPermissionBase] - key-specific object permission. + * Example - {"vector_stores": ["vector_store_1", "vector_store_2"], "agents": + * ["agent_1", "agent_2"], "agent_access_groups": ["dev_group"]}. IF null or {} then no object + * permission. + * - key_type: Optional[str] - Type of key that determines default allowed routes. Options: + * "llm_api" (can call LLM API routes), "management" (can call management routes), "read_only" + * (can only call info/read routes), "default" (uses default allowed routes). Defaults to + * "default". + * - prompts: Optional[List[str]] - List of allowed prompts for the key. If specified, the key will + * only be able to use these specific prompts. + * - auto_rotate: Optional[bool] - Whether this key should be automatically rotated (regenerated) + * - rotation_interval: Optional[str] - How often to auto-rotate this key (e.g., '30s', '30m', + * '30h', '30d'). Required if auto_rotate=True. + * - allowed_vector_store_indexes: Optional[List[dict]] - List of allowed vector store indexes for + * the key. Example - [{"index_name": "my-index", "index_permissions": ["write", "read"]}]. If + * specified, the key will only be able to use these specific vector store indexes. Create index, + * using `/v1/indexes` endpoint. + * - router_settings: Optional[UpdateRouterConfig] - key-specific router settings. Example - + * {"model_group_retry_policy": {"max_retries": 5}}. IF null or {} then no router settings. * * Examples: * 1. Allow users to turn on/off pii masking @@ -92,19 +134,23 @@ import kotlin.jvm.optionals.getOrNull */ class KeyGenerateParams private constructor( - private val llmChangedBy: String?, + private val litellmChangedBy: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The llm-changed-by header enables tracking of actions performed by authorized users on behalf - * of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users on + * behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(): Optional = Optional.ofNullable(llmChangedBy) + fun litellmChangedBy(): Optional = Optional.ofNullable(litellmChangedBy) - fun _aliases(): JsonValue = body._aliases() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = body.aliases() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -112,6 +158,33 @@ private constructor( */ fun allowedCacheControls(): Optional> = body.allowedCacheControls() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedPassthroughRoutes(): Optional> = body.allowedPassthroughRoutes() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = body.allowedRoutes() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedVectorStoreIndexes(): Optional> = + body.allowedVectorStoreIndexes() + + /** + * Whether this key should be automatically rotated + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoRotate(): Optional = body.autoRotate() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -130,7 +203,11 @@ private constructor( */ fun budgetId(): Optional = body.budgetId() - fun _config(): JsonValue = body._config() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = body.config() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -162,6 +239,14 @@ private constructor( */ fun keyAlias(): Optional = body.keyAlias() + /** + * Enum for key types that determine what routes a key can access + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun keyType(): Optional = body.keyType() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -174,13 +259,29 @@ private constructor( */ fun maxParallelRequests(): Optional = body.maxParallelRequests() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() - fun _modelMaxBudget(): JsonValue = body._modelMaxBudget() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = body.modelMaxBudget() - fun _modelRpmLimit(): JsonValue = body._modelRpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelRpmLimit(): Optional = body.modelRpmLimit() - fun _modelTpmLimit(): JsonValue = body._modelTpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelTpmLimit(): Optional = body.modelTpmLimit() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -188,7 +289,45 @@ private constructor( */ fun models(): Optional> = body.models() - fun _permissions(): JsonValue = body._permissions() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = body.objectPermission() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun organizationId(): Optional = body.organizationId() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = body.permissions() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompts(): Optional> = body.prompts() + + /** + * How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationInterval(): Optional = body.rotationInterval() + + /** + * Set of params that you can modify via `router.update_settings()`. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = body.routerSettings() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -196,6 +335,12 @@ private constructor( */ fun rpmLimit(): Optional = body.rpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpmLimitType(): Optional = body.rpmLimitType() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -232,12 +377,25 @@ private constructor( */ fun tpmLimit(): Optional = body.tpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tpmLimitType(): Optional = body.tpmLimitType() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun userId(): Optional = body.userId() + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _aliases(): JsonField = body._aliases() + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -246,6 +404,37 @@ private constructor( */ fun _allowedCacheControls(): JsonField> = body._allowedCacheControls() + /** + * Returns the raw JSON value of [allowedPassthroughRoutes]. + * + * Unlike [allowedPassthroughRoutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _allowedPassthroughRoutes(): JsonField> = body._allowedPassthroughRoutes() + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _allowedRoutes(): JsonField> = body._allowedRoutes() + + /** + * Returns the raw JSON value of [allowedVectorStoreIndexes]. + * + * Unlike [allowedVectorStoreIndexes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _allowedVectorStoreIndexes(): JsonField> = + body._allowedVectorStoreIndexes() + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoRotate(): JsonField = body._autoRotate() + /** * Returns the raw JSON value of [blocked]. * @@ -267,6 +456,13 @@ private constructor( */ fun _budgetId(): JsonField = body._budgetId() + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + /** * Returns the raw JSON value of [duration]. * @@ -302,6 +498,13 @@ private constructor( */ fun _keyAlias(): JsonField = body._keyAlias() + /** + * Returns the raw JSON value of [keyType]. + * + * Unlike [keyType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _keyType(): JsonField = body._keyType() + /** * Returns the raw JSON value of [maxBudget]. * @@ -317,6 +520,34 @@ private constructor( */ fun _maxParallelRequests(): JsonField = body._maxParallelRequests() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modelMaxBudget(): JsonField = body._modelMaxBudget() + + /** + * Returns the raw JSON value of [modelRpmLimit]. + * + * Unlike [modelRpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modelRpmLimit(): JsonField = body._modelRpmLimit() + + /** + * Returns the raw JSON value of [modelTpmLimit]. + * + * Unlike [modelTpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modelTpmLimit(): JsonField = body._modelTpmLimit() + /** * Returns the raw JSON value of [models]. * @@ -324,6 +555,50 @@ private constructor( */ fun _models(): JsonField> = body._models() + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _objectPermission(): JsonField = body._objectPermission() + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _organizationId(): JsonField = body._organizationId() + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _permissions(): JsonField = body._permissions() + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _prompts(): JsonField> = body._prompts() + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _rotationInterval(): JsonField = body._rotationInterval() + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _routerSettings(): JsonField = body._routerSettings() + /** * Returns the raw JSON value of [rpmLimit]. * @@ -331,6 +606,13 @@ private constructor( */ fun _rpmLimit(): JsonField = body._rpmLimit() + /** + * Returns the raw JSON value of [rpmLimitType]. + * + * Unlike [rpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rpmLimitType(): JsonField = body._rpmLimitType() + /** * Returns the raw JSON value of [sendInviteEmail]. * @@ -373,6 +655,13 @@ private constructor( */ fun _tpmLimit(): JsonField = body._tpmLimit() + /** + * Returns the raw JSON value of [tpmLimitType]. + * + * Unlike [tpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tpmLimitType(): JsonField = body._tpmLimitType() + /** * Returns the raw JSON value of [userId]. * @@ -401,27 +690,30 @@ private constructor( /** A builder for [KeyGenerateParams]. */ class Builder internal constructor() { - private var llmChangedBy: String? = null + private var litellmChangedBy: String? = null private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(keyGenerateParams: KeyGenerateParams) = apply { - llmChangedBy = keyGenerateParams.llmChangedBy + litellmChangedBy = keyGenerateParams.litellmChangedBy body = keyGenerateParams.body.toBuilder() additionalHeaders = keyGenerateParams.additionalHeaders.toBuilder() additionalQueryParams = keyGenerateParams.additionalQueryParams.toBuilder() } /** - * The llm-changed-by header enables tracking of actions performed by authorized users on - * behalf of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users + * on behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(llmChangedBy: String?) = apply { this.llmChangedBy = llmChangedBy } + fun litellmChangedBy(litellmChangedBy: String?) = apply { + this.litellmChangedBy = litellmChangedBy + } - /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ - fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** Alias for calling [Builder.litellmChangedBy] with `litellmChangedBy.orElse(null)`. */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) /** * Sets the entire request body. @@ -430,14 +722,25 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [aliases] * - [allowedCacheControls] - * - [blocked] - * - [budgetDuration] - * - [budgetId] + * - [allowedPassthroughRoutes] + * - [allowedRoutes] + * - [allowedVectorStoreIndexes] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } - fun aliases(aliases: JsonValue) = apply { body.aliases(aliases) } + fun aliases(aliases: Aliases?) = apply { body.aliases(aliases) } + + /** Alias for calling [Builder.aliases] with `aliases.orElse(null)`. */ + fun aliases(aliases: Optional) = aliases(aliases.getOrNull()) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun aliases(aliases: JsonField) = apply { body.aliases(aliases) } fun allowedCacheControls(allowedCacheControls: List?) = apply { body.allowedCacheControls(allowedCacheControls) @@ -470,6 +773,118 @@ private constructor( body.addAllowedCacheControl(allowedCacheControl) } + fun allowedPassthroughRoutes(allowedPassthroughRoutes: List?) = apply { + body.allowedPassthroughRoutes(allowedPassthroughRoutes) + } + + /** + * Alias for calling [Builder.allowedPassthroughRoutes] with + * `allowedPassthroughRoutes.orElse(null)`. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: Optional>) = + allowedPassthroughRoutes(allowedPassthroughRoutes.getOrNull()) + + /** + * Sets [Builder.allowedPassthroughRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedPassthroughRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: JsonField>) = apply { + body.allowedPassthroughRoutes(allowedPassthroughRoutes) + } + + /** + * Adds a single [JsonValue] to [allowedPassthroughRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedPassthroughRoute(allowedPassthroughRoute: JsonValue) = apply { + body.addAllowedPassthroughRoute(allowedPassthroughRoute) + } + + fun allowedRoutes(allowedRoutes: List?) = apply { + body.allowedRoutes(allowedRoutes) + } + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + body.allowedRoutes(allowedRoutes) + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { body.addAllowedRoute(allowedRoute) } + + fun allowedVectorStoreIndexes(allowedVectorStoreIndexes: List?) = + apply { + body.allowedVectorStoreIndexes(allowedVectorStoreIndexes) + } + + /** + * Alias for calling [Builder.allowedVectorStoreIndexes] with + * `allowedVectorStoreIndexes.orElse(null)`. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: Optional> + ) = allowedVectorStoreIndexes(allowedVectorStoreIndexes.getOrNull()) + + /** + * Sets [Builder.allowedVectorStoreIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedVectorStoreIndexes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: JsonField> + ) = apply { body.allowedVectorStoreIndexes(allowedVectorStoreIndexes) } + + /** + * Adds a single [AllowedVectorStoreIndex] to [allowedVectorStoreIndexes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedVectorStoreIndex(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + body.addAllowedVectorStoreIndex(allowedVectorStoreIndex) + } + + /** Whether this key should be automatically rotated */ + fun autoRotate(autoRotate: Boolean?) = apply { body.autoRotate(autoRotate) } + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoRotate(autoRotate: JsonField) = apply { body.autoRotate(autoRotate) } + fun blocked(blocked: Boolean?) = apply { body.blocked(blocked) } /** @@ -520,7 +935,18 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { body.budgetId(budgetId) } - fun config(config: JsonValue) = apply { body.config(config) } + fun config(config: Config?) = apply { body.config(config) } + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } fun duration(duration: String?) = apply { body.duration(duration) } @@ -608,6 +1034,20 @@ private constructor( */ fun keyAlias(keyAlias: JsonField) = apply { body.keyAlias(keyAlias) } + /** Enum for key types that determine what routes a key can access */ + fun keyType(keyType: KeyType?) = apply { body.keyType(keyType) } + + /** Alias for calling [Builder.keyType] with `keyType.orElse(null)`. */ + fun keyType(keyType: Optional) = keyType(keyType.getOrNull()) + + /** + * Sets [Builder.keyType] to an arbitrary JSON value. + * + * You should usually call [Builder.keyType] with a well-typed [KeyType] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun keyType(keyType: JsonField) = apply { body.keyType(keyType) } + fun maxBudget(maxBudget: Double?) = apply { body.maxBudget(maxBudget) } /** @@ -658,15 +1098,76 @@ private constructor( body.maxParallelRequests(maxParallelRequests) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } - - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { - body.modelMaxBudget(modelMaxBudget) - } - - fun modelRpmLimit(modelRpmLimit: JsonValue) = apply { body.modelRpmLimit(modelRpmLimit) } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - fun modelTpmLimit(modelTpmLimit: JsonValue) = apply { body.modelTpmLimit(modelTpmLimit) } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget?) = apply { + body.modelMaxBudget(modelMaxBudget) + } + + /** Alias for calling [Builder.modelMaxBudget] with `modelMaxBudget.orElse(null)`. */ + fun modelMaxBudget(modelMaxBudget: Optional) = + modelMaxBudget(modelMaxBudget.getOrNull()) + + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { + body.modelMaxBudget(modelMaxBudget) + } + + fun modelRpmLimit(modelRpmLimit: ModelRpmLimit?) = apply { + body.modelRpmLimit(modelRpmLimit) + } + + /** Alias for calling [Builder.modelRpmLimit] with `modelRpmLimit.orElse(null)`. */ + fun modelRpmLimit(modelRpmLimit: Optional) = + modelRpmLimit(modelRpmLimit.getOrNull()) + + /** + * Sets [Builder.modelRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelRpmLimit] with a well-typed [ModelRpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelRpmLimit(modelRpmLimit: JsonField) = apply { + body.modelRpmLimit(modelRpmLimit) + } + + fun modelTpmLimit(modelTpmLimit: ModelTpmLimit?) = apply { + body.modelTpmLimit(modelTpmLimit) + } + + /** Alias for calling [Builder.modelTpmLimit] with `modelTpmLimit.orElse(null)`. */ + fun modelTpmLimit(modelTpmLimit: Optional) = + modelTpmLimit(modelTpmLimit.getOrNull()) + + /** + * Sets [Builder.modelTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelTpmLimit] with a well-typed [ModelTpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelTpmLimit(modelTpmLimit: JsonField) = apply { + body.modelTpmLimit(modelTpmLimit) + } fun models(models: List?) = apply { body.models(models) } @@ -689,7 +1190,118 @@ private constructor( */ fun addModel(model: JsonValue) = apply { body.addModel(model) } - fun permissions(permissions: JsonValue) = apply { body.permissions(permissions) } + fun objectPermission(objectPermission: ObjectPermission?) = apply { + body.objectPermission(objectPermission) + } + + /** Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed [ObjectPermission] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + body.objectPermission(objectPermission) + } + + fun organizationId(organizationId: String?) = apply { body.organizationId(organizationId) } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField) = apply { + body.organizationId(organizationId) + } + + fun permissions(permissions: Permissions?) = apply { body.permissions(permissions) } + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional) = permissions(permissions.getOrNull()) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField) = apply { + body.permissions(permissions) + } + + fun prompts(prompts: List?) = apply { body.prompts(prompts) } + + /** Alias for calling [Builder.prompts] with `prompts.orElse(null)`. */ + fun prompts(prompts: Optional>) = prompts(prompts.getOrNull()) + + /** + * Sets [Builder.prompts] to an arbitrary JSON value. + * + * You should usually call [Builder.prompts] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prompts(prompts: JsonField>) = apply { body.prompts(prompts) } + + /** + * Adds a single [String] to [prompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: String) = apply { body.addPrompt(prompt) } + + /** How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True */ + fun rotationInterval(rotationInterval: String?) = apply { + body.rotationInterval(rotationInterval) + } + + /** Alias for calling [Builder.rotationInterval] with `rotationInterval.orElse(null)`. */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + body.rotationInterval(rotationInterval) + } + + /** Set of params that you can modify via `router.update_settings()`. */ + fun routerSettings(routerSettings: RouterSettings?) = apply { + body.routerSettings(routerSettings) + } + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + body.routerSettings(routerSettings) + } fun rpmLimit(rpmLimit: Long?) = apply { body.rpmLimit(rpmLimit) } @@ -711,6 +1323,23 @@ private constructor( */ fun rpmLimit(rpmLimit: JsonField) = apply { body.rpmLimit(rpmLimit) } + fun rpmLimitType(rpmLimitType: RpmLimitType?) = apply { body.rpmLimitType(rpmLimitType) } + + /** Alias for calling [Builder.rpmLimitType] with `rpmLimitType.orElse(null)`. */ + fun rpmLimitType(rpmLimitType: Optional) = + rpmLimitType(rpmLimitType.getOrNull()) + + /** + * Sets [Builder.rpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimitType] with a well-typed [RpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimitType(rpmLimitType: JsonField) = apply { + body.rpmLimitType(rpmLimitType) + } + fun sendInviteEmail(sendInviteEmail: Boolean?) = apply { body.sendInviteEmail(sendInviteEmail) } @@ -832,6 +1461,23 @@ private constructor( */ fun tpmLimit(tpmLimit: JsonField) = apply { body.tpmLimit(tpmLimit) } + fun tpmLimitType(tpmLimitType: TpmLimitType?) = apply { body.tpmLimitType(tpmLimitType) } + + /** Alias for calling [Builder.tpmLimitType] with `tpmLimitType.orElse(null)`. */ + fun tpmLimitType(tpmLimitType: Optional) = + tpmLimitType(tpmLimitType.getOrNull()) + + /** + * Sets [Builder.tpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimitType] with a well-typed [TpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tpmLimitType(tpmLimitType: JsonField) = apply { + body.tpmLimitType(tpmLimitType) + } + fun userId(userId: String?) = apply { body.userId(userId) } /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -969,7 +1615,7 @@ private constructor( */ fun build(): KeyGenerateParams = KeyGenerateParams( - llmChangedBy, + litellmChangedBy, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -981,7 +1627,7 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - llmChangedBy?.let { put("llm-changed-by", it) } + litellmChangedBy?.let { put("litellm-changed-by", it) } putAll(additionalHeaders) } .build() @@ -991,42 +1637,66 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val aliases: JsonValue, + private val aliases: JsonField, private val allowedCacheControls: JsonField>, + private val allowedPassthroughRoutes: JsonField>, + private val allowedRoutes: JsonField>, + private val allowedVectorStoreIndexes: JsonField>, + private val autoRotate: JsonField, private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetId: JsonField, - private val config: JsonValue, + private val config: JsonField, private val duration: JsonField, private val enforcedParams: JsonField>, private val guardrails: JsonField>, private val key: JsonField, private val keyAlias: JsonField, + private val keyType: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, - private val metadata: JsonValue, - private val modelMaxBudget: JsonValue, - private val modelRpmLimit: JsonValue, - private val modelTpmLimit: JsonValue, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelRpmLimit: JsonField, + private val modelTpmLimit: JsonField, private val models: JsonField>, - private val permissions: JsonValue, + private val objectPermission: JsonField, + private val organizationId: JsonField, + private val permissions: JsonField, + private val prompts: JsonField>, + private val rotationInterval: JsonField, + private val routerSettings: JsonField, private val rpmLimit: JsonField, + private val rpmLimitType: JsonField, private val sendInviteEmail: JsonField, private val softBudget: JsonField, private val spend: JsonField, private val tags: JsonField>, private val teamId: JsonField, private val tpmLimit: JsonField, + private val tpmLimitType: JsonField, private val userId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("aliases") @ExcludeMissing aliases: JsonValue = JsonMissing.of(), + @JsonProperty("aliases") @ExcludeMissing aliases: JsonField = JsonMissing.of(), @JsonProperty("allowed_cache_controls") @ExcludeMissing allowedCacheControls: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + allowedPassthroughRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + allowedVectorStoreIndexes: JsonField> = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), @JsonProperty("budget_duration") @ExcludeMissing @@ -1034,7 +1704,7 @@ private constructor( @JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @@ -1048,27 +1718,52 @@ private constructor( @JsonProperty("key_alias") @ExcludeMissing keyAlias: JsonField = JsonMissing.of(), + @JsonProperty("key_type") + @ExcludeMissing + keyType: JsonField = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @JsonProperty("max_parallel_requests") @ExcludeMissing maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("model_max_budget") @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), + modelMaxBudget: JsonField = JsonMissing.of(), @JsonProperty("model_rpm_limit") @ExcludeMissing - modelRpmLimit: JsonValue = JsonMissing.of(), + modelRpmLimit: JsonField = JsonMissing.of(), @JsonProperty("model_tpm_limit") @ExcludeMissing - modelTpmLimit: JsonValue = JsonMissing.of(), + modelTpmLimit: JsonField = JsonMissing.of(), @JsonProperty("models") @ExcludeMissing models: JsonField> = JsonMissing.of(), - @JsonProperty("permissions") @ExcludeMissing permissions: JsonValue = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField = JsonMissing.of(), + @JsonProperty("prompts") + @ExcludeMissing + prompts: JsonField> = JsonMissing.of(), + @JsonProperty("rotation_interval") + @ExcludeMissing + rotationInterval: JsonField = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("rpm_limit_type") + @ExcludeMissing + rpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("send_invite_email") @ExcludeMissing sendInviteEmail: JsonField = JsonMissing.of(), @@ -1079,10 +1774,17 @@ private constructor( @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("team_id") @ExcludeMissing teamId: JsonField = JsonMissing.of(), @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("tpm_limit_type") + @ExcludeMissing + tpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), ) : this( aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + autoRotate, blocked, budgetDuration, budgetId, @@ -1092,6 +1794,7 @@ private constructor( guardrails, key, keyAlias, + keyType, maxBudget, maxParallelRequests, metadata, @@ -1099,19 +1802,30 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + objectPermission, + organizationId, permissions, + prompts, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, sendInviteEmail, softBudget, spend, tags, teamId, tpmLimit, + tpmLimitType, userId, mutableMapOf(), ) - @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1120,6 +1834,34 @@ private constructor( fun allowedCacheControls(): Optional> = allowedCacheControls.getOptional("allowed_cache_controls") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedPassthroughRoutes(): Optional> = + allowedPassthroughRoutes.getOptional("allowed_passthrough_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = allowedRoutes.getOptional("allowed_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedVectorStoreIndexes(): Optional> = + allowedVectorStoreIndexes.getOptional("allowed_vector_store_indexes") + + /** + * Whether this key should be automatically rotated + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1138,7 +1880,11 @@ private constructor( */ fun budgetId(): Optional = budgetId.getOptional("budget_id") - @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1170,6 +1916,14 @@ private constructor( */ fun keyAlias(): Optional = keyAlias.getOptional("key_alias") + /** + * Enum for key types that determine what routes a key can access + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun keyType(): Optional = keyType.getOptional("key_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1183,19 +1937,30 @@ private constructor( fun maxParallelRequests(): Optional = maxParallelRequests.getOptional("max_parallel_requests") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = + modelMaxBudget.getOptional("model_max_budget") - @JsonProperty("model_rpm_limit") - @ExcludeMissing - fun _modelRpmLimit(): JsonValue = modelRpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelRpmLimit(): Optional = modelRpmLimit.getOptional("model_rpm_limit") - @JsonProperty("model_tpm_limit") - @ExcludeMissing - fun _modelTpmLimit(): JsonValue = modelTpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelTpmLimit(): Optional = modelTpmLimit.getOptional("model_tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1203,7 +1968,47 @@ private constructor( */ fun models(): Optional> = models.getOptional("models") - @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun organizationId(): Optional = organizationId.getOptional("organization_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompts(): Optional> = prompts.getOptional("prompts") + + /** + * How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationInterval(): Optional = rotationInterval.getOptional("rotation_interval") + + /** + * Set of params that you can modify via `router.update_settings()`. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = + routerSettings.getOptional("router_settings") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1211,6 +2016,12 @@ private constructor( */ fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpmLimitType(): Optional = rpmLimitType.getOptional("rpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1247,12 +2058,25 @@ private constructor( */ fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tpmLimitType(): Optional = tpmLimitType.getOptional("tpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun userId(): Optional = userId.getOptional("user_id") + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -1263,6 +2087,46 @@ private constructor( @ExcludeMissing fun _allowedCacheControls(): JsonField> = allowedCacheControls + /** + * Returns the raw JSON value of [allowedPassthroughRoutes]. + * + * Unlike [allowedPassthroughRoutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + fun _allowedPassthroughRoutes(): JsonField> = allowedPassthroughRoutes + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + + /** + * Returns the raw JSON value of [allowedVectorStoreIndexes]. + * + * Unlike [allowedVectorStoreIndexes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + fun _allowedVectorStoreIndexes(): JsonField> = + allowedVectorStoreIndexes + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + /** * Returns the raw JSON value of [blocked]. * @@ -1288,11 +2152,18 @@ private constructor( @JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId /** - * Returns the raw JSON value of [duration]. + * Returns the raw JSON value of [config]. * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** * Returns the raw JSON value of [enforcedParams]. @@ -1327,6 +2198,13 @@ private constructor( */ @JsonProperty("key_alias") @ExcludeMissing fun _keyAlias(): JsonField = keyAlias + /** + * Returns the raw JSON value of [keyType]. + * + * Unlike [keyType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key_type") @ExcludeMissing fun _keyType(): JsonField = keyType + /** * Returns the raw JSON value of [maxBudget]. * @@ -1344,6 +2222,43 @@ private constructor( @ExcludeMissing fun _maxParallelRequests(): JsonField = maxParallelRequests + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget + + /** + * Returns the raw JSON value of [modelRpmLimit]. + * + * Unlike [modelRpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_rpm_limit") + @ExcludeMissing + fun _modelRpmLimit(): JsonField = modelRpmLimit + + /** + * Returns the raw JSON value of [modelTpmLimit]. + * + * Unlike [modelTpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_tpm_limit") + @ExcludeMissing + fun _modelTpmLimit(): JsonField = modelTpmLimit + /** * Returns the raw JSON value of [models]. * @@ -1351,6 +2266,62 @@ private constructor( */ @JsonProperty("models") @ExcludeMissing fun _models(): JsonField> = models + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object_permission") + @ExcludeMissing + fun _objectPermission(): JsonField = objectPermission + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField = organizationId + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompts") @ExcludeMissing fun _prompts(): JsonField> = prompts + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rotation_interval") + @ExcludeMissing + fun _rotationInterval(): JsonField = rotationInterval + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + /** * Returns the raw JSON value of [rpmLimit]. * @@ -1358,6 +2329,16 @@ private constructor( */ @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + /** + * Returns the raw JSON value of [rpmLimitType]. + * + * Unlike [rpmLimitType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rpm_limit_type") + @ExcludeMissing + fun _rpmLimitType(): JsonField = rpmLimitType + /** * Returns the raw JSON value of [sendInviteEmail]. * @@ -1405,6 +2386,16 @@ private constructor( */ @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit + /** + * Returns the raw JSON value of [tpmLimitType]. + * + * Unlike [tpmLimitType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tpm_limit_type") + @ExcludeMissing + fun _tpmLimitType(): JsonField = tpmLimitType + /** * Returns the raw JSON value of [userId]. * @@ -1433,32 +2424,46 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var aliases: JsonValue = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() private var allowedCacheControls: JsonField>? = null + private var allowedPassthroughRoutes: JsonField>? = null + private var allowedRoutes: JsonField>? = null + private var allowedVectorStoreIndexes: + JsonField>? = + null + private var autoRotate: JsonField = JsonMissing.of() private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetId: JsonField = JsonMissing.of() - private var config: JsonValue = JsonMissing.of() + private var config: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var enforcedParams: JsonField>? = null private var guardrails: JsonField>? = null private var key: JsonField = JsonMissing.of() private var keyAlias: JsonField = JsonMissing.of() + private var keyType: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var modelRpmLimit: JsonValue = JsonMissing.of() - private var modelTpmLimit: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelRpmLimit: JsonField = JsonMissing.of() + private var modelTpmLimit: JsonField = JsonMissing.of() private var models: JsonField>? = null - private var permissions: JsonValue = JsonMissing.of() + private var objectPermission: JsonField = JsonMissing.of() + private var organizationId: JsonField = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var prompts: JsonField>? = null + private var rotationInterval: JsonField = JsonMissing.of() + private var routerSettings: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() + private var rpmLimitType: JsonField = JsonMissing.of() private var sendInviteEmail: JsonField = JsonMissing.of() private var softBudget: JsonField = JsonMissing.of() private var spend: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var teamId: JsonField = JsonMissing.of() private var tpmLimit: JsonField = JsonMissing.of() + private var tpmLimitType: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1466,6 +2471,11 @@ private constructor( internal fun from(body: Body) = apply { aliases = body.aliases allowedCacheControls = body.allowedCacheControls.map { it.toMutableList() } + allowedPassthroughRoutes = body.allowedPassthroughRoutes.map { it.toMutableList() } + allowedRoutes = body.allowedRoutes.map { it.toMutableList() } + allowedVectorStoreIndexes = + body.allowedVectorStoreIndexes.map { it.toMutableList() } + autoRotate = body.autoRotate blocked = body.blocked budgetDuration = body.budgetDuration budgetId = body.budgetId @@ -1475,6 +2485,7 @@ private constructor( guardrails = body.guardrails.map { it.toMutableList() } key = body.key keyAlias = body.keyAlias + keyType = body.keyType maxBudget = body.maxBudget maxParallelRequests = body.maxParallelRequests metadata = body.metadata @@ -1482,19 +2493,38 @@ private constructor( modelRpmLimit = body.modelRpmLimit modelTpmLimit = body.modelTpmLimit models = body.models.map { it.toMutableList() } + objectPermission = body.objectPermission + organizationId = body.organizationId permissions = body.permissions + prompts = body.prompts.map { it.toMutableList() } + rotationInterval = body.rotationInterval + routerSettings = body.routerSettings rpmLimit = body.rpmLimit + rpmLimitType = body.rpmLimitType sendInviteEmail = body.sendInviteEmail softBudget = body.softBudget spend = body.spend tags = body.tags.map { it.toMutableList() } teamId = body.teamId tpmLimit = body.tpmLimit + tpmLimitType = body.tpmLimitType userId = body.userId additionalProperties = body.additionalProperties.toMutableMap() } - fun aliases(aliases: JsonValue) = apply { this.aliases = aliases } + fun aliases(aliases: Aliases?) = aliases(JsonField.ofNullable(aliases)) + + /** Alias for calling [Builder.aliases] with `aliases.orElse(null)`. */ + fun aliases(aliases: Optional) = aliases(aliases.getOrNull()) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } fun allowedCacheControls(allowedCacheControls: List?) = allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) @@ -1529,6 +2559,132 @@ private constructor( } } + fun allowedPassthroughRoutes(allowedPassthroughRoutes: List?) = + allowedPassthroughRoutes(JsonField.ofNullable(allowedPassthroughRoutes)) + + /** + * Alias for calling [Builder.allowedPassthroughRoutes] with + * `allowedPassthroughRoutes.orElse(null)`. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: Optional>) = + allowedPassthroughRoutes(allowedPassthroughRoutes.getOrNull()) + + /** + * Sets [Builder.allowedPassthroughRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedPassthroughRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: JsonField>) = + apply { + this.allowedPassthroughRoutes = + allowedPassthroughRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedPassthroughRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedPassthroughRoute(allowedPassthroughRoute: JsonValue) = apply { + allowedPassthroughRoutes = + (allowedPassthroughRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedPassthroughRoutes", it).add(allowedPassthroughRoute) + } + } + + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } + + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: List? + ) = allowedVectorStoreIndexes(JsonField.ofNullable(allowedVectorStoreIndexes)) + + /** + * Alias for calling [Builder.allowedVectorStoreIndexes] with + * `allowedVectorStoreIndexes.orElse(null)`. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: Optional> + ) = allowedVectorStoreIndexes(allowedVectorStoreIndexes.getOrNull()) + + /** + * Sets [Builder.allowedVectorStoreIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedVectorStoreIndexes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: JsonField> + ) = apply { + this.allowedVectorStoreIndexes = + allowedVectorStoreIndexes.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedVectorStoreIndex] to [allowedVectorStoreIndexes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedVectorStoreIndex(allowedVectorStoreIndex: AllowedVectorStoreIndex) = + apply { + allowedVectorStoreIndexes = + (allowedVectorStoreIndexes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedVectorStoreIndexes", it).add(allowedVectorStoreIndex) + } + } + + /** Whether this key should be automatically rotated */ + fun autoRotate(autoRotate: Boolean?) = autoRotate(JsonField.ofNullable(autoRotate)) + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { this.autoRotate = autoRotate } + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) /** @@ -1582,7 +2738,19 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } - fun config(config: JsonValue) = apply { this.config = config } + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } fun duration(duration: String?) = duration(JsonField.ofNullable(duration)) @@ -1684,6 +2852,21 @@ private constructor( */ fun keyAlias(keyAlias: JsonField) = apply { this.keyAlias = keyAlias } + /** Enum for key types that determine what routes a key can access */ + fun keyType(keyType: KeyType?) = keyType(JsonField.ofNullable(keyType)) + + /** Alias for calling [Builder.keyType] with `keyType.orElse(null)`. */ + fun keyType(keyType: Optional) = keyType(keyType.getOrNull()) + + /** + * Sets [Builder.keyType] to an arbitrary JSON value. + * + * You should usually call [Builder.keyType] with a well-typed [KeyType] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun keyType(keyType: JsonField) = apply { this.keyType = keyType } + fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) /** @@ -1734,17 +2917,71 @@ private constructor( this.maxParallelRequests = maxParallelRequests } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget?) = + modelMaxBudget(JsonField.ofNullable(modelMaxBudget)) + + /** Alias for calling [Builder.modelMaxBudget] with `modelMaxBudget.orElse(null)`. */ + fun modelMaxBudget(modelMaxBudget: Optional) = + modelMaxBudget(modelMaxBudget.getOrNull()) - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { this.modelMaxBudget = modelMaxBudget } - fun modelRpmLimit(modelRpmLimit: JsonValue) = apply { + fun modelRpmLimit(modelRpmLimit: ModelRpmLimit?) = + modelRpmLimit(JsonField.ofNullable(modelRpmLimit)) + + /** Alias for calling [Builder.modelRpmLimit] with `modelRpmLimit.orElse(null)`. */ + fun modelRpmLimit(modelRpmLimit: Optional) = + modelRpmLimit(modelRpmLimit.getOrNull()) + + /** + * Sets [Builder.modelRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelRpmLimit] with a well-typed [ModelRpmLimit] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelRpmLimit(modelRpmLimit: JsonField) = apply { this.modelRpmLimit = modelRpmLimit } - fun modelTpmLimit(modelTpmLimit: JsonValue) = apply { + fun modelTpmLimit(modelTpmLimit: ModelTpmLimit?) = + modelTpmLimit(JsonField.ofNullable(modelTpmLimit)) + + /** Alias for calling [Builder.modelTpmLimit] with `modelTpmLimit.orElse(null)`. */ + fun modelTpmLimit(modelTpmLimit: Optional) = + modelTpmLimit(modelTpmLimit.getOrNull()) + + /** + * Sets [Builder.modelTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelTpmLimit] with a well-typed [ModelTpmLimit] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelTpmLimit(modelTpmLimit: JsonField) = apply { this.modelTpmLimit = modelTpmLimit } @@ -1776,92 +3013,232 @@ private constructor( } } - fun permissions(permissions: JsonValue) = apply { this.permissions = permissions } + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) - fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) + /** + * Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. + */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) /** - * Alias for [Builder.rpmLimit]. + * Sets [Builder.objectPermission] to an arbitrary JSON value. * - * This unboxed primitive overload exists for backwards compatibility. + * You should usually call [Builder.objectPermission] with a well-typed + * [ObjectPermission] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun rpmLimit(rpmLimit: Long) = rpmLimit(rpmLimit as Long?) + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } - /** Alias for calling [Builder.rpmLimit] with `rpmLimit.orElse(null)`. */ - fun rpmLimit(rpmLimit: Optional) = rpmLimit(rpmLimit.getOrNull()) + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) /** - * Sets [Builder.rpmLimit] to an arbitrary JSON value. + * Sets [Builder.organizationId] to an arbitrary JSON value. * - * You should usually call [Builder.rpmLimit] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } + fun organizationId(organizationId: JsonField) = apply { + this.organizationId = organizationId + } - fun sendInviteEmail(sendInviteEmail: Boolean?) = - sendInviteEmail(JsonField.ofNullable(sendInviteEmail)) + fun permissions(permissions: Permissions?) = + permissions(JsonField.ofNullable(permissions)) + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional) = + permissions(permissions.getOrNull()) /** - * Alias for [Builder.sendInviteEmail]. + * Sets [Builder.permissions] to an arbitrary JSON value. * - * This unboxed primitive overload exists for backwards compatibility. + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun sendInviteEmail(sendInviteEmail: Boolean) = - sendInviteEmail(sendInviteEmail as Boolean?) + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } - /** Alias for calling [Builder.sendInviteEmail] with `sendInviteEmail.orElse(null)`. */ - fun sendInviteEmail(sendInviteEmail: Optional) = - sendInviteEmail(sendInviteEmail.getOrNull()) + fun prompts(prompts: List?) = prompts(JsonField.ofNullable(prompts)) + + /** Alias for calling [Builder.prompts] with `prompts.orElse(null)`. */ + fun prompts(prompts: Optional>) = prompts(prompts.getOrNull()) /** - * Sets [Builder.sendInviteEmail] to an arbitrary JSON value. + * Sets [Builder.prompts] to an arbitrary JSON value. * - * You should usually call [Builder.sendInviteEmail] with a well-typed [Boolean] value + * You should usually call [Builder.prompts] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun sendInviteEmail(sendInviteEmail: JsonField) = apply { - this.sendInviteEmail = sendInviteEmail + fun prompts(prompts: JsonField>) = apply { + this.prompts = prompts.map { it.toMutableList() } } - fun softBudget(softBudget: Double?) = softBudget(JsonField.ofNullable(softBudget)) - /** - * Alias for [Builder.softBudget]. + * Adds a single [String] to [prompts]. * - * This unboxed primitive overload exists for backwards compatibility. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun softBudget(softBudget: Double) = softBudget(softBudget as Double?) + fun addPrompt(prompt: String) = apply { + prompts = + (prompts ?: JsonField.of(mutableListOf())).also { + checkKnown("prompts", it).add(prompt) + } + } - /** Alias for calling [Builder.softBudget] with `softBudget.orElse(null)`. */ - fun softBudget(softBudget: Optional) = softBudget(softBudget.getOrNull()) + /** How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True */ + fun rotationInterval(rotationInterval: String?) = + rotationInterval(JsonField.ofNullable(rotationInterval)) /** - * Sets [Builder.softBudget] to an arbitrary JSON value. + * Alias for calling [Builder.rotationInterval] with `rotationInterval.orElse(null)`. + */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. * - * You should usually call [Builder.softBudget] with a well-typed [Double] value + * You should usually call [Builder.rotationInterval] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun softBudget(softBudget: JsonField) = apply { this.softBudget = softBudget } + fun rotationInterval(rotationInterval: JsonField) = apply { + this.rotationInterval = rotationInterval + } - fun spend(spend: Double?) = spend(JsonField.ofNullable(spend)) + /** Set of params that you can modify via `router.update_settings()`. */ + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) /** - * Alias for [Builder.spend]. + * Sets [Builder.routerSettings] to an arbitrary JSON value. * - * This unboxed primitive overload exists for backwards compatibility. + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun spend(spend: Double) = spend(spend as Double?) + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } - /** Alias for calling [Builder.spend] with `spend.orElse(null)`. */ - fun spend(spend: Optional) = spend(spend.getOrNull()) + fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) /** - * Sets [Builder.spend] to an arbitrary JSON value. + * Alias for [Builder.rpmLimit]. * - * You should usually call [Builder.spend] with a well-typed [Double] value instead. + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rpmLimit(rpmLimit: Long) = rpmLimit(rpmLimit as Long?) + + /** Alias for calling [Builder.rpmLimit] with `rpmLimit.orElse(null)`. */ + fun rpmLimit(rpmLimit: Optional) = rpmLimit(rpmLimit.getOrNull()) + + /** + * Sets [Builder.rpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } + + fun rpmLimitType(rpmLimitType: RpmLimitType?) = + rpmLimitType(JsonField.ofNullable(rpmLimitType)) + + /** Alias for calling [Builder.rpmLimitType] with `rpmLimitType.orElse(null)`. */ + fun rpmLimitType(rpmLimitType: Optional) = + rpmLimitType(rpmLimitType.getOrNull()) + + /** + * Sets [Builder.rpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimitType] with a well-typed [RpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimitType(rpmLimitType: JsonField) = apply { + this.rpmLimitType = rpmLimitType + } + + fun sendInviteEmail(sendInviteEmail: Boolean?) = + sendInviteEmail(JsonField.ofNullable(sendInviteEmail)) + + /** + * Alias for [Builder.sendInviteEmail]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sendInviteEmail(sendInviteEmail: Boolean) = + sendInviteEmail(sendInviteEmail as Boolean?) + + /** Alias for calling [Builder.sendInviteEmail] with `sendInviteEmail.orElse(null)`. */ + fun sendInviteEmail(sendInviteEmail: Optional) = + sendInviteEmail(sendInviteEmail.getOrNull()) + + /** + * Sets [Builder.sendInviteEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.sendInviteEmail] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sendInviteEmail(sendInviteEmail: JsonField) = apply { + this.sendInviteEmail = sendInviteEmail + } + + fun softBudget(softBudget: Double?) = softBudget(JsonField.ofNullable(softBudget)) + + /** + * Alias for [Builder.softBudget]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun softBudget(softBudget: Double) = softBudget(softBudget as Double?) + + /** Alias for calling [Builder.softBudget] with `softBudget.orElse(null)`. */ + fun softBudget(softBudget: Optional) = softBudget(softBudget.getOrNull()) + + /** + * Sets [Builder.softBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.softBudget] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun softBudget(softBudget: JsonField) = apply { this.softBudget = softBudget } + + fun spend(spend: Double?) = spend(JsonField.ofNullable(spend)) + + /** + * Alias for [Builder.spend]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun spend(spend: Double) = spend(spend as Double?) + + /** Alias for calling [Builder.spend] with `spend.orElse(null)`. */ + fun spend(spend: Optional) = spend(spend.getOrNull()) + + /** + * Sets [Builder.spend] to an arbitrary JSON value. + * + * You should usually call [Builder.spend] with a well-typed [Double] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ @@ -1928,6 +3305,24 @@ private constructor( */ fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } + fun tpmLimitType(tpmLimitType: TpmLimitType?) = + tpmLimitType(JsonField.ofNullable(tpmLimitType)) + + /** Alias for calling [Builder.tpmLimitType] with `tpmLimitType.orElse(null)`. */ + fun tpmLimitType(tpmLimitType: Optional) = + tpmLimitType(tpmLimitType.getOrNull()) + + /** + * Sets [Builder.tpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimitType] with a well-typed [TpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tpmLimitType(tpmLimitType: JsonField) = apply { + this.tpmLimitType = tpmLimitType + } + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -1970,6 +3365,10 @@ private constructor( Body( aliases, (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedPassthroughRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedVectorStoreIndexes ?: JsonMissing.of()).map { it.toImmutable() }, + autoRotate, blocked, budgetDuration, budgetId, @@ -1979,6 +3378,7 @@ private constructor( (guardrails ?: JsonMissing.of()).map { it.toImmutable() }, key, keyAlias, + keyType, maxBudget, maxParallelRequests, metadata, @@ -1986,14 +3386,21 @@ private constructor( modelRpmLimit, modelTpmLimit, (models ?: JsonMissing.of()).map { it.toImmutable() }, + objectPermission, + organizationId, permissions, + (prompts ?: JsonMissing.of()).map { it.toImmutable() }, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, sendInviteEmail, softBudget, spend, (tags ?: JsonMissing.of()).map { it.toImmutable() }, teamId, tpmLimit, + tpmLimitType, userId, additionalProperties.toMutableMap(), ) @@ -2006,25 +3413,44 @@ private constructor( return@apply } + aliases().ifPresent { it.validate() } allowedCacheControls() + allowedPassthroughRoutes() + allowedRoutes() + allowedVectorStoreIndexes().ifPresent { it.forEach { it.validate() } } + autoRotate() blocked() budgetDuration() budgetId() + config().ifPresent { it.validate() } duration() enforcedParams() guardrails() key() keyAlias() + keyType().ifPresent { it.validate() } maxBudget() maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelRpmLimit().ifPresent { it.validate() } + modelTpmLimit().ifPresent { it.validate() } models() + objectPermission().ifPresent { it.validate() } + organizationId() + permissions().ifPresent { it.validate() } + prompts() + rotationInterval() + routerSettings().ifPresent { it.validate() } rpmLimit() + rpmLimitType().ifPresent { it.validate() } sendInviteEmail() softBudget() spend() tags() teamId() tpmLimit() + tpmLimitType().ifPresent { it.validate() } userId() validated = true } @@ -2045,25 +3471,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedPassthroughRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedVectorStoreIndexes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetId.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + (if (duration.asKnown().isPresent) 1 else 0) + (enforcedParams.asKnown().getOrNull()?.size ?: 0) + (guardrails.asKnown().getOrNull()?.size ?: 0) + (if (key.asKnown().isPresent) 1 else 0) + (if (keyAlias.asKnown().isPresent) 1 else 0) + + (keyType.asKnown().getOrNull()?.validity() ?: 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelRpmLimit.asKnown().getOrNull()?.validity() ?: 0) + + (modelTpmLimit.asKnown().getOrNull()?.validity() ?: 0) + (models.asKnown().getOrNull()?.size ?: 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (prompts.asKnown().getOrNull()?.size ?: 0) + + (if (rotationInterval.asKnown().isPresent) 1 else 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (rpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (sendInviteEmail.asKnown().isPresent) 1 else 0) + (if (softBudget.asKnown().isPresent) 1 else 0) + (if (spend.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (teamId.asKnown().isPresent) 1 else 0) + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (tpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (userId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2074,6 +3520,10 @@ private constructor( return other is Body && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && + allowedPassthroughRoutes == other.allowedPassthroughRoutes && + allowedRoutes == other.allowedRoutes && + allowedVectorStoreIndexes == other.allowedVectorStoreIndexes && + autoRotate == other.autoRotate && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetId == other.budgetId && @@ -2083,6 +3533,7 @@ private constructor( guardrails == other.guardrails && key == other.key && keyAlias == other.keyAlias && + keyType == other.keyType && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && @@ -2090,14 +3541,21 @@ private constructor( modelRpmLimit == other.modelRpmLimit && modelTpmLimit == other.modelTpmLimit && models == other.models && + objectPermission == other.objectPermission && + organizationId == other.organizationId && permissions == other.permissions && + prompts == other.prompts && + rotationInterval == other.rotationInterval && + routerSettings == other.routerSettings && rpmLimit == other.rpmLimit && + rpmLimitType == other.rpmLimitType && sendInviteEmail == other.sendInviteEmail && softBudget == other.softBudget && spend == other.spend && tags == other.tags && teamId == other.teamId && tpmLimit == other.tpmLimit && + tpmLimitType == other.tpmLimitType && userId == other.userId && additionalProperties == other.additionalProperties } @@ -2106,6 +3564,10 @@ private constructor( Objects.hash( aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + autoRotate, blocked, budgetDuration, budgetId, @@ -2115,6 +3577,7 @@ private constructor( guardrails, key, keyAlias, + keyType, maxBudget, maxParallelRequests, metadata, @@ -2122,14 +3585,21 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + objectPermission, + organizationId, permissions, + prompts, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, sendInviteEmail, softBudget, spend, tags, teamId, tpmLimit, + tpmLimitType, userId, additionalProperties, ) @@ -2138,7 +3608,3267 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{aliases=$aliases, allowedCacheControls=$allowedCacheControls, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, key=$key, keyAlias=$keyAlias, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, permissions=$permissions, rpmLimit=$rpmLimit, sendInviteEmail=$sendInviteEmail, softBudget=$softBudget, spend=$spend, tags=$tags, teamId=$teamId, tpmLimit=$tpmLimit, userId=$userId, additionalProperties=$additionalProperties}" + "Body{aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedPassthroughRoutes=$allowedPassthroughRoutes, allowedRoutes=$allowedRoutes, allowedVectorStoreIndexes=$allowedVectorStoreIndexes, autoRotate=$autoRotate, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, key=$key, keyAlias=$keyAlias, keyType=$keyType, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, objectPermission=$objectPermission, organizationId=$organizationId, permissions=$permissions, prompts=$prompts, rotationInterval=$rotationInterval, routerSettings=$routerSettings, rpmLimit=$rpmLimit, rpmLimitType=$rpmLimitType, sendInviteEmail=$sendInviteEmail, softBudget=$softBudget, spend=$spend, tags=$tags, teamId=$teamId, tpmLimit=$tpmLimit, tpmLimitType=$tpmLimitType, userId=$userId, additionalProperties=$additionalProperties}" + } + + class Aliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Aliases]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class AllowedVectorStoreIndex + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val indexName: JsonField, + private val indexPermissions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("index_name") + @ExcludeMissing + indexName: JsonField = JsonMissing.of(), + @JsonProperty("index_permissions") + @ExcludeMissing + indexPermissions: JsonField> = JsonMissing.of(), + ) : this(indexName, indexPermissions, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexName(): String = indexName.getRequired("index_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexPermissions(): List = + indexPermissions.getRequired("index_permissions") + + /** + * Returns the raw JSON value of [indexName]. + * + * Unlike [indexName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index_name") @ExcludeMissing fun _indexName(): JsonField = indexName + + /** + * Returns the raw JSON value of [indexPermissions]. + * + * Unlike [indexPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("index_permissions") + @ExcludeMissing + fun _indexPermissions(): JsonField> = indexPermissions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AllowedVectorStoreIndex]. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AllowedVectorStoreIndex]. */ + class Builder internal constructor() { + + private var indexName: JsonField? = null + private var indexPermissions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + indexName = allowedVectorStoreIndex.indexName + indexPermissions = + allowedVectorStoreIndex.indexPermissions.map { it.toMutableList() } + additionalProperties = allowedVectorStoreIndex.additionalProperties.toMutableMap() + } + + fun indexName(indexName: String) = indexName(JsonField.of(indexName)) + + /** + * Sets [Builder.indexName] to an arbitrary JSON value. + * + * You should usually call [Builder.indexName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun indexName(indexName: JsonField) = apply { this.indexName = indexName } + + fun indexPermissions(indexPermissions: List) = + indexPermissions(JsonField.of(indexPermissions)) + + /** + * Sets [Builder.indexPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.indexPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun indexPermissions(indexPermissions: JsonField>) = apply { + this.indexPermissions = indexPermissions.map { it.toMutableList() } + } + + /** + * Adds a single [IndexPermission] to [indexPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndexPermission(indexPermission: IndexPermission) = apply { + indexPermissions = + (indexPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("indexPermissions", it).add(indexPermission) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AllowedVectorStoreIndex]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AllowedVectorStoreIndex = + AllowedVectorStoreIndex( + checkRequired("indexName", indexName), + checkRequired("indexPermissions", indexPermissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AllowedVectorStoreIndex = apply { + if (validated) { + return@apply + } + + indexName() + indexPermissions().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (indexName.asKnown().isPresent) 1 else 0) + + (indexPermissions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class IndexPermission + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val READ = of("read") + + @JvmField val WRITE = of("write") + + @JvmStatic fun of(value: String) = IndexPermission(JsonField.of(value)) + } + + /** An enum containing [IndexPermission]'s known values. */ + enum class Known { + READ, + WRITE, + } + + /** + * An enum containing [IndexPermission]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IndexPermission] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + READ, + WRITE, + /** + * An enum member indicating that [IndexPermission] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + READ -> Value.READ + WRITE -> Value.WRITE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + READ -> Known.READ + WRITE -> Known.WRITE + else -> throw HanzoInvalidDataException("Unknown IndexPermission: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): IndexPermission = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexPermission && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedVectorStoreIndex && + indexName == other.indexName && + indexPermissions == other.indexPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(indexName, indexPermissions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AllowedVectorStoreIndex{indexName=$indexName, indexPermissions=$indexPermissions, additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + /** Enum for key types that determine what routes a key can access */ + class KeyType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_API = of("llm_api") + + @JvmField val MANAGEMENT = of("management") + + @JvmField val READ_ONLY = of("read_only") + + @JvmField val DEFAULT = of("default") + + @JvmStatic fun of(value: String) = KeyType(JsonField.of(value)) + } + + /** An enum containing [KeyType]'s known values. */ + enum class Known { + LLM_API, + MANAGEMENT, + READ_ONLY, + DEFAULT, + } + + /** + * An enum containing [KeyType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [KeyType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_API, + MANAGEMENT, + READ_ONLY, + DEFAULT, + /** An enum member indicating that [KeyType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_API -> Value.LLM_API + MANAGEMENT -> Value.MANAGEMENT + READ_ONLY -> Value.READ_ONLY + DEFAULT -> Value.DEFAULT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + LLM_API -> Known.LLM_API + MANAGEMENT -> Known.MANAGEMENT + READ_ONLY -> Known.READ_ONLY + DEFAULT -> Known.DEFAULT + else -> throw HanzoInvalidDataException("Unknown KeyType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): KeyType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KeyType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelMaxBudget]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelRpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelRpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelRpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelRpmLimit: ModelRpmLimit) = apply { + additionalProperties = modelRpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelRpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelRpmLimit = ModelRpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelRpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelRpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelRpmLimit{additionalProperties=$additionalProperties}" + } + + class ModelTpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelTpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelTpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelTpmLimit: ModelTpmLimit) = apply { + additionalProperties = modelTpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelTpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelTpmLimit = ModelTpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelTpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelTpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelTpmLimit{additionalProperties=$additionalProperties}" + } + + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vectorStores(): Optional> = vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agents") @ExcludeMissing fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ObjectPermission]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + agentAccessGroups = objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** Alias for calling [Builder.mcpAccessGroups] with `mcpAccessGroups.orElse(null)`. */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ObjectPermission = + ObjectPermission( + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + /** Set of params that you can modify via `router.update_settings()`. */ + class RouterSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowedFails: JsonField, + private val contextWindowFallbacks: JsonField>, + private val cooldownTime: JsonField, + private val fallbacks: JsonField>, + private val maxRetries: JsonField, + private val modelGroupAlias: JsonField, + private val modelGroupRetryPolicy: JsonField, + private val numRetries: JsonField, + private val retryAfter: JsonField, + private val routingStrategy: JsonField, + private val routingStrategyArgs: JsonField, + private val timeout: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_fails") + @ExcludeMissing + allowedFails: JsonField = JsonMissing.of(), + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + contextWindowFallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("cooldown_time") + @ExcludeMissing + cooldownTime: JsonField = JsonMissing.of(), + @JsonProperty("fallbacks") + @ExcludeMissing + fallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("max_retries") + @ExcludeMissing + maxRetries: JsonField = JsonMissing.of(), + @JsonProperty("model_group_alias") + @ExcludeMissing + modelGroupAlias: JsonField = JsonMissing.of(), + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + modelGroupRetryPolicy: JsonField = JsonMissing.of(), + @JsonProperty("num_retries") + @ExcludeMissing + numRetries: JsonField = JsonMissing.of(), + @JsonProperty("retry_after") + @ExcludeMissing + retryAfter: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy") + @ExcludeMissing + routingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy_args") + @ExcludeMissing + routingStrategyArgs: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + ) : this( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedFails(): Optional = allowedFails.getOptional("allowed_fails") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbacks(): Optional> = + contextWindowFallbacks.getOptional("context_window_fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cooldownTime(): Optional = cooldownTime.getOptional("cooldown_time") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = fallbacks.getOptional("fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupAlias(): Optional = + modelGroupAlias.getOptional("model_group_alias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupRetryPolicy(): Optional = + modelGroupRetryPolicy.getOptional("model_group_retry_policy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = numRetries.getOptional("num_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun retryAfter(): Optional = retryAfter.getOptional("retry_after") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategy(): Optional = routingStrategy.getOptional("routing_strategy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategyArgs(): Optional = + routingStrategyArgs.getOptional("routing_strategy_args") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * Returns the raw JSON value of [allowedFails]. + * + * Unlike [allowedFails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_fails") + @ExcludeMissing + fun _allowedFails(): JsonField = allowedFails + + /** + * Returns the raw JSON value of [contextWindowFallbacks]. + * + * Unlike [contextWindowFallbacks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + fun _contextWindowFallbacks(): JsonField> = + contextWindowFallbacks + + /** + * Returns the raw JSON value of [cooldownTime]. + * + * Unlike [cooldownTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cooldown_time") + @ExcludeMissing + fun _cooldownTime(): JsonField = cooldownTime + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fallbacks") + @ExcludeMissing + fun _fallbacks(): JsonField> = fallbacks + + /** + * Returns the raw JSON value of [maxRetries]. + * + * Unlike [maxRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_retries") @ExcludeMissing fun _maxRetries(): JsonField = maxRetries + + /** + * Returns the raw JSON value of [modelGroupAlias]. + * + * Unlike [modelGroupAlias], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_group_alias") + @ExcludeMissing + fun _modelGroupAlias(): JsonField = modelGroupAlias + + /** + * Returns the raw JSON value of [modelGroupRetryPolicy]. + * + * Unlike [modelGroupRetryPolicy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + fun _modelGroupRetryPolicy(): JsonField = modelGroupRetryPolicy + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_retries") @ExcludeMissing fun _numRetries(): JsonField = numRetries + + /** + * Returns the raw JSON value of [retryAfter]. + * + * Unlike [retryAfter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retry_after") + @ExcludeMissing + fun _retryAfter(): JsonField = retryAfter + + /** + * Returns the raw JSON value of [routingStrategy]. + * + * Unlike [routingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_strategy") + @ExcludeMissing + fun _routingStrategy(): JsonField = routingStrategy + + /** + * Returns the raw JSON value of [routingStrategyArgs]. + * + * Unlike [routingStrategyArgs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routing_strategy_args") + @ExcludeMissing + fun _routingStrategyArgs(): JsonField = routingStrategyArgs + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RouterSettings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var allowedFails: JsonField = JsonMissing.of() + private var contextWindowFallbacks: JsonField>? = + null + private var cooldownTime: JsonField = JsonMissing.of() + private var fallbacks: JsonField>? = null + private var maxRetries: JsonField = JsonMissing.of() + private var modelGroupAlias: JsonField = JsonMissing.of() + private var modelGroupRetryPolicy: JsonField = JsonMissing.of() + private var numRetries: JsonField = JsonMissing.of() + private var retryAfter: JsonField = JsonMissing.of() + private var routingStrategy: JsonField = JsonMissing.of() + private var routingStrategyArgs: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + allowedFails = routerSettings.allowedFails + contextWindowFallbacks = + routerSettings.contextWindowFallbacks.map { it.toMutableList() } + cooldownTime = routerSettings.cooldownTime + fallbacks = routerSettings.fallbacks.map { it.toMutableList() } + maxRetries = routerSettings.maxRetries + modelGroupAlias = routerSettings.modelGroupAlias + modelGroupRetryPolicy = routerSettings.modelGroupRetryPolicy + numRetries = routerSettings.numRetries + retryAfter = routerSettings.retryAfter + routingStrategy = routerSettings.routingStrategy + routingStrategyArgs = routerSettings.routingStrategyArgs + timeout = routerSettings.timeout + additionalProperties = routerSettings.additionalProperties.toMutableMap() + } + + fun allowedFails(allowedFails: Long?) = allowedFails(JsonField.ofNullable(allowedFails)) + + /** + * Alias for [Builder.allowedFails]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allowedFails(allowedFails: Long) = allowedFails(allowedFails as Long?) + + /** Alias for calling [Builder.allowedFails] with `allowedFails.orElse(null)`. */ + fun allowedFails(allowedFails: Optional) = allowedFails(allowedFails.getOrNull()) + + /** + * Sets [Builder.allowedFails] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedFails] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedFails(allowedFails: JsonField) = apply { + this.allowedFails = allowedFails + } + + fun contextWindowFallbacks(contextWindowFallbacks: List?) = + contextWindowFallbacks(JsonField.ofNullable(contextWindowFallbacks)) + + /** + * Alias for calling [Builder.contextWindowFallbacks] with + * `contextWindowFallbacks.orElse(null)`. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: Optional> + ) = contextWindowFallbacks(contextWindowFallbacks.getOrNull()) + + /** + * Sets [Builder.contextWindowFallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbacks] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: JsonField> + ) = apply { + this.contextWindowFallbacks = contextWindowFallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [ContextWindowFallback] to [contextWindowFallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContextWindowFallback(contextWindowFallback: ContextWindowFallback) = apply { + contextWindowFallbacks = + (contextWindowFallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("contextWindowFallbacks", it).add(contextWindowFallback) + } + } + + fun cooldownTime(cooldownTime: Double?) = + cooldownTime(JsonField.ofNullable(cooldownTime)) + + /** + * Alias for [Builder.cooldownTime]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cooldownTime(cooldownTime: Double) = cooldownTime(cooldownTime as Double?) + + /** Alias for calling [Builder.cooldownTime] with `cooldownTime.orElse(null)`. */ + fun cooldownTime(cooldownTime: Optional) = + cooldownTime(cooldownTime.getOrNull()) + + /** + * Sets [Builder.cooldownTime] to an arbitrary JSON value. + * + * You should usually call [Builder.cooldownTime] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cooldownTime(cooldownTime: JsonField) = apply { + this.cooldownTime = cooldownTime + } + + fun fallbacks(fallbacks: List?) = fallbacks(JsonField.ofNullable(fallbacks)) + + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) + + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { + this.fallbacks = fallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [Fallback] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: Fallback) = apply { + fallbacks = + (fallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("fallbacks", it).add(fallback) + } + } + + fun maxRetries(maxRetries: Long?) = maxRetries(JsonField.ofNullable(maxRetries)) + + /** + * Alias for [Builder.maxRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxRetries(maxRetries: Long) = maxRetries(maxRetries as Long?) + + /** Alias for calling [Builder.maxRetries] with `maxRetries.orElse(null)`. */ + fun maxRetries(maxRetries: Optional) = maxRetries(maxRetries.getOrNull()) + + /** + * Sets [Builder.maxRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.maxRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxRetries(maxRetries: JsonField) = apply { this.maxRetries = maxRetries } + + fun modelGroupAlias(modelGroupAlias: ModelGroupAlias?) = + modelGroupAlias(JsonField.ofNullable(modelGroupAlias)) + + /** Alias for calling [Builder.modelGroupAlias] with `modelGroupAlias.orElse(null)`. */ + fun modelGroupAlias(modelGroupAlias: Optional) = + modelGroupAlias(modelGroupAlias.getOrNull()) + + /** + * Sets [Builder.modelGroupAlias] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupAlias] with a well-typed [ModelGroupAlias] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelGroupAlias(modelGroupAlias: JsonField) = apply { + this.modelGroupAlias = modelGroupAlias + } + + fun modelGroupRetryPolicy(modelGroupRetryPolicy: ModelGroupRetryPolicy?) = + modelGroupRetryPolicy(JsonField.ofNullable(modelGroupRetryPolicy)) + + /** + * Alias for calling [Builder.modelGroupRetryPolicy] with + * `modelGroupRetryPolicy.orElse(null)`. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: Optional) = + modelGroupRetryPolicy(modelGroupRetryPolicy.getOrNull()) + + /** + * Sets [Builder.modelGroupRetryPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupRetryPolicy] with a well-typed + * [ModelGroupRetryPolicy] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: JsonField) = + apply { + this.modelGroupRetryPolicy = modelGroupRetryPolicy + } + + fun numRetries(numRetries: Long?) = numRetries(JsonField.ofNullable(numRetries)) + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numRetries(numRetries: JsonField) = apply { this.numRetries = numRetries } + + fun retryAfter(retryAfter: Double?) = retryAfter(JsonField.ofNullable(retryAfter)) + + /** + * Alias for [Builder.retryAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun retryAfter(retryAfter: Double) = retryAfter(retryAfter as Double?) + + /** Alias for calling [Builder.retryAfter] with `retryAfter.orElse(null)`. */ + fun retryAfter(retryAfter: Optional) = retryAfter(retryAfter.getOrNull()) + + /** + * Sets [Builder.retryAfter] to an arbitrary JSON value. + * + * You should usually call [Builder.retryAfter] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retryAfter(retryAfter: JsonField) = apply { this.retryAfter = retryAfter } + + fun routingStrategy(routingStrategy: String?) = + routingStrategy(JsonField.ofNullable(routingStrategy)) + + /** Alias for calling [Builder.routingStrategy] with `routingStrategy.orElse(null)`. */ + fun routingStrategy(routingStrategy: Optional) = + routingStrategy(routingStrategy.getOrNull()) + + /** + * Sets [Builder.routingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routingStrategy(routingStrategy: JsonField) = apply { + this.routingStrategy = routingStrategy + } + + fun routingStrategyArgs(routingStrategyArgs: RoutingStrategyArgs?) = + routingStrategyArgs(JsonField.ofNullable(routingStrategyArgs)) + + /** + * Alias for calling [Builder.routingStrategyArgs] with + * `routingStrategyArgs.orElse(null)`. + */ + fun routingStrategyArgs(routingStrategyArgs: Optional) = + routingStrategyArgs(routingStrategyArgs.getOrNull()) + + /** + * Sets [Builder.routingStrategyArgs] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategyArgs] with a well-typed + * [RoutingStrategyArgs] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun routingStrategyArgs(routingStrategyArgs: JsonField) = apply { + this.routingStrategyArgs = routingStrategyArgs + } + + fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) + + /** + * Alias for [Builder.timeout]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun timeout(timeout: Double) = timeout(timeout as Double?) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = + RouterSettings( + allowedFails, + (contextWindowFallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + cooldownTime, + (fallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouterSettings = apply { + if (validated) { + return@apply + } + + allowedFails() + contextWindowFallbacks().ifPresent { it.forEach { it.validate() } } + cooldownTime() + fallbacks().ifPresent { it.forEach { it.validate() } } + maxRetries() + modelGroupAlias().ifPresent { it.validate() } + modelGroupRetryPolicy().ifPresent { it.validate() } + numRetries() + retryAfter() + routingStrategy() + routingStrategyArgs().ifPresent { it.validate() } + timeout() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowedFails.asKnown().isPresent) 1 else 0) + + (contextWindowFallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (cooldownTime.asKnown().isPresent) 1 else 0) + + (fallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maxRetries.asKnown().isPresent) 1 else 0) + + (modelGroupAlias.asKnown().getOrNull()?.validity() ?: 0) + + (modelGroupRetryPolicy.asKnown().getOrNull()?.validity() ?: 0) + + (if (numRetries.asKnown().isPresent) 1 else 0) + + (if (retryAfter.asKnown().isPresent) 1 else 0) + + (if (routingStrategy.asKnown().isPresent) 1 else 0) + + (routingStrategyArgs.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeout.asKnown().isPresent) 1 else 0) + + class ContextWindowFallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContextWindowFallback]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContextWindowFallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contextWindowFallback: ContextWindowFallback) = apply { + additionalProperties = contextWindowFallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContextWindowFallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContextWindowFallback = + ContextWindowFallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ContextWindowFallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContextWindowFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContextWindowFallback{additionalProperties=$additionalProperties}" + } + + class Fallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Fallback]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + additionalProperties = fallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Fallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Fallback = Fallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Fallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Fallback && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Fallback{additionalProperties=$additionalProperties}" + } + + class ModelGroupAlias + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelGroupAlias]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupAlias]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupAlias: ModelGroupAlias) = apply { + additionalProperties = modelGroupAlias.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupAlias]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupAlias = ModelGroupAlias(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupAlias = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupAlias && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelGroupAlias{additionalProperties=$additionalProperties}" + } + + class ModelGroupRetryPolicy + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelGroupRetryPolicy]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupRetryPolicy]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupRetryPolicy: ModelGroupRetryPolicy) = apply { + additionalProperties = modelGroupRetryPolicy.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupRetryPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupRetryPolicy = + ModelGroupRetryPolicy(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupRetryPolicy = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupRetryPolicy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelGroupRetryPolicy{additionalProperties=$additionalProperties}" + } + + class RoutingStrategyArgs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoutingStrategyArgs]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutingStrategyArgs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routingStrategyArgs: RoutingStrategyArgs) = apply { + additionalProperties = routingStrategyArgs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutingStrategyArgs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoutingStrategyArgs = + RoutingStrategyArgs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RoutingStrategyArgs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingStrategyArgs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutingStrategyArgs{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouterSettings && + allowedFails == other.allowedFails && + contextWindowFallbacks == other.contextWindowFallbacks && + cooldownTime == other.cooldownTime && + fallbacks == other.fallbacks && + maxRetries == other.maxRetries && + modelGroupAlias == other.modelGroupAlias && + modelGroupRetryPolicy == other.modelGroupRetryPolicy && + numRetries == other.numRetries && + retryAfter == other.retryAfter && + routingStrategy == other.routingStrategy && + routingStrategyArgs == other.routingStrategyArgs && + timeout == other.timeout && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouterSettings{allowedFails=$allowedFails, contextWindowFallbacks=$contextWindowFallbacks, cooldownTime=$cooldownTime, fallbacks=$fallbacks, maxRetries=$maxRetries, modelGroupAlias=$modelGroupAlias, modelGroupRetryPolicy=$modelGroupRetryPolicy, numRetries=$numRetries, retryAfter=$retryAfter, routingStrategy=$routingStrategy, routingStrategyArgs=$routingStrategyArgs, timeout=$timeout, additionalProperties=$additionalProperties}" + } + + class RpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = RpmLimitType(JsonField.of(value)) + } + + /** An enum containing [RpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [RpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [RpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown RpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = TpmLimitType(JsonField.of(value)) + } + + /** An enum containing [TpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [TpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [TpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown TpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2147,15 +6877,15 @@ private constructor( } return other is KeyGenerateParams && - llmChangedBy == other.llmChangedBy && + litellmChangedBy == other.litellmChangedBy && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) + Objects.hash(litellmChangedBy, body, additionalHeaders, additionalQueryParams) override fun toString() = - "KeyGenerateParams{llmChangedBy=$llmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyGenerateParams{litellmChangedBy=$litellmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListParams.kt index f1572f12..74e75b2a 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListParams.kt @@ -5,6 +5,7 @@ package ai.hanzo.api.models.key import ai.hanzo.api.core.Params import ai.hanzo.api.core.http.Headers import ai.hanzo.api.core.http.QueryParams +import ai.hanzo.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -12,29 +13,52 @@ import kotlin.jvm.optionals.getOrNull /** * List all keys for a given user / team / organization. * + * Parameters: expand: Optional[List[str]] - Expand related objects (e.g. 'user' to include user + * information) status: Optional[str] - Filter by status. Currently supports "deleted" to query + * deleted keys. + * * Returns: { "keys": List[str] or List[UserAPIKeyAuth], "total_count": int, "current_page": int, * "total_pages": int, } + * + * When expand includes "user", each key object will include a "user" field with the associated user + * object. Note: When expand=user is specified, full key objects are returned regardless of the + * return_full_object parameter. */ class KeyListParams private constructor( + private val expand: List?, + private val includeCreatedByKeys: Boolean?, private val includeTeamKeys: Boolean?, private val keyAlias: String?, + private val keyHash: String?, private val organizationId: String?, private val page: Long?, private val returnFullObject: Boolean?, private val size: Long?, + private val sortBy: String?, + private val sortOrder: String?, + private val status: String?, private val teamId: String?, private val userId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { + /** Expand related objects (e.g. 'user') */ + fun expand(): Optional> = Optional.ofNullable(expand) + + /** Include keys created by the user */ + fun includeCreatedByKeys(): Optional = Optional.ofNullable(includeCreatedByKeys) + /** Include all keys for teams that user is an admin of. */ fun includeTeamKeys(): Optional = Optional.ofNullable(includeTeamKeys) /** Filter keys by key alias */ fun keyAlias(): Optional = Optional.ofNullable(keyAlias) + /** Filter keys by key hash */ + fun keyHash(): Optional = Optional.ofNullable(keyHash) + /** Filter keys by organization ID */ fun organizationId(): Optional = Optional.ofNullable(organizationId) @@ -47,6 +71,15 @@ private constructor( /** Page size */ fun size(): Optional = Optional.ofNullable(size) + /** Column to sort by (e.g. 'user_id', 'created_at', 'spend') */ + fun sortBy(): Optional = Optional.ofNullable(sortBy) + + /** Sort order ('asc' or 'desc') */ + fun sortOrder(): Optional = Optional.ofNullable(sortOrder) + + /** Filter by status (e.g. 'deleted') */ + fun status(): Optional = Optional.ofNullable(status) + /** Filter keys by team ID */ fun teamId(): Optional = Optional.ofNullable(teamId) @@ -72,12 +105,18 @@ private constructor( /** A builder for [KeyListParams]. */ class Builder internal constructor() { + private var expand: MutableList? = null + private var includeCreatedByKeys: Boolean? = null private var includeTeamKeys: Boolean? = null private var keyAlias: String? = null + private var keyHash: String? = null private var organizationId: String? = null private var page: Long? = null private var returnFullObject: Boolean? = null private var size: Long? = null + private var sortBy: String? = null + private var sortOrder: String? = null + private var status: String? = null private var teamId: String? = null private var userId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -85,18 +124,59 @@ private constructor( @JvmSynthetic internal fun from(keyListParams: KeyListParams) = apply { + expand = keyListParams.expand?.toMutableList() + includeCreatedByKeys = keyListParams.includeCreatedByKeys includeTeamKeys = keyListParams.includeTeamKeys keyAlias = keyListParams.keyAlias + keyHash = keyListParams.keyHash organizationId = keyListParams.organizationId page = keyListParams.page returnFullObject = keyListParams.returnFullObject size = keyListParams.size + sortBy = keyListParams.sortBy + sortOrder = keyListParams.sortOrder + status = keyListParams.status teamId = keyListParams.teamId userId = keyListParams.userId additionalHeaders = keyListParams.additionalHeaders.toBuilder() additionalQueryParams = keyListParams.additionalQueryParams.toBuilder() } + /** Expand related objects (e.g. 'user') */ + fun expand(expand: List?) = apply { this.expand = expand?.toMutableList() } + + /** Alias for calling [Builder.expand] with `expand.orElse(null)`. */ + fun expand(expand: Optional>) = expand(expand.getOrNull()) + + /** + * Adds a single [String] to [Builder.expand]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExpand(expand: String) = apply { + this.expand = (this.expand ?: mutableListOf()).apply { add(expand) } + } + + /** Include keys created by the user */ + fun includeCreatedByKeys(includeCreatedByKeys: Boolean?) = apply { + this.includeCreatedByKeys = includeCreatedByKeys + } + + /** + * Alias for [Builder.includeCreatedByKeys]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeCreatedByKeys(includeCreatedByKeys: Boolean) = + includeCreatedByKeys(includeCreatedByKeys as Boolean?) + + /** + * Alias for calling [Builder.includeCreatedByKeys] with + * `includeCreatedByKeys.orElse(null)`. + */ + fun includeCreatedByKeys(includeCreatedByKeys: Optional) = + includeCreatedByKeys(includeCreatedByKeys.getOrNull()) + /** Include all keys for teams that user is an admin of. */ fun includeTeamKeys(includeTeamKeys: Boolean?) = apply { this.includeTeamKeys = includeTeamKeys @@ -119,6 +199,12 @@ private constructor( /** Alias for calling [Builder.keyAlias] with `keyAlias.orElse(null)`. */ fun keyAlias(keyAlias: Optional) = keyAlias(keyAlias.getOrNull()) + /** Filter keys by key hash */ + fun keyHash(keyHash: String?) = apply { this.keyHash = keyHash } + + /** Alias for calling [Builder.keyHash] with `keyHash.orElse(null)`. */ + fun keyHash(keyHash: Optional) = keyHash(keyHash.getOrNull()) + /** Filter keys by organization ID */ fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } @@ -169,6 +255,24 @@ private constructor( /** Alias for calling [Builder.size] with `size.orElse(null)`. */ fun size(size: Optional) = size(size.getOrNull()) + /** Column to sort by (e.g. 'user_id', 'created_at', 'spend') */ + fun sortBy(sortBy: String?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) + + /** Sort order ('asc' or 'desc') */ + fun sortOrder(sortOrder: String?) = apply { this.sortOrder = sortOrder } + + /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ + fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) + + /** Filter by status (e.g. 'deleted') */ + fun status(status: String?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + /** Filter keys by team ID */ fun teamId(teamId: String?) = apply { this.teamId = teamId } @@ -286,12 +390,18 @@ private constructor( */ fun build(): KeyListParams = KeyListParams( + expand?.toImmutable(), + includeCreatedByKeys, includeTeamKeys, keyAlias, + keyHash, organizationId, page, returnFullObject, size, + sortBy, + sortOrder, + status, teamId, userId, additionalHeaders.build(), @@ -304,12 +414,18 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + expand?.let { put("expand", it.joinToString(",")) } + includeCreatedByKeys?.let { put("include_created_by_keys", it.toString()) } includeTeamKeys?.let { put("include_team_keys", it.toString()) } keyAlias?.let { put("key_alias", it) } + keyHash?.let { put("key_hash", it) } organizationId?.let { put("organization_id", it) } page?.let { put("page", it.toString()) } returnFullObject?.let { put("return_full_object", it.toString()) } size?.let { put("size", it.toString()) } + sortBy?.let { put("sort_by", it) } + sortOrder?.let { put("sort_order", it) } + status?.let { put("status", it) } teamId?.let { put("team_id", it) } userId?.let { put("user_id", it) } putAll(additionalQueryParams) @@ -322,12 +438,18 @@ private constructor( } return other is KeyListParams && + expand == other.expand && + includeCreatedByKeys == other.includeCreatedByKeys && includeTeamKeys == other.includeTeamKeys && keyAlias == other.keyAlias && + keyHash == other.keyHash && organizationId == other.organizationId && page == other.page && returnFullObject == other.returnFullObject && size == other.size && + sortBy == other.sortBy && + sortOrder == other.sortOrder && + status == other.status && teamId == other.teamId && userId == other.userId && additionalHeaders == other.additionalHeaders && @@ -336,12 +458,18 @@ private constructor( override fun hashCode(): Int = Objects.hash( + expand, + includeCreatedByKeys, includeTeamKeys, keyAlias, + keyHash, organizationId, page, returnFullObject, size, + sortBy, + sortOrder, + status, teamId, userId, additionalHeaders, @@ -349,5 +477,5 @@ private constructor( ) override fun toString() = - "KeyListParams{includeTeamKeys=$includeTeamKeys, keyAlias=$keyAlias, organizationId=$organizationId, page=$page, returnFullObject=$returnFullObject, size=$size, teamId=$teamId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyListParams{expand=$expand, includeCreatedByKeys=$includeCreatedByKeys, includeTeamKeys=$includeTeamKeys, keyAlias=$keyAlias, keyHash=$keyHash, organizationId=$organizationId, page=$page, returnFullObject=$returnFullObject, size=$size, sortBy=$sortBy, sortOrder=$sortOrder, status=$status, teamId=$teamId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt index b3b7fbe2..d44b5e37 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyListResponse.kt @@ -11,9 +11,11 @@ import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.allMaxBy import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.getOrThrow import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException +import ai.hanzo.api.models.organization.UserRoles import ai.hanzo.api.models.team.Member import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -187,6 +189,13 @@ private constructor( fun addKey(userApiKeyAuth: Key.UserApiKeyAuth) = addKey(Key.ofUserApiKeyAuth(userApiKeyAuth)) + /** + * Alias for calling [addKey] with + * `Key.ofLiteLlmDeletedVerificationToken(liteLlmDeletedVerificationToken)`. + */ + fun addKey(liteLlmDeletedVerificationToken: Key.LiteLlmDeletedVerificationToken) = + addKey(Key.ofLiteLlmDeletedVerificationToken(liteLlmDeletedVerificationToken)) + fun totalCount(totalCount: Long?) = totalCount(JsonField.ofNullable(totalCount)) /** @@ -302,6 +311,7 @@ private constructor( private constructor( private val string: String? = null, private val userApiKeyAuth: UserApiKeyAuth? = null, + private val liteLlmDeletedVerificationToken: LiteLlmDeletedVerificationToken? = null, private val _json: JsonValue? = null, ) { @@ -310,21 +320,39 @@ private constructor( /** Return the row in the db */ fun userApiKeyAuth(): Optional = Optional.ofNullable(userApiKeyAuth) + /** + * Recording of deleted keys for audit purposes. Mirrors LiteLLM_VerificationToken plus + * metadata captured at deletion time. + */ + fun liteLlmDeletedVerificationToken(): Optional = + Optional.ofNullable(liteLlmDeletedVerificationToken) + fun isString(): Boolean = string != null fun isUserApiKeyAuth(): Boolean = userApiKeyAuth != null + fun isLiteLlmDeletedVerificationToken(): Boolean = liteLlmDeletedVerificationToken != null + fun asString(): String = string.getOrThrow("string") /** Return the row in the db */ fun asUserApiKeyAuth(): UserApiKeyAuth = userApiKeyAuth.getOrThrow("userApiKeyAuth") + /** + * Recording of deleted keys for audit purposes. Mirrors LiteLLM_VerificationToken plus + * metadata captured at deletion time. + */ + fun asLiteLlmDeletedVerificationToken(): LiteLlmDeletedVerificationToken = + liteLlmDeletedVerificationToken.getOrThrow("liteLlmDeletedVerificationToken") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) userApiKeyAuth != null -> visitor.visitUserApiKeyAuth(userApiKeyAuth) + liteLlmDeletedVerificationToken != null -> + visitor.visitLiteLlmDeletedVerificationToken(liteLlmDeletedVerificationToken) else -> visitor.unknown(_json) } @@ -342,6 +370,12 @@ private constructor( override fun visitUserApiKeyAuth(userApiKeyAuth: UserApiKeyAuth) { userApiKeyAuth.validate() } + + override fun visitLiteLlmDeletedVerificationToken( + liteLlmDeletedVerificationToken: LiteLlmDeletedVerificationToken + ) { + liteLlmDeletedVerificationToken.validate() + } } ) validated = true @@ -370,6 +404,10 @@ private constructor( override fun visitUserApiKeyAuth(userApiKeyAuth: UserApiKeyAuth) = userApiKeyAuth.validity() + override fun visitLiteLlmDeletedVerificationToken( + liteLlmDeletedVerificationToken: LiteLlmDeletedVerificationToken + ) = liteLlmDeletedVerificationToken.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -379,15 +417,21 @@ private constructor( return true } - return other is Key && string == other.string && userApiKeyAuth == other.userApiKeyAuth + return other is Key && + string == other.string && + userApiKeyAuth == other.userApiKeyAuth && + liteLlmDeletedVerificationToken == other.liteLlmDeletedVerificationToken } - override fun hashCode(): Int = Objects.hash(string, userApiKeyAuth) + override fun hashCode(): Int = + Objects.hash(string, userApiKeyAuth, liteLlmDeletedVerificationToken) override fun toString(): String = when { string != null -> "Key{string=$string}" userApiKeyAuth != null -> "Key{userApiKeyAuth=$userApiKeyAuth}" + liteLlmDeletedVerificationToken != null -> + "Key{liteLlmDeletedVerificationToken=$liteLlmDeletedVerificationToken}" _json != null -> "Key{_unknown=$_json}" else -> throw IllegalStateException("Invalid Key") } @@ -400,6 +444,15 @@ private constructor( @JvmStatic fun ofUserApiKeyAuth(userApiKeyAuth: UserApiKeyAuth) = Key(userApiKeyAuth = userApiKeyAuth) + + /** + * Recording of deleted keys for audit purposes. Mirrors LiteLLM_VerificationToken plus + * metadata captured at deletion time. + */ + @JvmStatic + fun ofLiteLlmDeletedVerificationToken( + liteLlmDeletedVerificationToken: LiteLlmDeletedVerificationToken + ) = Key(liteLlmDeletedVerificationToken = liteLlmDeletedVerificationToken) } /** An interface that defines how to map each variant of [Key] to a value of type [T]. */ @@ -410,6 +463,14 @@ private constructor( /** Return the row in the db */ fun visitUserApiKeyAuth(userApiKeyAuth: UserApiKeyAuth): T + /** + * Recording of deleted keys for audit purposes. Mirrors LiteLLM_VerificationToken plus + * metadata captured at deletion time. + */ + fun visitLiteLlmDeletedVerificationToken( + liteLlmDeletedVerificationToken: LiteLlmDeletedVerificationToken + ): T + /** * Maps an unknown variant of [Key] to a value of type [T]. * @@ -434,6 +495,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Key(userApiKeyAuth = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Key(liteLlmDeletedVerificationToken = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { Key(string = it, _json = json) }, @@ -443,7 +506,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from array). + // all the possible variants (e.g. deserializing from boolean). 0 -> Key(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -464,6 +527,8 @@ private constructor( when { value.string != null -> generator.writeObject(value.string) value.userApiKeyAuth != null -> generator.writeObject(value.userApiKeyAuth) + value.liteLlmDeletedVerificationToken != null -> + generator.writeObject(value.liteLlmDeletedVerificationToken) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Key") } @@ -475,14 +540,16 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, - private val aliases: JsonValue, + private val aliases: JsonField, private val allowedCacheControls: JsonField>, private val allowedModelRegion: JsonField, + private val allowedRoutes: JsonField>, private val apiKey: JsonField, + private val autoRotate: JsonField, private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetResetAt: JsonField, - private val config: JsonValue, + private val config: JsonField, private val createdAt: JsonField, private val createdBy: JsonField, private val endUserId: JsonField, @@ -492,17 +559,29 @@ private constructor( private val expires: JsonField, private val keyAlias: JsonField, private val keyName: JsonField, + private val keyRotationAt: JsonField, private val lastRefreshedAt: JsonField, - private val llmBudgetTable: JsonValue, + private val lastRotationAt: JsonField, + private val litellmBudgetTable: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, - private val metadata: JsonValue, - private val modelMaxBudget: JsonValue, - private val modelSpend: JsonValue, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelSpend: JsonField, private val models: JsonField>, + private val objectPermission: JsonField, + private val objectPermissionId: JsonField, private val orgId: JsonField, + private val organizationMaxBudget: JsonField, + private val organizationMetadata: JsonField, + private val organizationRpmLimit: JsonField, + private val organizationTpmLimit: JsonField, private val parentOtelSpan: JsonValue, - private val permissions: JsonValue, + private val permissions: JsonField, + private val requestRoute: JsonField, + private val rotationCount: JsonField, + private val rotationInterval: JsonField, + private val routerSettings: JsonField, private val rpmLimit: JsonField, private val rpmLimitPerModel: JsonField, private val softBudget: JsonField, @@ -513,10 +592,13 @@ private constructor( private val teamId: JsonField, private val teamMaxBudget: JsonField, private val teamMember: JsonField, + private val teamMemberRpmLimit: JsonField, private val teamMemberSpend: JsonField, - private val teamMetadata: JsonValue, - private val teamModelAliases: JsonValue, + private val teamMemberTpmLimit: JsonField, + private val teamMetadata: JsonField, + private val teamModelAliases: JsonField, private val teamModels: JsonField>, + private val teamObjectPermissionId: JsonField, private val teamRpmLimit: JsonField, private val teamSpend: JsonField, private val teamTpmLimit: JsonField, @@ -524,10 +606,13 @@ private constructor( private val tpmLimitPerModel: JsonField, private val updatedAt: JsonField, private val updatedBy: JsonField, + private val user: JsonValue, private val userEmail: JsonField, private val userId: JsonField, - private val userRole: JsonField, + private val userMaxBudget: JsonField, + private val userRole: JsonField, private val userRpmLimit: JsonField, + private val userSpend: JsonField, private val userTpmLimit: JsonField, private val additionalProperties: MutableMap, ) { @@ -535,16 +620,24 @@ private constructor( @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("aliases") @ExcludeMissing aliases: JsonValue = JsonMissing.of(), + @JsonProperty("aliases") + @ExcludeMissing + aliases: JsonField = JsonMissing.of(), @JsonProperty("allowed_cache_controls") @ExcludeMissing allowedCacheControls: JsonField> = JsonMissing.of(), @JsonProperty("allowed_model_region") @ExcludeMissing allowedModelRegion: JsonField = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), @JsonProperty("api_key") @ExcludeMissing apiKey: JsonField = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), @@ -554,7 +647,9 @@ private constructor( @JsonProperty("budget_reset_at") @ExcludeMissing budgetResetAt: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -582,35 +677,73 @@ private constructor( @JsonProperty("key_name") @ExcludeMissing keyName: JsonField = JsonMissing.of(), + @JsonProperty("key_rotation_at") + @ExcludeMissing + keyRotationAt: JsonField = JsonMissing.of(), @JsonProperty("last_refreshed_at") @ExcludeMissing lastRefreshedAt: JsonField = JsonMissing.of(), - @JsonProperty("llm_budget_table") + @JsonProperty("last_rotation_at") @ExcludeMissing - llmBudgetTable: JsonValue = JsonMissing.of(), + lastRotationAt: JsonField = JsonMissing.of(), + @JsonProperty("litellm_budget_table") + @ExcludeMissing + litellmBudgetTable: JsonField = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @JsonProperty("max_parallel_requests") @ExcludeMissing maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("model_max_budget") @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), + modelMaxBudget: JsonField = JsonMissing.of(), @JsonProperty("model_spend") @ExcludeMissing - modelSpend: JsonValue = JsonMissing.of(), + modelSpend: JsonField = JsonMissing.of(), @JsonProperty("models") @ExcludeMissing models: JsonField> = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("object_permission_id") + @ExcludeMissing + objectPermissionId: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing orgId: JsonField = JsonMissing.of(), + @JsonProperty("organization_max_budget") + @ExcludeMissing + organizationMaxBudget: JsonField = JsonMissing.of(), + @JsonProperty("organization_metadata") + @ExcludeMissing + organizationMetadata: JsonField = JsonMissing.of(), + @JsonProperty("organization_rpm_limit") + @ExcludeMissing + organizationRpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("organization_tpm_limit") + @ExcludeMissing + organizationTpmLimit: JsonField = JsonMissing.of(), @JsonProperty("parent_otel_span") @ExcludeMissing parentOtelSpan: JsonValue = JsonMissing.of(), @JsonProperty("permissions") @ExcludeMissing - permissions: JsonValue = JsonMissing.of(), + permissions: JsonField = JsonMissing.of(), + @JsonProperty("request_route") + @ExcludeMissing + requestRoute: JsonField = JsonMissing.of(), + @JsonProperty("rotation_count") + @ExcludeMissing + rotationCount: JsonField = JsonMissing.of(), + @JsonProperty("rotation_interval") + @ExcludeMissing + rotationInterval: JsonField = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), @@ -639,18 +772,27 @@ private constructor( @JsonProperty("team_member") @ExcludeMissing teamMember: JsonField = JsonMissing.of(), + @JsonProperty("team_member_rpm_limit") + @ExcludeMissing + teamMemberRpmLimit: JsonField = JsonMissing.of(), @JsonProperty("team_member_spend") @ExcludeMissing teamMemberSpend: JsonField = JsonMissing.of(), + @JsonProperty("team_member_tpm_limit") + @ExcludeMissing + teamMemberTpmLimit: JsonField = JsonMissing.of(), @JsonProperty("team_metadata") @ExcludeMissing - teamMetadata: JsonValue = JsonMissing.of(), + teamMetadata: JsonField = JsonMissing.of(), @JsonProperty("team_model_aliases") @ExcludeMissing - teamModelAliases: JsonValue = JsonMissing.of(), + teamModelAliases: JsonField = JsonMissing.of(), @JsonProperty("team_models") @ExcludeMissing teamModels: JsonField> = JsonMissing.of(), + @JsonProperty("team_object_permission_id") + @ExcludeMissing + teamObjectPermissionId: JsonField = JsonMissing.of(), @JsonProperty("team_rpm_limit") @ExcludeMissing teamRpmLimit: JsonField = JsonMissing.of(), @@ -672,18 +814,25 @@ private constructor( @JsonProperty("updated_by") @ExcludeMissing updatedBy: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonValue = JsonMissing.of(), @JsonProperty("user_email") @ExcludeMissing userEmail: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("user_max_budget") + @ExcludeMissing + userMaxBudget: JsonField = JsonMissing.of(), @JsonProperty("user_role") @ExcludeMissing - userRole: JsonField = JsonMissing.of(), + userRole: JsonField = JsonMissing.of(), @JsonProperty("user_rpm_limit") @ExcludeMissing userRpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("user_spend") + @ExcludeMissing + userSpend: JsonField = JsonMissing.of(), @JsonProperty("user_tpm_limit") @ExcludeMissing userTpmLimit: JsonField = JsonMissing.of(), @@ -692,7 +841,9 @@ private constructor( aliases, allowedCacheControls, allowedModelRegion, + allowedRoutes, apiKey, + autoRotate, blocked, budgetDuration, budgetResetAt, @@ -706,17 +857,29 @@ private constructor( expires, keyAlias, keyName, + keyRotationAt, lastRefreshedAt, - llmBudgetTable, + lastRotationAt, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelSpend, models, + objectPermission, + objectPermissionId, orgId, + organizationMaxBudget, + organizationMetadata, + organizationRpmLimit, + organizationTpmLimit, parentOtelSpan, permissions, + requestRoute, + rotationCount, + rotationInterval, + routerSettings, rpmLimit, rpmLimitPerModel, softBudget, @@ -727,10 +890,13 @@ private constructor( teamId, teamMaxBudget, teamMember, + teamMemberRpmLimit, teamMemberSpend, + teamMemberTpmLimit, teamMetadata, teamModelAliases, teamModels, + teamObjectPermissionId, teamRpmLimit, teamSpend, teamTpmLimit, @@ -738,10 +904,13 @@ private constructor( tpmLimitPerModel, updatedAt, updatedBy, + user, userEmail, userId, + userMaxBudget, userRole, userRpmLimit, + userSpend, userTpmLimit, mutableMapOf(), ) @@ -752,7 +921,11 @@ private constructor( */ fun token(): Optional = token.getOptional("token") - @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -768,12 +941,25 @@ private constructor( fun allowedModelRegion(): Optional = allowedModelRegion.getOptional("allowed_model_region") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = + allowedRoutes.getOptional("allowed_routes") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun apiKey(): Optional = apiKey.getOptional("api_key") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -793,7 +979,11 @@ private constructor( fun budgetResetAt(): Optional = budgetResetAt.getOptional("budget_reset_at") - @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -852,6 +1042,13 @@ private constructor( */ fun keyName(): Optional = keyName.getOptional("key_name") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun keyRotationAt(): Optional = + keyRotationAt.getOptional("key_rotation_at") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -859,9 +1056,19 @@ private constructor( fun lastRefreshedAt(): Optional = lastRefreshedAt.getOptional("last_refreshed_at") - @JsonProperty("llm_budget_table") - @ExcludeMissing - fun _llmBudgetTable(): JsonValue = llmBudgetTable + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRotationAt(): Optional = + lastRotationAt.getOptional("last_rotation_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun litellmBudgetTable(): Optional = + litellmBudgetTable.getOptional("litellm_budget_table") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -876,13 +1083,24 @@ private constructor( fun maxParallelRequests(): Optional = maxParallelRequests.getOptional("max_parallel_requests") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = + modelMaxBudget.getOptional("model_max_budget") - @JsonProperty("model_spend") @ExcludeMissing fun _modelSpend(): JsonValue = modelSpend + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelSpend(): Optional = modelSpend.getOptional("model_spend") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -890,17 +1108,98 @@ private constructor( */ fun models(): Optional> = models.getOptional("models") + /** + * Represents a LiteLLM_ObjectPermissionTable record + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectPermissionId(): Optional = + objectPermissionId.getOptional("object_permission_id") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun orgId(): Optional = orgId.getOptional("org_id") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationMaxBudget(): Optional = + organizationMaxBudget.getOptional("organization_max_budget") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationMetadata(): Optional = + organizationMetadata.getOptional("organization_metadata") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationRpmLimit(): Optional = + organizationRpmLimit.getOptional("organization_rpm_limit") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationTpmLimit(): Optional = + organizationTpmLimit.getOptional("organization_tpm_limit") + + /** + * This arbitrary value can be deserialized into a custom type using the `convert` + * method: + * ```java + * MyClass myObject = userApiKeyAuth.parentOtelSpan().convert(MyClass.class); + * ``` + */ @JsonProperty("parent_otel_span") @ExcludeMissing fun _parentOtelSpan(): JsonValue = parentOtelSpan - @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestRoute(): Optional = requestRoute.getOptional("request_route") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rotationCount(): Optional = rotationCount.getOptional("rotation_count") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rotationInterval(): Optional = + rotationInterval.getOptional("rotation_interval") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun routerSettings(): Optional = + routerSettings.getOptional("router_settings") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -964,6 +1263,13 @@ private constructor( */ fun teamMember(): Optional = teamMember.getOptional("team_member") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun teamMemberRpmLimit(): Optional = + teamMemberRpmLimit.getOptional("team_member_rpm_limit") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -971,13 +1277,25 @@ private constructor( fun teamMemberSpend(): Optional = teamMemberSpend.getOptional("team_member_spend") - @JsonProperty("team_metadata") - @ExcludeMissing - fun _teamMetadata(): JsonValue = teamMetadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun teamMemberTpmLimit(): Optional = + teamMemberTpmLimit.getOptional("team_member_tpm_limit") - @JsonProperty("team_model_aliases") - @ExcludeMissing - fun _teamModelAliases(): JsonValue = teamModelAliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun teamMetadata(): Optional = teamMetadata.getOptional("team_metadata") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun teamModelAliases(): Optional = + teamModelAliases.getOptional("team_model_aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -985,6 +1303,13 @@ private constructor( */ fun teamModels(): Optional> = teamModels.getOptional("team_models") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun teamObjectPermissionId(): Optional = + teamObjectPermissionId.getOptional("team_object_permission_id") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1028,6 +1353,15 @@ private constructor( */ fun updatedBy(): Optional = updatedBy.getOptional("updated_by") + /** + * This arbitrary value can be deserialized into a custom type using the `convert` + * method: + * ```java + * MyClass myObject = userApiKeyAuth.user().convert(MyClass.class); + * ``` + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonValue = user + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1040,6 +1374,12 @@ private constructor( */ fun userId(): Optional = userId.getOptional("user_id") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userMaxBudget(): Optional = userMaxBudget.getOptional("user_max_budget") + /** * Admin Roles: PROXY_ADMIN: admin over the platform PROXY_ADMIN_VIEW_ONLY: can login, * view all own keys, view all spend ORG_ADMIN: admin over a specific organization, can @@ -1056,7 +1396,7 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun userRole(): Optional = userRole.getOptional("user_role") + fun userRole(): Optional = userRole.getOptional("user_role") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1064,6 +1404,12 @@ private constructor( */ fun userRpmLimit(): Optional = userRpmLimit.getOptional("user_rpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userSpend(): Optional = userSpend.getOptional("user_spend") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1077,6 +1423,13 @@ private constructor( */ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -1097,6 +1450,16 @@ private constructor( @ExcludeMissing fun _allowedModelRegion(): JsonField = allowedModelRegion + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + /** * Returns the raw JSON value of [apiKey]. * @@ -1104,6 +1467,16 @@ private constructor( */ @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + /** * Returns the raw JSON value of [blocked]. * @@ -1131,6 +1504,13 @@ private constructor( @ExcludeMissing fun _budgetResetAt(): JsonField = budgetResetAt + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + /** * Returns the raw JSON value of [createdAt]. * @@ -1213,6 +1593,16 @@ private constructor( */ @JsonProperty("key_name") @ExcludeMissing fun _keyName(): JsonField = keyName + /** + * Returns the raw JSON value of [keyRotationAt]. + * + * Unlike [keyRotationAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("key_rotation_at") + @ExcludeMissing + fun _keyRotationAt(): JsonField = keyRotationAt + /** * Returns the raw JSON value of [lastRefreshedAt]. * @@ -1223,6 +1613,26 @@ private constructor( @ExcludeMissing fun _lastRefreshedAt(): JsonField = lastRefreshedAt + /** + * Returns the raw JSON value of [lastRotationAt]. + * + * Unlike [lastRotationAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("last_rotation_at") + @ExcludeMissing + fun _lastRotationAt(): JsonField = lastRotationAt + + /** + * Returns the raw JSON value of [litellmBudgetTable]. + * + * Unlike [litellmBudgetTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("litellm_budget_table") + @ExcludeMissing + fun _litellmBudgetTable(): JsonField = litellmBudgetTable + /** * Returns the raw JSON value of [maxBudget]. * @@ -1244,51 +1654,191 @@ private constructor( fun _maxParallelRequests(): JsonField = maxParallelRequests /** - * Returns the raw JSON value of [models]. + * Returns the raw JSON value of [metadata]. * - * Unlike [models], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("models") + @JsonProperty("metadata") @ExcludeMissing - fun _models(): JsonField> = models + fun _metadata(): JsonField = metadata /** - * Returns the raw JSON value of [orgId]. + * Returns the raw JSON value of [modelMaxBudget]. * - * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget /** - * Returns the raw JSON value of [rpmLimit]. + * Returns the raw JSON value of [modelSpend]. * - * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected + * Unlike [modelSpend], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + @JsonProperty("model_spend") + @ExcludeMissing + fun _modelSpend(): JsonField = modelSpend /** - * Returns the raw JSON value of [rpmLimitPerModel]. + * Returns the raw JSON value of [models]. * - * Unlike [rpmLimitPerModel], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [models], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("rpm_limit_per_model") + @JsonProperty("models") @ExcludeMissing - fun _rpmLimitPerModel(): JsonField = rpmLimitPerModel + fun _models(): JsonField> = models /** - * Returns the raw JSON value of [softBudget]. + * Returns the raw JSON value of [objectPermission]. * - * Unlike [softBudget], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [objectPermission], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("soft_budget") + @JsonProperty("object_permission") @ExcludeMissing - fun _softBudget(): JsonField = softBudget + fun _objectPermission(): JsonField = objectPermission /** - * Returns the raw JSON value of [softBudgetCooldown]. + * Returns the raw JSON value of [objectPermissionId]. + * + * Unlike [objectPermissionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("object_permission_id") + @ExcludeMissing + fun _objectPermissionId(): JsonField = objectPermissionId + + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + + /** + * Returns the raw JSON value of [organizationMaxBudget]. + * + * Unlike [organizationMaxBudget], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("organization_max_budget") + @ExcludeMissing + fun _organizationMaxBudget(): JsonField = organizationMaxBudget + + /** + * Returns the raw JSON value of [organizationMetadata]. + * + * Unlike [organizationMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("organization_metadata") + @ExcludeMissing + fun _organizationMetadata(): JsonField = organizationMetadata + + /** + * Returns the raw JSON value of [organizationRpmLimit]. + * + * Unlike [organizationRpmLimit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("organization_rpm_limit") + @ExcludeMissing + fun _organizationRpmLimit(): JsonField = organizationRpmLimit + + /** + * Returns the raw JSON value of [organizationTpmLimit]. + * + * Unlike [organizationTpmLimit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("organization_tpm_limit") + @ExcludeMissing + fun _organizationTpmLimit(): JsonField = organizationTpmLimit + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [requestRoute]. + * + * Unlike [requestRoute], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("request_route") + @ExcludeMissing + fun _requestRoute(): JsonField = requestRoute + + /** + * Returns the raw JSON value of [rotationCount]. + * + * Unlike [rotationCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rotation_count") + @ExcludeMissing + fun _rotationCount(): JsonField = rotationCount + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rotation_interval") + @ExcludeMissing + fun _rotationInterval(): JsonField = rotationInterval + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + + /** + * Returns the raw JSON value of [rpmLimit]. + * + * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + + /** + * Returns the raw JSON value of [rpmLimitPerModel]. + * + * Unlike [rpmLimitPerModel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rpm_limit_per_model") + @ExcludeMissing + fun _rpmLimitPerModel(): JsonField = rpmLimitPerModel + + /** + * Returns the raw JSON value of [softBudget]. + * + * Unlike [softBudget], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("soft_budget") + @ExcludeMissing + fun _softBudget(): JsonField = softBudget + + /** + * Returns the raw JSON value of [softBudgetCooldown]. * * Unlike [softBudgetCooldown], this method doesn't throw if the JSON field has an * unexpected type. @@ -1351,6 +1901,16 @@ private constructor( @ExcludeMissing fun _teamMember(): JsonField = teamMember + /** + * Returns the raw JSON value of [teamMemberRpmLimit]. + * + * Unlike [teamMemberRpmLimit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("team_member_rpm_limit") + @ExcludeMissing + fun _teamMemberRpmLimit(): JsonField = teamMemberRpmLimit + /** * Returns the raw JSON value of [teamMemberSpend]. * @@ -1361,6 +1921,36 @@ private constructor( @ExcludeMissing fun _teamMemberSpend(): JsonField = teamMemberSpend + /** + * Returns the raw JSON value of [teamMemberTpmLimit]. + * + * Unlike [teamMemberTpmLimit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("team_member_tpm_limit") + @ExcludeMissing + fun _teamMemberTpmLimit(): JsonField = teamMemberTpmLimit + + /** + * Returns the raw JSON value of [teamMetadata]. + * + * Unlike [teamMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("team_metadata") + @ExcludeMissing + fun _teamMetadata(): JsonField = teamMetadata + + /** + * Returns the raw JSON value of [teamModelAliases]. + * + * Unlike [teamModelAliases], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("team_model_aliases") + @ExcludeMissing + fun _teamModelAliases(): JsonField = teamModelAliases + /** * Returns the raw JSON value of [teamModels]. * @@ -1371,6 +1961,16 @@ private constructor( @ExcludeMissing fun _teamModels(): JsonField> = teamModels + /** + * Returns the raw JSON value of [teamObjectPermissionId]. + * + * Unlike [teamObjectPermissionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("team_object_permission_id") + @ExcludeMissing + fun _teamObjectPermissionId(): JsonField = teamObjectPermissionId + /** * Returns the raw JSON value of [teamRpmLimit]. * @@ -1456,6 +2056,16 @@ private constructor( */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + /** + * Returns the raw JSON value of [userMaxBudget]. + * + * Unlike [userMaxBudget], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_max_budget") + @ExcludeMissing + fun _userMaxBudget(): JsonField = userMaxBudget + /** * Returns the raw JSON value of [userRole]. * @@ -1464,7 +2074,7 @@ private constructor( */ @JsonProperty("user_role") @ExcludeMissing - fun _userRole(): JsonField = userRole + fun _userRole(): JsonField = userRole /** * Returns the raw JSON value of [userRpmLimit]. @@ -1476,6 +2086,16 @@ private constructor( @ExcludeMissing fun _userRpmLimit(): JsonField = userRpmLimit + /** + * Returns the raw JSON value of [userSpend]. + * + * Unlike [userSpend], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_spend") + @ExcludeMissing + fun _userSpend(): JsonField = userSpend + /** * Returns the raw JSON value of [userTpmLimit]. * @@ -1508,14 +2128,16 @@ private constructor( class Builder internal constructor() { private var token: JsonField = JsonMissing.of() - private var aliases: JsonValue = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() private var allowedCacheControls: JsonField>? = null private var allowedModelRegion: JsonField = JsonMissing.of() + private var allowedRoutes: JsonField>? = null private var apiKey: JsonField = JsonMissing.of() + private var autoRotate: JsonField = JsonMissing.of() private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetResetAt: JsonField = JsonMissing.of() - private var config: JsonValue = JsonMissing.of() + private var config: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var createdBy: JsonField = JsonMissing.of() private var endUserId: JsonField = JsonMissing.of() @@ -1525,17 +2147,29 @@ private constructor( private var expires: JsonField = JsonMissing.of() private var keyAlias: JsonField = JsonMissing.of() private var keyName: JsonField = JsonMissing.of() + private var keyRotationAt: JsonField = JsonMissing.of() private var lastRefreshedAt: JsonField = JsonMissing.of() - private var llmBudgetTable: JsonValue = JsonMissing.of() + private var lastRotationAt: JsonField = JsonMissing.of() + private var litellmBudgetTable: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var modelSpend: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelSpend: JsonField = JsonMissing.of() private var models: JsonField>? = null + private var objectPermission: JsonField = JsonMissing.of() + private var objectPermissionId: JsonField = JsonMissing.of() private var orgId: JsonField = JsonMissing.of() + private var organizationMaxBudget: JsonField = JsonMissing.of() + private var organizationMetadata: JsonField = JsonMissing.of() + private var organizationRpmLimit: JsonField = JsonMissing.of() + private var organizationTpmLimit: JsonField = JsonMissing.of() private var parentOtelSpan: JsonValue = JsonMissing.of() - private var permissions: JsonValue = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var requestRoute: JsonField = JsonMissing.of() + private var rotationCount: JsonField = JsonMissing.of() + private var rotationInterval: JsonField = JsonMissing.of() + private var routerSettings: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() private var rpmLimitPerModel: JsonField = JsonMissing.of() private var softBudget: JsonField = JsonMissing.of() @@ -1546,10 +2180,13 @@ private constructor( private var teamId: JsonField = JsonMissing.of() private var teamMaxBudget: JsonField = JsonMissing.of() private var teamMember: JsonField = JsonMissing.of() + private var teamMemberRpmLimit: JsonField = JsonMissing.of() private var teamMemberSpend: JsonField = JsonMissing.of() - private var teamMetadata: JsonValue = JsonMissing.of() - private var teamModelAliases: JsonValue = JsonMissing.of() + private var teamMemberTpmLimit: JsonField = JsonMissing.of() + private var teamMetadata: JsonField = JsonMissing.of() + private var teamModelAliases: JsonField = JsonMissing.of() private var teamModels: JsonField>? = null + private var teamObjectPermissionId: JsonField = JsonMissing.of() private var teamRpmLimit: JsonField = JsonMissing.of() private var teamSpend: JsonField = JsonMissing.of() private var teamTpmLimit: JsonField = JsonMissing.of() @@ -1557,10 +2194,13 @@ private constructor( private var tpmLimitPerModel: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() private var updatedBy: JsonField = JsonMissing.of() + private var user: JsonValue = JsonMissing.of() private var userEmail: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() - private var userRole: JsonField = JsonMissing.of() + private var userMaxBudget: JsonField = JsonMissing.of() + private var userRole: JsonField = JsonMissing.of() private var userRpmLimit: JsonField = JsonMissing.of() + private var userSpend: JsonField = JsonMissing.of() private var userTpmLimit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1571,7 +2211,9 @@ private constructor( allowedCacheControls = userApiKeyAuth.allowedCacheControls.map { it.toMutableList() } allowedModelRegion = userApiKeyAuth.allowedModelRegion + allowedRoutes = userApiKeyAuth.allowedRoutes.map { it.toMutableList() } apiKey = userApiKeyAuth.apiKey + autoRotate = userApiKeyAuth.autoRotate blocked = userApiKeyAuth.blocked budgetDuration = userApiKeyAuth.budgetDuration budgetResetAt = userApiKeyAuth.budgetResetAt @@ -1585,17 +2227,29 @@ private constructor( expires = userApiKeyAuth.expires keyAlias = userApiKeyAuth.keyAlias keyName = userApiKeyAuth.keyName + keyRotationAt = userApiKeyAuth.keyRotationAt lastRefreshedAt = userApiKeyAuth.lastRefreshedAt - llmBudgetTable = userApiKeyAuth.llmBudgetTable + lastRotationAt = userApiKeyAuth.lastRotationAt + litellmBudgetTable = userApiKeyAuth.litellmBudgetTable maxBudget = userApiKeyAuth.maxBudget maxParallelRequests = userApiKeyAuth.maxParallelRequests metadata = userApiKeyAuth.metadata modelMaxBudget = userApiKeyAuth.modelMaxBudget modelSpend = userApiKeyAuth.modelSpend models = userApiKeyAuth.models.map { it.toMutableList() } + objectPermission = userApiKeyAuth.objectPermission + objectPermissionId = userApiKeyAuth.objectPermissionId orgId = userApiKeyAuth.orgId + organizationMaxBudget = userApiKeyAuth.organizationMaxBudget + organizationMetadata = userApiKeyAuth.organizationMetadata + organizationRpmLimit = userApiKeyAuth.organizationRpmLimit + organizationTpmLimit = userApiKeyAuth.organizationTpmLimit parentOtelSpan = userApiKeyAuth.parentOtelSpan permissions = userApiKeyAuth.permissions + requestRoute = userApiKeyAuth.requestRoute + rotationCount = userApiKeyAuth.rotationCount + rotationInterval = userApiKeyAuth.rotationInterval + routerSettings = userApiKeyAuth.routerSettings rpmLimit = userApiKeyAuth.rpmLimit rpmLimitPerModel = userApiKeyAuth.rpmLimitPerModel softBudget = userApiKeyAuth.softBudget @@ -1606,10 +2260,13 @@ private constructor( teamId = userApiKeyAuth.teamId teamMaxBudget = userApiKeyAuth.teamMaxBudget teamMember = userApiKeyAuth.teamMember + teamMemberRpmLimit = userApiKeyAuth.teamMemberRpmLimit teamMemberSpend = userApiKeyAuth.teamMemberSpend + teamMemberTpmLimit = userApiKeyAuth.teamMemberTpmLimit teamMetadata = userApiKeyAuth.teamMetadata teamModelAliases = userApiKeyAuth.teamModelAliases teamModels = userApiKeyAuth.teamModels.map { it.toMutableList() } + teamObjectPermissionId = userApiKeyAuth.teamObjectPermissionId teamRpmLimit = userApiKeyAuth.teamRpmLimit teamSpend = userApiKeyAuth.teamSpend teamTpmLimit = userApiKeyAuth.teamTpmLimit @@ -1617,10 +2274,13 @@ private constructor( tpmLimitPerModel = userApiKeyAuth.tpmLimitPerModel updatedAt = userApiKeyAuth.updatedAt updatedBy = userApiKeyAuth.updatedBy + user = userApiKeyAuth.user userEmail = userApiKeyAuth.userEmail userId = userApiKeyAuth.userId + userMaxBudget = userApiKeyAuth.userMaxBudget userRole = userApiKeyAuth.userRole userRpmLimit = userApiKeyAuth.userRpmLimit + userSpend = userApiKeyAuth.userSpend userTpmLimit = userApiKeyAuth.userTpmLimit additionalProperties = userApiKeyAuth.additionalProperties.toMutableMap() } @@ -1639,7 +2299,16 @@ private constructor( */ fun token(token: JsonField) = apply { this.token = token } - fun aliases(aliases: JsonValue) = apply { this.aliases = aliases } + fun aliases(aliases: Aliases) = aliases(JsonField.of(aliases)) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } fun allowedCacheControls(allowedCacheControls: List?) = allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) @@ -1695,6 +2364,36 @@ private constructor( this.allowedModelRegion = allowedModelRegion } + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } + fun apiKey(apiKey: String?) = apiKey(JsonField.ofNullable(apiKey)) /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ @@ -1709,6 +2408,29 @@ private constructor( */ fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + fun autoRotate(autoRotate: Boolean?) = autoRotate(JsonField.ofNullable(autoRotate)) + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { + this.autoRotate = autoRotate + } + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) /** @@ -1768,7 +2490,16 @@ private constructor( this.budgetResetAt = budgetResetAt } - fun config(config: JsonValue) = apply { this.config = config } + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) @@ -1950,6 +2681,24 @@ private constructor( */ fun keyName(keyName: JsonField) = apply { this.keyName = keyName } + fun keyRotationAt(keyRotationAt: OffsetDateTime?) = + keyRotationAt(JsonField.ofNullable(keyRotationAt)) + + /** Alias for calling [Builder.keyRotationAt] with `keyRotationAt.orElse(null)`. */ + fun keyRotationAt(keyRotationAt: Optional) = + keyRotationAt(keyRotationAt.getOrNull()) + + /** + * Sets [Builder.keyRotationAt] to an arbitrary JSON value. + * + * You should usually call [Builder.keyRotationAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun keyRotationAt(keyRotationAt: JsonField) = apply { + this.keyRotationAt = keyRotationAt + } + fun lastRefreshedAt(lastRefreshedAt: Double?) = lastRefreshedAt(JsonField.ofNullable(lastRefreshedAt)) @@ -1978,8 +2727,45 @@ private constructor( this.lastRefreshedAt = lastRefreshedAt } - fun llmBudgetTable(llmBudgetTable: JsonValue) = apply { - this.llmBudgetTable = llmBudgetTable + fun lastRotationAt(lastRotationAt: OffsetDateTime?) = + lastRotationAt(JsonField.ofNullable(lastRotationAt)) + + /** + * Alias for calling [Builder.lastRotationAt] with `lastRotationAt.orElse(null)`. + */ + fun lastRotationAt(lastRotationAt: Optional) = + lastRotationAt(lastRotationAt.getOrNull()) + + /** + * Sets [Builder.lastRotationAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRotationAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun lastRotationAt(lastRotationAt: JsonField) = apply { + this.lastRotationAt = lastRotationAt + } + + fun litellmBudgetTable(litellmBudgetTable: LitellmBudgetTable?) = + litellmBudgetTable(JsonField.ofNullable(litellmBudgetTable)) + + /** + * Alias for calling [Builder.litellmBudgetTable] with + * `litellmBudgetTable.orElse(null)`. + */ + fun litellmBudgetTable(litellmBudgetTable: Optional) = + litellmBudgetTable(litellmBudgetTable.getOrNull()) + + /** + * Sets [Builder.litellmBudgetTable] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmBudgetTable] with a well-typed + * [LitellmBudgetTable] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun litellmBudgetTable(litellmBudgetTable: JsonField) = apply { + this.litellmBudgetTable = litellmBudgetTable } fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) @@ -2032,13 +2818,43 @@ private constructor( this.maxParallelRequests = maxParallelRequests } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget) = + modelMaxBudget(JsonField.of(modelMaxBudget)) - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed + * [ModelMaxBudget] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { this.modelMaxBudget = modelMaxBudget } - fun modelSpend(modelSpend: JsonValue) = apply { this.modelSpend = modelSpend } + fun modelSpend(modelSpend: ModelSpend) = modelSpend(JsonField.of(modelSpend)) + + /** + * Sets [Builder.modelSpend] to an arbitrary JSON value. + * + * You should usually call [Builder.modelSpend] with a well-typed [ModelSpend] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelSpend(modelSpend: JsonField) = apply { + this.modelSpend = modelSpend + } fun models(models: List) = models(JsonField.of(models)) @@ -2065,6 +2881,49 @@ private constructor( } } + /** Represents a LiteLLM_ObjectPermissionTable record */ + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) + + /** + * Alias for calling [Builder.objectPermission] with + * `objectPermission.orElse(null)`. + */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed + * [ObjectPermission] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } + + fun objectPermissionId(objectPermissionId: String?) = + objectPermissionId(JsonField.ofNullable(objectPermissionId)) + + /** + * Alias for calling [Builder.objectPermissionId] with + * `objectPermissionId.orElse(null)`. + */ + fun objectPermissionId(objectPermissionId: Optional) = + objectPermissionId(objectPermissionId.getOrNull()) + + /** + * Sets [Builder.objectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermissionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun objectPermissionId(objectPermissionId: JsonField) = apply { + this.objectPermissionId = objectPermissionId + } + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ @@ -2079,16 +2938,220 @@ private constructor( */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - fun parentOtelSpan(parentOtelSpan: JsonValue) = apply { - this.parentOtelSpan = parentOtelSpan - } - - fun permissions(permissions: JsonValue) = apply { this.permissions = permissions } - - fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) + fun organizationMaxBudget(organizationMaxBudget: Double?) = + organizationMaxBudget(JsonField.ofNullable(organizationMaxBudget)) /** - * Alias for [Builder.rpmLimit]. + * Alias for [Builder.organizationMaxBudget]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun organizationMaxBudget(organizationMaxBudget: Double) = + organizationMaxBudget(organizationMaxBudget as Double?) + + /** + * Alias for calling [Builder.organizationMaxBudget] with + * `organizationMaxBudget.orElse(null)`. + */ + fun organizationMaxBudget(organizationMaxBudget: Optional) = + organizationMaxBudget(organizationMaxBudget.getOrNull()) + + /** + * Sets [Builder.organizationMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationMaxBudget] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun organizationMaxBudget(organizationMaxBudget: JsonField) = apply { + this.organizationMaxBudget = organizationMaxBudget + } + + fun organizationMetadata(organizationMetadata: OrganizationMetadata?) = + organizationMetadata(JsonField.ofNullable(organizationMetadata)) + + /** + * Alias for calling [Builder.organizationMetadata] with + * `organizationMetadata.orElse(null)`. + */ + fun organizationMetadata(organizationMetadata: Optional) = + organizationMetadata(organizationMetadata.getOrNull()) + + /** + * Sets [Builder.organizationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationMetadata] with a well-typed + * [OrganizationMetadata] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun organizationMetadata(organizationMetadata: JsonField) = + apply { + this.organizationMetadata = organizationMetadata + } + + fun organizationRpmLimit(organizationRpmLimit: Long?) = + organizationRpmLimit(JsonField.ofNullable(organizationRpmLimit)) + + /** + * Alias for [Builder.organizationRpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun organizationRpmLimit(organizationRpmLimit: Long) = + organizationRpmLimit(organizationRpmLimit as Long?) + + /** + * Alias for calling [Builder.organizationRpmLimit] with + * `organizationRpmLimit.orElse(null)`. + */ + fun organizationRpmLimit(organizationRpmLimit: Optional) = + organizationRpmLimit(organizationRpmLimit.getOrNull()) + + /** + * Sets [Builder.organizationRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationRpmLimit] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun organizationRpmLimit(organizationRpmLimit: JsonField) = apply { + this.organizationRpmLimit = organizationRpmLimit + } + + fun organizationTpmLimit(organizationTpmLimit: Long?) = + organizationTpmLimit(JsonField.ofNullable(organizationTpmLimit)) + + /** + * Alias for [Builder.organizationTpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun organizationTpmLimit(organizationTpmLimit: Long) = + organizationTpmLimit(organizationTpmLimit as Long?) + + /** + * Alias for calling [Builder.organizationTpmLimit] with + * `organizationTpmLimit.orElse(null)`. + */ + fun organizationTpmLimit(organizationTpmLimit: Optional) = + organizationTpmLimit(organizationTpmLimit.getOrNull()) + + /** + * Sets [Builder.organizationTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationTpmLimit] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun organizationTpmLimit(organizationTpmLimit: JsonField) = apply { + this.organizationTpmLimit = organizationTpmLimit + } + + fun parentOtelSpan(parentOtelSpan: JsonValue) = apply { + this.parentOtelSpan = parentOtelSpan + } + + fun permissions(permissions: Permissions) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } + + fun requestRoute(requestRoute: String?) = + requestRoute(JsonField.ofNullable(requestRoute)) + + /** Alias for calling [Builder.requestRoute] with `requestRoute.orElse(null)`. */ + fun requestRoute(requestRoute: Optional) = + requestRoute(requestRoute.getOrNull()) + + /** + * Sets [Builder.requestRoute] to an arbitrary JSON value. + * + * You should usually call [Builder.requestRoute] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestRoute(requestRoute: JsonField) = apply { + this.requestRoute = requestRoute + } + + fun rotationCount(rotationCount: Long?) = + rotationCount(JsonField.ofNullable(rotationCount)) + + /** + * Alias for [Builder.rotationCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rotationCount(rotationCount: Long) = rotationCount(rotationCount as Long?) + + /** Alias for calling [Builder.rotationCount] with `rotationCount.orElse(null)`. */ + fun rotationCount(rotationCount: Optional) = + rotationCount(rotationCount.getOrNull()) + + /** + * Sets [Builder.rotationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rotationCount(rotationCount: JsonField) = apply { + this.rotationCount = rotationCount + } + + fun rotationInterval(rotationInterval: String?) = + rotationInterval(JsonField.ofNullable(rotationInterval)) + + /** + * Alias for calling [Builder.rotationInterval] with + * `rotationInterval.orElse(null)`. + */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + this.rotationInterval = rotationInterval + } + + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** + * Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. + */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed + * [RouterSettings] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } + + fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) + + /** + * Alias for [Builder.rpmLimit]. * * This unboxed primitive overload exists for backwards compatibility. */ @@ -2257,6 +3320,35 @@ private constructor( this.teamMember = teamMember } + fun teamMemberRpmLimit(teamMemberRpmLimit: Long?) = + teamMemberRpmLimit(JsonField.ofNullable(teamMemberRpmLimit)) + + /** + * Alias for [Builder.teamMemberRpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun teamMemberRpmLimit(teamMemberRpmLimit: Long) = + teamMemberRpmLimit(teamMemberRpmLimit as Long?) + + /** + * Alias for calling [Builder.teamMemberRpmLimit] with + * `teamMemberRpmLimit.orElse(null)`. + */ + fun teamMemberRpmLimit(teamMemberRpmLimit: Optional) = + teamMemberRpmLimit(teamMemberRpmLimit.getOrNull()) + + /** + * Sets [Builder.teamMemberRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.teamMemberRpmLimit] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun teamMemberRpmLimit(teamMemberRpmLimit: JsonField) = apply { + this.teamMemberRpmLimit = teamMemberRpmLimit + } + fun teamMemberSpend(teamMemberSpend: Double?) = teamMemberSpend(JsonField.ofNullable(teamMemberSpend)) @@ -2285,11 +3377,71 @@ private constructor( this.teamMemberSpend = teamMemberSpend } - fun teamMetadata(teamMetadata: JsonValue) = apply { + fun teamMemberTpmLimit(teamMemberTpmLimit: Long?) = + teamMemberTpmLimit(JsonField.ofNullable(teamMemberTpmLimit)) + + /** + * Alias for [Builder.teamMemberTpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun teamMemberTpmLimit(teamMemberTpmLimit: Long) = + teamMemberTpmLimit(teamMemberTpmLimit as Long?) + + /** + * Alias for calling [Builder.teamMemberTpmLimit] with + * `teamMemberTpmLimit.orElse(null)`. + */ + fun teamMemberTpmLimit(teamMemberTpmLimit: Optional) = + teamMemberTpmLimit(teamMemberTpmLimit.getOrNull()) + + /** + * Sets [Builder.teamMemberTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.teamMemberTpmLimit] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun teamMemberTpmLimit(teamMemberTpmLimit: JsonField) = apply { + this.teamMemberTpmLimit = teamMemberTpmLimit + } + + fun teamMetadata(teamMetadata: TeamMetadata?) = + teamMetadata(JsonField.ofNullable(teamMetadata)) + + /** Alias for calling [Builder.teamMetadata] with `teamMetadata.orElse(null)`. */ + fun teamMetadata(teamMetadata: Optional) = + teamMetadata(teamMetadata.getOrNull()) + + /** + * Sets [Builder.teamMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.teamMetadata] with a well-typed [TeamMetadata] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun teamMetadata(teamMetadata: JsonField) = apply { this.teamMetadata = teamMetadata } - fun teamModelAliases(teamModelAliases: JsonValue) = apply { + fun teamModelAliases(teamModelAliases: TeamModelAliases?) = + teamModelAliases(JsonField.ofNullable(teamModelAliases)) + + /** + * Alias for calling [Builder.teamModelAliases] with + * `teamModelAliases.orElse(null)`. + */ + fun teamModelAliases(teamModelAliases: Optional) = + teamModelAliases(teamModelAliases.getOrNull()) + + /** + * Sets [Builder.teamModelAliases] to an arbitrary JSON value. + * + * You should usually call [Builder.teamModelAliases] with a well-typed + * [TeamModelAliases] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun teamModelAliases(teamModelAliases: JsonField) = apply { this.teamModelAliases = teamModelAliases } @@ -2318,6 +3470,27 @@ private constructor( } } + fun teamObjectPermissionId(teamObjectPermissionId: String?) = + teamObjectPermissionId(JsonField.ofNullable(teamObjectPermissionId)) + + /** + * Alias for calling [Builder.teamObjectPermissionId] with + * `teamObjectPermissionId.orElse(null)`. + */ + fun teamObjectPermissionId(teamObjectPermissionId: Optional) = + teamObjectPermissionId(teamObjectPermissionId.getOrNull()) + + /** + * Sets [Builder.teamObjectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.teamObjectPermissionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun teamObjectPermissionId(teamObjectPermissionId: JsonField) = apply { + this.teamObjectPermissionId = teamObjectPermissionId + } + fun teamRpmLimit(teamRpmLimit: Long?) = teamRpmLimit(JsonField.ofNullable(teamRpmLimit)) @@ -2463,6 +3636,8 @@ private constructor( */ fun updatedBy(updatedBy: JsonField) = apply { this.updatedBy = updatedBy } + fun user(user: JsonValue) = apply { this.user = user } + fun userEmail(userEmail: String?) = userEmail(JsonField.ofNullable(userEmail)) /** Alias for calling [Builder.userEmail] with `userEmail.orElse(null)`. */ @@ -2491,6 +3666,31 @@ private constructor( */ fun userId(userId: JsonField) = apply { this.userId = userId } + fun userMaxBudget(userMaxBudget: Double?) = + userMaxBudget(JsonField.ofNullable(userMaxBudget)) + + /** + * Alias for [Builder.userMaxBudget]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userMaxBudget(userMaxBudget: Double) = userMaxBudget(userMaxBudget as Double?) + + /** Alias for calling [Builder.userMaxBudget] with `userMaxBudget.orElse(null)`. */ + fun userMaxBudget(userMaxBudget: Optional) = + userMaxBudget(userMaxBudget.getOrNull()) + + /** + * Sets [Builder.userMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.userMaxBudget] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun userMaxBudget(userMaxBudget: JsonField) = apply { + this.userMaxBudget = userMaxBudget + } + /** * Admin Roles: PROXY_ADMIN: admin over the platform PROXY_ADMIN_VIEW_ONLY: can * login, view all own keys, view all spend ORG_ADMIN: admin over a specific @@ -2504,19 +3704,19 @@ private constructor( * * Customer Roles: CUSTOMER: External users -> these are customers */ - fun userRole(userRole: UserRole?) = userRole(JsonField.ofNullable(userRole)) + fun userRole(userRole: UserRoles?) = userRole(JsonField.ofNullable(userRole)) /** Alias for calling [Builder.userRole] with `userRole.orElse(null)`. */ - fun userRole(userRole: Optional) = userRole(userRole.getOrNull()) + fun userRole(userRole: Optional) = userRole(userRole.getOrNull()) /** * Sets [Builder.userRole] to an arbitrary JSON value. * - * You should usually call [Builder.userRole] with a well-typed [UserRole] value + * You should usually call [Builder.userRole] with a well-typed [UserRoles] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun userRole(userRole: JsonField) = apply { this.userRole = userRole } + fun userRole(userRole: JsonField) = apply { this.userRole = userRole } fun userRpmLimit(userRpmLimit: Long?) = userRpmLimit(JsonField.ofNullable(userRpmLimit)) @@ -2543,6 +3743,27 @@ private constructor( this.userRpmLimit = userRpmLimit } + fun userSpend(userSpend: Double?) = userSpend(JsonField.ofNullable(userSpend)) + + /** + * Alias for [Builder.userSpend]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userSpend(userSpend: Double) = userSpend(userSpend as Double?) + + /** Alias for calling [Builder.userSpend] with `userSpend.orElse(null)`. */ + fun userSpend(userSpend: Optional) = userSpend(userSpend.getOrNull()) + + /** + * Sets [Builder.userSpend] to an arbitrary JSON value. + * + * You should usually call [Builder.userSpend] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun userSpend(userSpend: JsonField) = apply { this.userSpend = userSpend } + fun userTpmLimit(userTpmLimit: Long?) = userTpmLimit(JsonField.ofNullable(userTpmLimit)) @@ -2601,7 +3822,9 @@ private constructor( aliases, (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, allowedModelRegion, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, apiKey, + autoRotate, blocked, budgetDuration, budgetResetAt, @@ -2615,17 +3838,29 @@ private constructor( expires, keyAlias, keyName, + keyRotationAt, lastRefreshedAt, - llmBudgetTable, + lastRotationAt, + litellmBudgetTable, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelSpend, (models ?: JsonMissing.of()).map { it.toImmutable() }, + objectPermission, + objectPermissionId, orgId, + organizationMaxBudget, + organizationMetadata, + organizationRpmLimit, + organizationTpmLimit, parentOtelSpan, permissions, + requestRoute, + rotationCount, + rotationInterval, + routerSettings, rpmLimit, rpmLimitPerModel, softBudget, @@ -2636,10 +3871,13 @@ private constructor( teamId, teamMaxBudget, teamMember, + teamMemberRpmLimit, teamMemberSpend, + teamMemberTpmLimit, teamMetadata, teamModelAliases, (teamModels ?: JsonMissing.of()).map { it.toImmutable() }, + teamObjectPermissionId, teamRpmLimit, teamSpend, teamTpmLimit, @@ -2647,10 +3885,13 @@ private constructor( tpmLimitPerModel, updatedAt, updatedBy, + user, userEmail, userId, + userMaxBudget, userRole, userRpmLimit, + userSpend, userTpmLimit, additionalProperties.toMutableMap(), ) @@ -2664,12 +3905,16 @@ private constructor( } token() + aliases().ifPresent { it.validate() } allowedCacheControls() allowedModelRegion().ifPresent { it.validate() } + allowedRoutes() apiKey() + autoRotate() blocked() budgetDuration() budgetResetAt() + config().ifPresent { it.validate() } createdAt() createdBy() endUserId() @@ -2679,11 +3924,28 @@ private constructor( expires().ifPresent { it.validate() } keyAlias() keyName() + keyRotationAt() lastRefreshedAt() + lastRotationAt() + litellmBudgetTable().ifPresent { it.validate() } maxBudget() maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelSpend().ifPresent { it.validate() } models() + objectPermission().ifPresent { it.validate() } + objectPermissionId() orgId() + organizationMaxBudget() + organizationMetadata().ifPresent { it.validate() } + organizationRpmLimit() + organizationTpmLimit() + permissions().ifPresent { it.validate() } + requestRoute() + rotationCount() + rotationInterval() + routerSettings().ifPresent { it.validate() } rpmLimit() rpmLimitPerModel().ifPresent { it.validate() } softBudget() @@ -2694,8 +3956,13 @@ private constructor( teamId() teamMaxBudget() teamMember().ifPresent { it.validate() } + teamMemberRpmLimit() teamMemberSpend() + teamMemberTpmLimit() + teamMetadata().ifPresent { it.validate() } + teamModelAliases().ifPresent { it.validate() } teamModels() + teamObjectPermissionId() teamRpmLimit() teamSpend() teamTpmLimit() @@ -2705,8 +3972,10 @@ private constructor( updatedBy() userEmail() userId() + userMaxBudget() userRole().ifPresent { it.validate() } userRpmLimit() + userSpend() userTpmLimit() validated = true } @@ -2728,12 +3997,16 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + (allowedModelRegion.asKnown().getOrNull()?.validity() ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (createdBy.asKnown().isPresent) 1 else 0) + (if (endUserId.asKnown().isPresent) 1 else 0) + @@ -2743,11 +4016,28 @@ private constructor( (expires.asKnown().getOrNull()?.validity() ?: 0) + (if (keyAlias.asKnown().isPresent) 1 else 0) + (if (keyName.asKnown().isPresent) 1 else 0) + + (if (keyRotationAt.asKnown().isPresent) 1 else 0) + (if (lastRefreshedAt.asKnown().isPresent) 1 else 0) + + (if (lastRotationAt.asKnown().isPresent) 1 else 0) + + (litellmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelSpend.asKnown().getOrNull()?.validity() ?: 0) + (models.asKnown().getOrNull()?.size ?: 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (if (objectPermissionId.asKnown().isPresent) 1 else 0) + (if (orgId.asKnown().isPresent) 1 else 0) + + (if (organizationMaxBudget.asKnown().isPresent) 1 else 0) + + (organizationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationRpmLimit.asKnown().isPresent) 1 else 0) + + (if (organizationTpmLimit.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (if (requestRoute.asKnown().isPresent) 1 else 0) + + (if (rotationCount.asKnown().isPresent) 1 else 0) + + (if (rotationInterval.asKnown().isPresent) 1 else 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + (rpmLimitPerModel.asKnown().getOrNull()?.validity() ?: 0) + (if (softBudget.asKnown().isPresent) 1 else 0) + @@ -2758,8 +4048,13 @@ private constructor( (if (teamId.asKnown().isPresent) 1 else 0) + (if (teamMaxBudget.asKnown().isPresent) 1 else 0) + (teamMember.asKnown().getOrNull()?.validity() ?: 0) + + (if (teamMemberRpmLimit.asKnown().isPresent) 1 else 0) + (if (teamMemberSpend.asKnown().isPresent) 1 else 0) + + (if (teamMemberTpmLimit.asKnown().isPresent) 1 else 0) + + (teamMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (teamModelAliases.asKnown().getOrNull()?.validity() ?: 0) + (teamModels.asKnown().getOrNull()?.size ?: 0) + + (if (teamObjectPermissionId.asKnown().isPresent) 1 else 0) + (if (teamRpmLimit.asKnown().isPresent) 1 else 0) + (if (teamSpend.asKnown().isPresent) 1 else 0) + (if (teamTpmLimit.asKnown().isPresent) 1 else 0) + @@ -2769,64 +4064,170 @@ private constructor( (if (updatedBy.asKnown().isPresent) 1 else 0) + (if (userEmail.asKnown().isPresent) 1 else 0) + (if (userId.asKnown().isPresent) 1 else 0) + + (if (userMaxBudget.asKnown().isPresent) 1 else 0) + (userRole.asKnown().getOrNull()?.validity() ?: 0) + (if (userRpmLimit.asKnown().isPresent) 1 else 0) + + (if (userSpend.asKnown().isPresent) 1 else 0) + (if (userTpmLimit.asKnown().isPresent) 1 else 0) - class AllowedModelRegion + class Aliases @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmField val EU = of("eu") + fun toBuilder() = Builder().from(this) - @JvmField val US = of("us") + companion object { - @JvmStatic fun of(value: String) = AllowedModelRegion(JsonField.of(value)) + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [AllowedModelRegion]'s known values. */ - enum class Known { - EU, - US, - } + /** A builder for [Aliases]. */ + class Builder internal constructor() { - /** - * An enum containing [AllowedModelRegion]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AllowedModelRegion] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EU, - US, - /** - * An enum member indicating that [AllowedModelRegion] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class AllowedModelRegion + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EU = of("eu") + + @JvmField val US = of("us") + + @JvmStatic fun of(value: String) = AllowedModelRegion(JsonField.of(value)) + } + + /** An enum containing [AllowedModelRegion]'s known values. */ + enum class Known { + EU, + US, + } + + /** + * An enum containing [AllowedModelRegion]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AllowedModelRegion] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EU, + US, + /** + * An enum member indicating that [AllowedModelRegion] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * * Use the [known] method instead if you're certain the value is always known or if * you want to throw for the unknown case. */ @@ -2908,6 +4309,110 @@ private constructor( override fun toString() = value.toString() } + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Expires.Deserializer::class) @JsonSerialize(using = Expires.Serializer::class) class Expires @@ -3042,12 +4547,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Expires(string = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Expires(offsetDateTime = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -3055,7 +4560,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> Expires(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -3084,7 +4589,7 @@ private constructor( } } - class RpmLimitPerModel + class LitellmBudgetTable @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -3100,19 +4605,21 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [RpmLimitPerModel]. + * Returns a mutable builder for constructing an instance of + * [LitellmBudgetTable]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RpmLimitPerModel]. */ + /** A builder for [LitellmBudgetTable]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(rpmLimitPerModel: RpmLimitPerModel) = apply { - additionalProperties = rpmLimitPerModel.additionalProperties.toMutableMap() + internal fun from(litellmBudgetTable: LitellmBudgetTable) = apply { + additionalProperties = + litellmBudgetTable.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -3138,17 +4645,17 @@ private constructor( } /** - * Returns an immutable instance of [RpmLimitPerModel]. + * Returns an immutable instance of [LitellmBudgetTable]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): RpmLimitPerModel = - RpmLimitPerModel(additionalProperties.toImmutable()) + fun build(): LitellmBudgetTable = + LitellmBudgetTable(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): RpmLimitPerModel = apply { + fun validate(): LitellmBudgetTable = apply { if (validated) { return@apply } @@ -3181,7 +4688,7 @@ private constructor( return true } - return other is RpmLimitPerModel && + return other is LitellmBudgetTable && additionalProperties == other.additionalProperties } @@ -3190,10 +4697,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RpmLimitPerModel{additionalProperties=$additionalProperties}" + "LitellmBudgetTable{additionalProperties=$additionalProperties}" } - class TpmLimitPerModel + class Metadata @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -3208,20 +4715,18 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [TpmLimitPerModel]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [TpmLimitPerModel]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tpmLimitPerModel: TpmLimitPerModel) = apply { - additionalProperties = tpmLimitPerModel.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -3247,17 +4752,16 @@ private constructor( } /** - * Returns an immutable instance of [TpmLimitPerModel]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): TpmLimitPerModel = - TpmLimitPerModel(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): TpmLimitPerModel = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -3290,160 +4794,5412 @@ private constructor( return true } - return other is TpmLimitPerModel && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "TpmLimitPerModel{additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** - * Admin Roles: PROXY_ADMIN: admin over the platform PROXY_ADMIN_VIEW_ONLY: can login, - * view all own keys, view all spend ORG_ADMIN: admin over a specific organization, can - * create teams, users only within their organization + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ModelMaxBudget]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelSpend + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelSpend]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelSpend]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelSpend: ModelSpend) = apply { + additionalProperties = modelSpend.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelSpend]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelSpend = ModelSpend(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelSpend = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelSpend && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelSpend{additionalProperties=$additionalProperties}" + } + + /** Represents a LiteLLM_ObjectPermissionTable record */ + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val objectPermissionId: JsonField, + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("object_permission_id") + @ExcludeMissing + objectPermissionId: JsonField = JsonMissing.of(), + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + objectPermissionId, + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun objectPermissionId(): String = + objectPermissionId.getRequired("object_permission_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun vectorStores(): Optional> = + vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [objectPermissionId]. + * + * Unlike [objectPermissionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("object_permission_id") + @ExcludeMissing + fun _objectPermissionId(): JsonField = objectPermissionId + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agents") + @ExcludeMissing + fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ObjectPermission]. + * + * The following fields are required: + * ```java + * .objectPermissionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var objectPermissionId: JsonField? = null + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + objectPermissionId = objectPermission.objectPermissionId + agentAccessGroups = + objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = + objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun objectPermissionId(objectPermissionId: String) = + objectPermissionId(JsonField.of(objectPermissionId)) + + /** + * Sets [Builder.objectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermissionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun objectPermissionId(objectPermissionId: JsonField) = apply { + this.objectPermissionId = objectPermissionId + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with + * `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** + * Alias for calling [Builder.mcpAccessGroups] with + * `mcpAccessGroups.orElse(null)`. + */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = + mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = + mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = + apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** + * Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. + */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectPermissionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ObjectPermission = + ObjectPermission( + checkRequired("objectPermissionId", objectPermissionId), + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + objectPermissionId() + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (objectPermissionId.asKnown().isPresent) 1 else 0) + + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = + mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + objectPermissionId == other.objectPermissionId && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + objectPermissionId, + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{objectPermissionId=$objectPermissionId, agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class OrganizationMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationMetadata: OrganizationMetadata) = apply { + additionalProperties = + organizationMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrganizationMetadata = + OrganizationMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OrganizationMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationMetadata{additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + class RouterSettings + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RouterSettings]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + additionalProperties = routerSettings.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = RouterSettings(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RouterSettings = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouterSettings && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouterSettings{additionalProperties=$additionalProperties}" + } + + class RpmLimitPerModel + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RpmLimitPerModel]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RpmLimitPerModel]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rpmLimitPerModel: RpmLimitPerModel) = apply { + additionalProperties = rpmLimitPerModel.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RpmLimitPerModel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RpmLimitPerModel = + RpmLimitPerModel(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RpmLimitPerModel = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RpmLimitPerModel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RpmLimitPerModel{additionalProperties=$additionalProperties}" + } + + class TeamMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TeamMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TeamMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(teamMetadata: TeamMetadata) = apply { + additionalProperties = teamMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TeamMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TeamMetadata = TeamMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): TeamMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TeamMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TeamMetadata{additionalProperties=$additionalProperties}" + } + + class TeamModelAliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TeamModelAliases]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TeamModelAliases]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(teamModelAliases: TeamModelAliases) = apply { + additionalProperties = teamModelAliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TeamModelAliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TeamModelAliases = + TeamModelAliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): TeamModelAliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TeamModelAliases && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TeamModelAliases{additionalProperties=$additionalProperties}" + } + + class TpmLimitPerModel + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TpmLimitPerModel]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TpmLimitPerModel]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tpmLimitPerModel: TpmLimitPerModel) = apply { + additionalProperties = tpmLimitPerModel.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TpmLimitPerModel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TpmLimitPerModel = + TpmLimitPerModel(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): TpmLimitPerModel = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TpmLimitPerModel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TpmLimitPerModel{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserApiKeyAuth && + token == other.token && + aliases == other.aliases && + allowedCacheControls == other.allowedCacheControls && + allowedModelRegion == other.allowedModelRegion && + allowedRoutes == other.allowedRoutes && + apiKey == other.apiKey && + autoRotate == other.autoRotate && + blocked == other.blocked && + budgetDuration == other.budgetDuration && + budgetResetAt == other.budgetResetAt && + config == other.config && + createdAt == other.createdAt && + createdBy == other.createdBy && + endUserId == other.endUserId && + endUserMaxBudget == other.endUserMaxBudget && + endUserRpmLimit == other.endUserRpmLimit && + endUserTpmLimit == other.endUserTpmLimit && + expires == other.expires && + keyAlias == other.keyAlias && + keyName == other.keyName && + keyRotationAt == other.keyRotationAt && + lastRefreshedAt == other.lastRefreshedAt && + lastRotationAt == other.lastRotationAt && + litellmBudgetTable == other.litellmBudgetTable && + maxBudget == other.maxBudget && + maxParallelRequests == other.maxParallelRequests && + metadata == other.metadata && + modelMaxBudget == other.modelMaxBudget && + modelSpend == other.modelSpend && + models == other.models && + objectPermission == other.objectPermission && + objectPermissionId == other.objectPermissionId && + orgId == other.orgId && + organizationMaxBudget == other.organizationMaxBudget && + organizationMetadata == other.organizationMetadata && + organizationRpmLimit == other.organizationRpmLimit && + organizationTpmLimit == other.organizationTpmLimit && + parentOtelSpan == other.parentOtelSpan && + permissions == other.permissions && + requestRoute == other.requestRoute && + rotationCount == other.rotationCount && + rotationInterval == other.rotationInterval && + routerSettings == other.routerSettings && + rpmLimit == other.rpmLimit && + rpmLimitPerModel == other.rpmLimitPerModel && + softBudget == other.softBudget && + softBudgetCooldown == other.softBudgetCooldown && + spend == other.spend && + teamAlias == other.teamAlias && + teamBlocked == other.teamBlocked && + teamId == other.teamId && + teamMaxBudget == other.teamMaxBudget && + teamMember == other.teamMember && + teamMemberRpmLimit == other.teamMemberRpmLimit && + teamMemberSpend == other.teamMemberSpend && + teamMemberTpmLimit == other.teamMemberTpmLimit && + teamMetadata == other.teamMetadata && + teamModelAliases == other.teamModelAliases && + teamModels == other.teamModels && + teamObjectPermissionId == other.teamObjectPermissionId && + teamRpmLimit == other.teamRpmLimit && + teamSpend == other.teamSpend && + teamTpmLimit == other.teamTpmLimit && + tpmLimit == other.tpmLimit && + tpmLimitPerModel == other.tpmLimitPerModel && + updatedAt == other.updatedAt && + updatedBy == other.updatedBy && + user == other.user && + userEmail == other.userEmail && + userId == other.userId && + userMaxBudget == other.userMaxBudget && + userRole == other.userRole && + userRpmLimit == other.userRpmLimit && + userSpend == other.userSpend && + userTpmLimit == other.userTpmLimit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + aliases, + allowedCacheControls, + allowedModelRegion, + allowedRoutes, + apiKey, + autoRotate, + blocked, + budgetDuration, + budgetResetAt, + config, + createdAt, + createdBy, + endUserId, + endUserMaxBudget, + endUserRpmLimit, + endUserTpmLimit, + expires, + keyAlias, + keyName, + keyRotationAt, + lastRefreshedAt, + lastRotationAt, + litellmBudgetTable, + maxBudget, + maxParallelRequests, + metadata, + modelMaxBudget, + modelSpend, + models, + objectPermission, + objectPermissionId, + orgId, + organizationMaxBudget, + organizationMetadata, + organizationRpmLimit, + organizationTpmLimit, + parentOtelSpan, + permissions, + requestRoute, + rotationCount, + rotationInterval, + routerSettings, + rpmLimit, + rpmLimitPerModel, + softBudget, + softBudgetCooldown, + spend, + teamAlias, + teamBlocked, + teamId, + teamMaxBudget, + teamMember, + teamMemberRpmLimit, + teamMemberSpend, + teamMemberTpmLimit, + teamMetadata, + teamModelAliases, + teamModels, + teamObjectPermissionId, + teamRpmLimit, + teamSpend, + teamTpmLimit, + tpmLimit, + tpmLimitPerModel, + updatedAt, + updatedBy, + user, + userEmail, + userId, + userMaxBudget, + userRole, + userRpmLimit, + userSpend, + userTpmLimit, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserApiKeyAuth{token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedModelRegion=$allowedModelRegion, allowedRoutes=$allowedRoutes, apiKey=$apiKey, autoRotate=$autoRotate, blocked=$blocked, budgetDuration=$budgetDuration, budgetResetAt=$budgetResetAt, config=$config, createdAt=$createdAt, createdBy=$createdBy, endUserId=$endUserId, endUserMaxBudget=$endUserMaxBudget, endUserRpmLimit=$endUserRpmLimit, endUserTpmLimit=$endUserTpmLimit, expires=$expires, keyAlias=$keyAlias, keyName=$keyName, keyRotationAt=$keyRotationAt, lastRefreshedAt=$lastRefreshedAt, lastRotationAt=$lastRotationAt, litellmBudgetTable=$litellmBudgetTable, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelSpend=$modelSpend, models=$models, objectPermission=$objectPermission, objectPermissionId=$objectPermissionId, orgId=$orgId, organizationMaxBudget=$organizationMaxBudget, organizationMetadata=$organizationMetadata, organizationRpmLimit=$organizationRpmLimit, organizationTpmLimit=$organizationTpmLimit, parentOtelSpan=$parentOtelSpan, permissions=$permissions, requestRoute=$requestRoute, rotationCount=$rotationCount, rotationInterval=$rotationInterval, routerSettings=$routerSettings, rpmLimit=$rpmLimit, rpmLimitPerModel=$rpmLimitPerModel, softBudget=$softBudget, softBudgetCooldown=$softBudgetCooldown, spend=$spend, teamAlias=$teamAlias, teamBlocked=$teamBlocked, teamId=$teamId, teamMaxBudget=$teamMaxBudget, teamMember=$teamMember, teamMemberRpmLimit=$teamMemberRpmLimit, teamMemberSpend=$teamMemberSpend, teamMemberTpmLimit=$teamMemberTpmLimit, teamMetadata=$teamMetadata, teamModelAliases=$teamModelAliases, teamModels=$teamModels, teamObjectPermissionId=$teamObjectPermissionId, teamRpmLimit=$teamRpmLimit, teamSpend=$teamSpend, teamTpmLimit=$teamTpmLimit, tpmLimit=$tpmLimit, tpmLimitPerModel=$tpmLimitPerModel, updatedAt=$updatedAt, updatedBy=$updatedBy, user=$user, userEmail=$userEmail, userId=$userId, userMaxBudget=$userMaxBudget, userRole=$userRole, userRpmLimit=$userRpmLimit, userSpend=$userSpend, userTpmLimit=$userTpmLimit, additionalProperties=$additionalProperties}" + } + + /** + * Recording of deleted keys for audit purposes. Mirrors LiteLLM_VerificationToken plus + * metadata captured at deletion time. + */ + class LiteLlmDeletedVerificationToken + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val token: JsonField, + private val aliases: JsonField, + private val allowedCacheControls: JsonField>, + private val allowedRoutes: JsonField>, + private val autoRotate: JsonField, + private val blocked: JsonField, + private val budgetDuration: JsonField, + private val budgetResetAt: JsonField, + private val config: JsonField, + private val createdAt: JsonField, + private val createdBy: JsonField, + private val deletedAt: JsonField, + private val deletedBy: JsonField, + private val deletedByApiKey: JsonField, + private val expires: JsonField, + private val keyAlias: JsonField, + private val keyName: JsonField, + private val keyRotationAt: JsonField, + private val lastRotationAt: JsonField, + private val litellmBudgetTable: JsonField, + private val litellmChangedBy: JsonField, + private val maxBudget: JsonField, + private val maxParallelRequests: JsonField, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelSpend: JsonField, + private val models: JsonField>, + private val objectPermission: JsonField, + private val objectPermissionId: JsonField, + private val orgId: JsonField, + private val permissions: JsonField, + private val rotationCount: JsonField, + private val rotationInterval: JsonField, + private val routerSettings: JsonField, + private val rpmLimit: JsonField, + private val softBudgetCooldown: JsonField, + private val spend: JsonField, + private val teamId: JsonField, + private val tpmLimit: JsonField, + private val updatedAt: JsonField, + private val updatedBy: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("aliases") + @ExcludeMissing + aliases: JsonField = JsonMissing.of(), + @JsonProperty("allowed_cache_controls") + @ExcludeMissing + allowedCacheControls: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField = JsonMissing.of(), + @JsonProperty("budget_duration") + @ExcludeMissing + budgetDuration: JsonField = JsonMissing.of(), + @JsonProperty("budget_reset_at") + @ExcludeMissing + budgetResetAt: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("deleted_by") + @ExcludeMissing + deletedBy: JsonField = JsonMissing.of(), + @JsonProperty("deleted_by_api_key") + @ExcludeMissing + deletedByApiKey: JsonField = JsonMissing.of(), + @JsonProperty("expires") + @ExcludeMissing + expires: JsonField = JsonMissing.of(), + @JsonProperty("key_alias") + @ExcludeMissing + keyAlias: JsonField = JsonMissing.of(), + @JsonProperty("key_name") + @ExcludeMissing + keyName: JsonField = JsonMissing.of(), + @JsonProperty("key_rotation_at") + @ExcludeMissing + keyRotationAt: JsonField = JsonMissing.of(), + @JsonProperty("last_rotation_at") + @ExcludeMissing + lastRotationAt: JsonField = JsonMissing.of(), + @JsonProperty("litellm_budget_table") + @ExcludeMissing + litellmBudgetTable: JsonField = JsonMissing.of(), + @JsonProperty("litellm_changed_by") + @ExcludeMissing + litellmChangedBy: JsonField = JsonMissing.of(), + @JsonProperty("max_budget") + @ExcludeMissing + maxBudget: JsonField = JsonMissing.of(), + @JsonProperty("max_parallel_requests") + @ExcludeMissing + maxParallelRequests: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("model_max_budget") + @ExcludeMissing + modelMaxBudget: JsonField = JsonMissing.of(), + @JsonProperty("model_spend") + @ExcludeMissing + modelSpend: JsonField = JsonMissing.of(), + @JsonProperty("models") + @ExcludeMissing + models: JsonField> = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("object_permission_id") + @ExcludeMissing + objectPermissionId: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing orgId: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField = JsonMissing.of(), + @JsonProperty("rotation_count") + @ExcludeMissing + rotationCount: JsonField = JsonMissing.of(), + @JsonProperty("rotation_interval") + @ExcludeMissing + rotationInterval: JsonField = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), + @JsonProperty("rpm_limit") + @ExcludeMissing + rpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("soft_budget_cooldown") + @ExcludeMissing + softBudgetCooldown: JsonField = JsonMissing.of(), + @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), + @JsonProperty("team_id") + @ExcludeMissing + teamId: JsonField = JsonMissing.of(), + @JsonProperty("tpm_limit") + @ExcludeMissing + tpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("updated_by") + @ExcludeMissing + updatedBy: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + userId: JsonField = JsonMissing.of(), + ) : this( + id, + token, + aliases, + allowedCacheControls, + allowedRoutes, + autoRotate, + blocked, + budgetDuration, + budgetResetAt, + config, + createdAt, + createdBy, + deletedAt, + deletedBy, + deletedByApiKey, + expires, + keyAlias, + keyName, + keyRotationAt, + lastRotationAt, + litellmBudgetTable, + litellmChangedBy, + maxBudget, + maxParallelRequests, + metadata, + modelMaxBudget, + modelSpend, + models, + objectPermission, + objectPermissionId, + orgId, + permissions, + rotationCount, + rotationInterval, + routerSettings, + rpmLimit, + softBudgetCooldown, + spend, + teamId, + tpmLimit, + updatedAt, + updatedBy, + userId, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowedCacheControls(): Optional> = + allowedCacheControls.getOptional("allowed_cache_controls") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = + allowedRoutes.getOptional("allowed_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun blocked(): Optional = blocked.getOptional("blocked") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun budgetResetAt(): Optional = + budgetResetAt.getOptional("budget_reset_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deletedAt(): Optional = deletedAt.getOptional("deleted_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deletedBy(): Optional = deletedBy.getOptional("deleted_by") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deletedByApiKey(): Optional = + deletedByApiKey.getOptional("deleted_by_api_key") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expires(): Optional = expires.getOptional("expires") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun keyAlias(): Optional = keyAlias.getOptional("key_alias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun keyName(): Optional = keyName.getOptional("key_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun keyRotationAt(): Optional = + keyRotationAt.getOptional("key_rotation_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRotationAt(): Optional = + lastRotationAt.getOptional("last_rotation_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun litellmBudgetTable(): Optional = + litellmBudgetTable.getOptional("litellm_budget_table") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun litellmChangedBy(): Optional = + litellmChangedBy.getOptional("litellm_changed_by") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxParallelRequests(): Optional = + maxParallelRequests.getOptional("max_parallel_requests") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = + modelMaxBudget.getOptional("model_max_budget") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelSpend(): Optional = modelSpend.getOptional("model_spend") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun models(): Optional> = models.getOptional("models") + + /** + * Represents a LiteLLM_ObjectPermissionTable record + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectPermissionId(): Optional = + objectPermissionId.getOptional("object_permission_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgId(): Optional = orgId.getOptional("org_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rotationCount(): Optional = rotationCount.getOptional("rotation_count") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rotationInterval(): Optional = + rotationInterval.getOptional("rotation_interval") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun routerSettings(): Optional = + routerSettings.getOptional("router_settings") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun softBudgetCooldown(): Optional = + softBudgetCooldown.getOptional("soft_budget_cooldown") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun spend(): Optional = spend.getOptional("spend") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun teamId(): Optional = teamId.getOptional("team_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedBy(): Optional = updatedBy.getOptional("updated_by") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("user_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + + /** + * Returns the raw JSON value of [allowedCacheControls]. + * + * Unlike [allowedCacheControls], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_cache_controls") + @ExcludeMissing + fun _allowedCacheControls(): JsonField> = allowedCacheControls + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") @ExcludeMissing fun _blocked(): JsonField = blocked + + /** + * Returns the raw JSON value of [budgetDuration]. + * + * Unlike [budgetDuration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("budget_duration") + @ExcludeMissing + fun _budgetDuration(): JsonField = budgetDuration + + /** + * Returns the raw JSON value of [budgetResetAt]. * - * Internal User Roles: INTERNAL_USER: can login, view/create/delete their own keys, - * view their spend INTERNAL_USER_VIEW_ONLY: can login, view their own keys, view their - * own spend + * Unlike [budgetResetAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("budget_reset_at") + @ExcludeMissing + fun _budgetResetAt(): JsonField = budgetResetAt + + /** + * Returns the raw JSON value of [config]. * - * Team Roles: TEAM: used for JWT auth + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_by") + @ExcludeMissing + fun _createdBy(): JsonField = createdBy + + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt + + /** + * Returns the raw JSON value of [deletedBy]. + * + * Unlike [deletedBy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deleted_by") + @ExcludeMissing + fun _deletedBy(): JsonField = deletedBy + + /** + * Returns the raw JSON value of [deletedByApiKey]. + * + * Unlike [deletedByApiKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("deleted_by_api_key") + @ExcludeMissing + fun _deletedByApiKey(): JsonField = deletedByApiKey + + /** + * Returns the raw JSON value of [expires]. + * + * Unlike [expires], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires") @ExcludeMissing fun _expires(): JsonField = expires + + /** + * Returns the raw JSON value of [keyAlias]. + * + * Unlike [keyAlias], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("key_alias") @ExcludeMissing fun _keyAlias(): JsonField = keyAlias + + /** + * Returns the raw JSON value of [keyName]. + * + * Unlike [keyName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key_name") @ExcludeMissing fun _keyName(): JsonField = keyName + + /** + * Returns the raw JSON value of [keyRotationAt]. + * + * Unlike [keyRotationAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("key_rotation_at") + @ExcludeMissing + fun _keyRotationAt(): JsonField = keyRotationAt + + /** + * Returns the raw JSON value of [lastRotationAt]. + * + * Unlike [lastRotationAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("last_rotation_at") + @ExcludeMissing + fun _lastRotationAt(): JsonField = lastRotationAt + + /** + * Returns the raw JSON value of [litellmBudgetTable]. + * + * Unlike [litellmBudgetTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("litellm_budget_table") + @ExcludeMissing + fun _litellmBudgetTable(): JsonField = litellmBudgetTable + + /** + * Returns the raw JSON value of [litellmChangedBy]. + * + * Unlike [litellmChangedBy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("litellm_changed_by") + @ExcludeMissing + fun _litellmChangedBy(): JsonField = litellmChangedBy + + /** + * Returns the raw JSON value of [maxBudget]. + * + * Unlike [maxBudget], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("max_budget") + @ExcludeMissing + fun _maxBudget(): JsonField = maxBudget + + /** + * Returns the raw JSON value of [maxParallelRequests]. + * + * Unlike [maxParallelRequests], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_parallel_requests") + @ExcludeMissing + fun _maxParallelRequests(): JsonField = maxParallelRequests + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget + + /** + * Returns the raw JSON value of [modelSpend]. + * + * Unlike [modelSpend], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_spend") + @ExcludeMissing + fun _modelSpend(): JsonField = modelSpend + + /** + * Returns the raw JSON value of [models]. + * + * Unlike [models], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("models") + @ExcludeMissing + fun _models(): JsonField> = models + + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("object_permission") + @ExcludeMissing + fun _objectPermission(): JsonField = objectPermission + + /** + * Returns the raw JSON value of [objectPermissionId]. + * + * Unlike [objectPermissionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("object_permission_id") + @ExcludeMissing + fun _objectPermissionId(): JsonField = objectPermissionId + + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [rotationCount]. + * + * Unlike [rotationCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rotation_count") + @ExcludeMissing + fun _rotationCount(): JsonField = rotationCount + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rotation_interval") + @ExcludeMissing + fun _rotationInterval(): JsonField = rotationInterval + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + + /** + * Returns the raw JSON value of [rpmLimit]. + * + * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + + /** + * Returns the raw JSON value of [softBudgetCooldown]. + * + * Unlike [softBudgetCooldown], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("soft_budget_cooldown") + @ExcludeMissing + fun _softBudgetCooldown(): JsonField = softBudgetCooldown + + /** + * Returns the raw JSON value of [spend]. + * + * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend + + /** + * Returns the raw JSON value of [teamId]. + * + * Unlike [teamId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("team_id") @ExcludeMissing fun _teamId(): JsonField = teamId + + /** + * Returns the raw JSON value of [tpmLimit]. + * + * Unlike [tpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [updatedBy]. + * + * Unlike [updatedBy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("updated_by") + @ExcludeMissing + fun _updatedBy(): JsonField = updatedBy + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LiteLlmDeletedVerificationToken]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LiteLlmDeletedVerificationToken]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var token: JsonField = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() + private var allowedCacheControls: JsonField>? = null + private var allowedRoutes: JsonField>? = null + private var autoRotate: JsonField = JsonMissing.of() + private var blocked: JsonField = JsonMissing.of() + private var budgetDuration: JsonField = JsonMissing.of() + private var budgetResetAt: JsonField = JsonMissing.of() + private var config: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var createdBy: JsonField = JsonMissing.of() + private var deletedAt: JsonField = JsonMissing.of() + private var deletedBy: JsonField = JsonMissing.of() + private var deletedByApiKey: JsonField = JsonMissing.of() + private var expires: JsonField = JsonMissing.of() + private var keyAlias: JsonField = JsonMissing.of() + private var keyName: JsonField = JsonMissing.of() + private var keyRotationAt: JsonField = JsonMissing.of() + private var lastRotationAt: JsonField = JsonMissing.of() + private var litellmBudgetTable: JsonField = JsonMissing.of() + private var litellmChangedBy: JsonField = JsonMissing.of() + private var maxBudget: JsonField = JsonMissing.of() + private var maxParallelRequests: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelSpend: JsonField = JsonMissing.of() + private var models: JsonField>? = null + private var objectPermission: JsonField = JsonMissing.of() + private var objectPermissionId: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var rotationCount: JsonField = JsonMissing.of() + private var rotationInterval: JsonField = JsonMissing.of() + private var routerSettings: JsonField = JsonMissing.of() + private var rpmLimit: JsonField = JsonMissing.of() + private var softBudgetCooldown: JsonField = JsonMissing.of() + private var spend: JsonField = JsonMissing.of() + private var teamId: JsonField = JsonMissing.of() + private var tpmLimit: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var updatedBy: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + liteLlmDeletedVerificationToken: LiteLlmDeletedVerificationToken + ) = apply { + id = liteLlmDeletedVerificationToken.id + token = liteLlmDeletedVerificationToken.token + aliases = liteLlmDeletedVerificationToken.aliases + allowedCacheControls = + liteLlmDeletedVerificationToken.allowedCacheControls.map { + it.toMutableList() + } + allowedRoutes = + liteLlmDeletedVerificationToken.allowedRoutes.map { it.toMutableList() } + autoRotate = liteLlmDeletedVerificationToken.autoRotate + blocked = liteLlmDeletedVerificationToken.blocked + budgetDuration = liteLlmDeletedVerificationToken.budgetDuration + budgetResetAt = liteLlmDeletedVerificationToken.budgetResetAt + config = liteLlmDeletedVerificationToken.config + createdAt = liteLlmDeletedVerificationToken.createdAt + createdBy = liteLlmDeletedVerificationToken.createdBy + deletedAt = liteLlmDeletedVerificationToken.deletedAt + deletedBy = liteLlmDeletedVerificationToken.deletedBy + deletedByApiKey = liteLlmDeletedVerificationToken.deletedByApiKey + expires = liteLlmDeletedVerificationToken.expires + keyAlias = liteLlmDeletedVerificationToken.keyAlias + keyName = liteLlmDeletedVerificationToken.keyName + keyRotationAt = liteLlmDeletedVerificationToken.keyRotationAt + lastRotationAt = liteLlmDeletedVerificationToken.lastRotationAt + litellmBudgetTable = liteLlmDeletedVerificationToken.litellmBudgetTable + litellmChangedBy = liteLlmDeletedVerificationToken.litellmChangedBy + maxBudget = liteLlmDeletedVerificationToken.maxBudget + maxParallelRequests = liteLlmDeletedVerificationToken.maxParallelRequests + metadata = liteLlmDeletedVerificationToken.metadata + modelMaxBudget = liteLlmDeletedVerificationToken.modelMaxBudget + modelSpend = liteLlmDeletedVerificationToken.modelSpend + models = liteLlmDeletedVerificationToken.models.map { it.toMutableList() } + objectPermission = liteLlmDeletedVerificationToken.objectPermission + objectPermissionId = liteLlmDeletedVerificationToken.objectPermissionId + orgId = liteLlmDeletedVerificationToken.orgId + permissions = liteLlmDeletedVerificationToken.permissions + rotationCount = liteLlmDeletedVerificationToken.rotationCount + rotationInterval = liteLlmDeletedVerificationToken.rotationInterval + routerSettings = liteLlmDeletedVerificationToken.routerSettings + rpmLimit = liteLlmDeletedVerificationToken.rpmLimit + softBudgetCooldown = liteLlmDeletedVerificationToken.softBudgetCooldown + spend = liteLlmDeletedVerificationToken.spend + teamId = liteLlmDeletedVerificationToken.teamId + tpmLimit = liteLlmDeletedVerificationToken.tpmLimit + updatedAt = liteLlmDeletedVerificationToken.updatedAt + updatedBy = liteLlmDeletedVerificationToken.updatedBy + userId = liteLlmDeletedVerificationToken.userId + additionalProperties = + liteLlmDeletedVerificationToken.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun token(token: String?) = token(JsonField.ofNullable(token)) + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun aliases(aliases: Aliases) = aliases(JsonField.of(aliases)) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } + + fun allowedCacheControls(allowedCacheControls: List?) = + allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) + + /** + * Alias for calling [Builder.allowedCacheControls] with + * `allowedCacheControls.orElse(null)`. + */ + fun allowedCacheControls(allowedCacheControls: Optional>) = + allowedCacheControls(allowedCacheControls.getOrNull()) + + /** + * Sets [Builder.allowedCacheControls] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedCacheControls] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun allowedCacheControls(allowedCacheControls: JsonField>) = apply { + this.allowedCacheControls = allowedCacheControls.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedCacheControls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedCacheControl(allowedCacheControl: JsonValue) = apply { + allowedCacheControls = + (allowedCacheControls ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedCacheControls", it).add(allowedCacheControl) + } + } + + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } + + fun autoRotate(autoRotate: Boolean?) = autoRotate(JsonField.ofNullable(autoRotate)) + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { + this.autoRotate = autoRotate + } + + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) + + /** + * Alias for [Builder.blocked]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun blocked(blocked: Boolean) = blocked(blocked as Boolean?) + + /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ + fun blocked(blocked: Optional) = blocked(blocked.getOrNull()) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField) = apply { this.blocked = blocked } + + fun budgetDuration(budgetDuration: String?) = + budgetDuration(JsonField.ofNullable(budgetDuration)) + + /** + * Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. + */ + fun budgetDuration(budgetDuration: Optional) = + budgetDuration(budgetDuration.getOrNull()) + + /** + * Sets [Builder.budgetDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetDuration] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun budgetDuration(budgetDuration: JsonField) = apply { + this.budgetDuration = budgetDuration + } + + fun budgetResetAt(budgetResetAt: OffsetDateTime?) = + budgetResetAt(JsonField.ofNullable(budgetResetAt)) + + /** Alias for calling [Builder.budgetResetAt] with `budgetResetAt.orElse(null)`. */ + fun budgetResetAt(budgetResetAt: Optional) = + budgetResetAt(budgetResetAt.getOrNull()) + + /** + * Sets [Builder.budgetResetAt] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetResetAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun budgetResetAt(budgetResetAt: JsonField) = apply { + this.budgetResetAt = budgetResetAt + } + + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + fun createdAt(createdAt: OffsetDateTime?) = + createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = + createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun createdBy(createdBy: String?) = createdBy(JsonField.ofNullable(createdBy)) + + /** Alias for calling [Builder.createdBy] with `createdBy.orElse(null)`. */ + fun createdBy(createdBy: Optional) = createdBy(createdBy.getOrNull()) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + + fun deletedAt(deletedAt: OffsetDateTime?) = + deletedAt(JsonField.ofNullable(deletedAt)) + + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ + fun deletedAt(deletedAt: Optional) = + deletedAt(deletedAt.getOrNull()) + + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } + + fun deletedBy(deletedBy: String?) = deletedBy(JsonField.ofNullable(deletedBy)) + + /** Alias for calling [Builder.deletedBy] with `deletedBy.orElse(null)`. */ + fun deletedBy(deletedBy: Optional) = deletedBy(deletedBy.getOrNull()) + + /** + * Sets [Builder.deletedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun deletedBy(deletedBy: JsonField) = apply { this.deletedBy = deletedBy } + + fun deletedByApiKey(deletedByApiKey: String?) = + deletedByApiKey(JsonField.ofNullable(deletedByApiKey)) + + /** + * Alias for calling [Builder.deletedByApiKey] with `deletedByApiKey.orElse(null)`. + */ + fun deletedByApiKey(deletedByApiKey: Optional) = + deletedByApiKey(deletedByApiKey.getOrNull()) + + /** + * Sets [Builder.deletedByApiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedByApiKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun deletedByApiKey(deletedByApiKey: JsonField) = apply { + this.deletedByApiKey = deletedByApiKey + } + + fun expires(expires: Expires?) = expires(JsonField.ofNullable(expires)) + + /** Alias for calling [Builder.expires] with `expires.orElse(null)`. */ + fun expires(expires: Optional) = expires(expires.getOrNull()) + + /** + * Sets [Builder.expires] to an arbitrary JSON value. + * + * You should usually call [Builder.expires] with a well-typed [Expires] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun expires(expires: JsonField) = apply { this.expires = expires } + + /** Alias for calling [expires] with `Expires.ofString(string)`. */ + fun expires(string: String) = expires(Expires.ofString(string)) + + /** Alias for calling [expires] with `Expires.ofOffsetDateTime(offsetDateTime)`. */ + fun expires(offsetDateTime: OffsetDateTime) = + expires(Expires.ofOffsetDateTime(offsetDateTime)) + + fun keyAlias(keyAlias: String?) = keyAlias(JsonField.ofNullable(keyAlias)) + + /** Alias for calling [Builder.keyAlias] with `keyAlias.orElse(null)`. */ + fun keyAlias(keyAlias: Optional) = keyAlias(keyAlias.getOrNull()) + + /** + * Sets [Builder.keyAlias] to an arbitrary JSON value. + * + * You should usually call [Builder.keyAlias] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun keyAlias(keyAlias: JsonField) = apply { this.keyAlias = keyAlias } + + fun keyName(keyName: String?) = keyName(JsonField.ofNullable(keyName)) + + /** Alias for calling [Builder.keyName] with `keyName.orElse(null)`. */ + fun keyName(keyName: Optional) = keyName(keyName.getOrNull()) + + /** + * Sets [Builder.keyName] to an arbitrary JSON value. + * + * You should usually call [Builder.keyName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun keyName(keyName: JsonField) = apply { this.keyName = keyName } + + fun keyRotationAt(keyRotationAt: OffsetDateTime?) = + keyRotationAt(JsonField.ofNullable(keyRotationAt)) + + /** Alias for calling [Builder.keyRotationAt] with `keyRotationAt.orElse(null)`. */ + fun keyRotationAt(keyRotationAt: Optional) = + keyRotationAt(keyRotationAt.getOrNull()) + + /** + * Sets [Builder.keyRotationAt] to an arbitrary JSON value. + * + * You should usually call [Builder.keyRotationAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun keyRotationAt(keyRotationAt: JsonField) = apply { + this.keyRotationAt = keyRotationAt + } + + fun lastRotationAt(lastRotationAt: OffsetDateTime?) = + lastRotationAt(JsonField.ofNullable(lastRotationAt)) + + /** + * Alias for calling [Builder.lastRotationAt] with `lastRotationAt.orElse(null)`. + */ + fun lastRotationAt(lastRotationAt: Optional) = + lastRotationAt(lastRotationAt.getOrNull()) + + /** + * Sets [Builder.lastRotationAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRotationAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun lastRotationAt(lastRotationAt: JsonField) = apply { + this.lastRotationAt = lastRotationAt + } + + fun litellmBudgetTable(litellmBudgetTable: LitellmBudgetTable?) = + litellmBudgetTable(JsonField.ofNullable(litellmBudgetTable)) + + /** + * Alias for calling [Builder.litellmBudgetTable] with + * `litellmBudgetTable.orElse(null)`. + */ + fun litellmBudgetTable(litellmBudgetTable: Optional) = + litellmBudgetTable(litellmBudgetTable.getOrNull()) + + /** + * Sets [Builder.litellmBudgetTable] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmBudgetTable] with a well-typed + * [LitellmBudgetTable] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun litellmBudgetTable(litellmBudgetTable: JsonField) = apply { + this.litellmBudgetTable = litellmBudgetTable + } + + fun litellmChangedBy(litellmChangedBy: String?) = + litellmChangedBy(JsonField.ofNullable(litellmChangedBy)) + + /** + * Alias for calling [Builder.litellmChangedBy] with + * `litellmChangedBy.orElse(null)`. + */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) + + /** + * Sets [Builder.litellmChangedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmChangedBy] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun litellmChangedBy(litellmChangedBy: JsonField) = apply { + this.litellmChangedBy = litellmChangedBy + } + + fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) + + /** + * Alias for [Builder.maxBudget]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxBudget(maxBudget: Double) = maxBudget(maxBudget as Double?) + + /** Alias for calling [Builder.maxBudget] with `maxBudget.orElse(null)`. */ + fun maxBudget(maxBudget: Optional) = maxBudget(maxBudget.getOrNull()) + + /** + * Sets [Builder.maxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.maxBudget] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maxBudget(maxBudget: JsonField) = apply { this.maxBudget = maxBudget } + + fun maxParallelRequests(maxParallelRequests: Long?) = + maxParallelRequests(JsonField.ofNullable(maxParallelRequests)) + + /** + * Alias for [Builder.maxParallelRequests]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxParallelRequests(maxParallelRequests: Long) = + maxParallelRequests(maxParallelRequests as Long?) + + /** + * Alias for calling [Builder.maxParallelRequests] with + * `maxParallelRequests.orElse(null)`. + */ + fun maxParallelRequests(maxParallelRequests: Optional) = + maxParallelRequests(maxParallelRequests.getOrNull()) + + /** + * Sets [Builder.maxParallelRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.maxParallelRequests] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun maxParallelRequests(maxParallelRequests: JsonField) = apply { + this.maxParallelRequests = maxParallelRequests + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget) = + modelMaxBudget(JsonField.of(modelMaxBudget)) + + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed + * [ModelMaxBudget] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { + this.modelMaxBudget = modelMaxBudget + } + + fun modelSpend(modelSpend: ModelSpend) = modelSpend(JsonField.of(modelSpend)) + + /** + * Sets [Builder.modelSpend] to an arbitrary JSON value. + * + * You should usually call [Builder.modelSpend] with a well-typed [ModelSpend] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelSpend(modelSpend: JsonField) = apply { + this.modelSpend = modelSpend + } + + fun models(models: List) = models(JsonField.of(models)) + + /** + * Sets [Builder.models] to an arbitrary JSON value. + * + * You should usually call [Builder.models] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun models(models: JsonField>) = apply { + this.models = models.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [models]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addModel(model: JsonValue) = apply { + models = + (models ?: JsonField.of(mutableListOf())).also { + checkKnown("models", it).add(model) + } + } + + /** Represents a LiteLLM_ObjectPermissionTable record */ + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) + + /** + * Alias for calling [Builder.objectPermission] with + * `objectPermission.orElse(null)`. + */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed + * [ObjectPermission] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } + + fun objectPermissionId(objectPermissionId: String?) = + objectPermissionId(JsonField.ofNullable(objectPermissionId)) + + /** + * Alias for calling [Builder.objectPermissionId] with + * `objectPermissionId.orElse(null)`. + */ + fun objectPermissionId(objectPermissionId: Optional) = + objectPermissionId(objectPermissionId.getOrNull()) + + /** + * Sets [Builder.objectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermissionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun objectPermissionId(objectPermissionId: JsonField) = apply { + this.objectPermissionId = objectPermissionId + } + + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) + + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) + + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + + fun permissions(permissions: Permissions) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } + + fun rotationCount(rotationCount: Long?) = + rotationCount(JsonField.ofNullable(rotationCount)) + + /** + * Alias for [Builder.rotationCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rotationCount(rotationCount: Long) = rotationCount(rotationCount as Long?) + + /** Alias for calling [Builder.rotationCount] with `rotationCount.orElse(null)`. */ + fun rotationCount(rotationCount: Optional) = + rotationCount(rotationCount.getOrNull()) + + /** + * Sets [Builder.rotationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rotationCount(rotationCount: JsonField) = apply { + this.rotationCount = rotationCount + } + + fun rotationInterval(rotationInterval: String?) = + rotationInterval(JsonField.ofNullable(rotationInterval)) + + /** + * Alias for calling [Builder.rotationInterval] with + * `rotationInterval.orElse(null)`. + */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + this.rotationInterval = rotationInterval + } + + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** + * Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. + */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed + * [RouterSettings] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } + + fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) + + /** + * Alias for [Builder.rpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rpmLimit(rpmLimit: Long) = rpmLimit(rpmLimit as Long?) + + /** Alias for calling [Builder.rpmLimit] with `rpmLimit.orElse(null)`. */ + fun rpmLimit(rpmLimit: Optional) = rpmLimit(rpmLimit.getOrNull()) + + /** + * Sets [Builder.rpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } + + fun softBudgetCooldown(softBudgetCooldown: Boolean) = + softBudgetCooldown(JsonField.of(softBudgetCooldown)) + + /** + * Sets [Builder.softBudgetCooldown] to an arbitrary JSON value. + * + * You should usually call [Builder.softBudgetCooldown] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun softBudgetCooldown(softBudgetCooldown: JsonField) = apply { + this.softBudgetCooldown = softBudgetCooldown + } + + fun spend(spend: Double) = spend(JsonField.of(spend)) + + /** + * Sets [Builder.spend] to an arbitrary JSON value. + * + * You should usually call [Builder.spend] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun spend(spend: JsonField) = apply { this.spend = spend } + + fun teamId(teamId: String?) = teamId(JsonField.ofNullable(teamId)) + + /** Alias for calling [Builder.teamId] with `teamId.orElse(null)`. */ + fun teamId(teamId: Optional) = teamId(teamId.getOrNull()) + + /** + * Sets [Builder.teamId] to an arbitrary JSON value. + * + * You should usually call [Builder.teamId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun teamId(teamId: JsonField) = apply { this.teamId = teamId } + + fun tpmLimit(tpmLimit: Long?) = tpmLimit(JsonField.ofNullable(tpmLimit)) + + /** + * Alias for [Builder.tpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tpmLimit(tpmLimit: Long) = tpmLimit(tpmLimit as Long?) + + /** Alias for calling [Builder.tpmLimit] with `tpmLimit.orElse(null)`. */ + fun tpmLimit(tpmLimit: Optional) = tpmLimit(tpmLimit.getOrNull()) + + /** + * Sets [Builder.tpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } + + fun updatedAt(updatedAt: OffsetDateTime?) = + updatedAt(JsonField.ofNullable(updatedAt)) + + /** Alias for calling [Builder.updatedAt] with `updatedAt.orElse(null)`. */ + fun updatedAt(updatedAt: Optional) = + updatedAt(updatedAt.getOrNull()) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } + + fun updatedBy(updatedBy: String?) = updatedBy(JsonField.ofNullable(updatedBy)) + + /** Alias for calling [Builder.updatedBy] with `updatedBy.orElse(null)`. */ + fun updatedBy(updatedBy: Optional) = updatedBy(updatedBy.getOrNull()) + + /** + * Sets [Builder.updatedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun updatedBy(updatedBy: JsonField) = apply { this.updatedBy = updatedBy } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LiteLlmDeletedVerificationToken]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LiteLlmDeletedVerificationToken = + LiteLlmDeletedVerificationToken( + id, + token, + aliases, + (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + autoRotate, + blocked, + budgetDuration, + budgetResetAt, + config, + createdAt, + createdBy, + deletedAt, + deletedBy, + deletedByApiKey, + expires, + keyAlias, + keyName, + keyRotationAt, + lastRotationAt, + litellmBudgetTable, + litellmChangedBy, + maxBudget, + maxParallelRequests, + metadata, + modelMaxBudget, + modelSpend, + (models ?: JsonMissing.of()).map { it.toImmutable() }, + objectPermission, + objectPermissionId, + orgId, + permissions, + rotationCount, + rotationInterval, + routerSettings, + rpmLimit, + softBudgetCooldown, + spend, + teamId, + tpmLimit, + updatedAt, + updatedBy, + userId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LiteLlmDeletedVerificationToken = apply { + if (validated) { + return@apply + } + + id() + token() + aliases().ifPresent { it.validate() } + allowedCacheControls() + allowedRoutes() + autoRotate() + blocked() + budgetDuration() + budgetResetAt() + config().ifPresent { it.validate() } + createdAt() + createdBy() + deletedAt() + deletedBy() + deletedByApiKey() + expires().ifPresent { it.validate() } + keyAlias() + keyName() + keyRotationAt() + lastRotationAt() + litellmBudgetTable().ifPresent { it.validate() } + litellmChangedBy() + maxBudget() + maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelSpend().ifPresent { it.validate() } + models() + objectPermission().ifPresent { it.validate() } + objectPermissionId() + orgId() + permissions().ifPresent { it.validate() } + rotationCount() + rotationInterval() + routerSettings().ifPresent { it.validate() } + rpmLimit() + softBudgetCooldown() + spend() + teamId() + tpmLimit() + updatedAt() + updatedBy() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Customer Roles: CUSTOMER: External users -> these are customers + * Used for best match union deserialization. */ - class UserRole @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + + (if (blocked.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (budgetResetAt.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (deletedAt.asKnown().isPresent) 1 else 0) + + (if (deletedBy.asKnown().isPresent) 1 else 0) + + (if (deletedByApiKey.asKnown().isPresent) 1 else 0) + + (expires.asKnown().getOrNull()?.validity() ?: 0) + + (if (keyAlias.asKnown().isPresent) 1 else 0) + + (if (keyName.asKnown().isPresent) 1 else 0) + + (if (keyRotationAt.asKnown().isPresent) 1 else 0) + + (if (lastRotationAt.asKnown().isPresent) 1 else 0) + + (litellmBudgetTable.asKnown().getOrNull()?.validity() ?: 0) + + (if (litellmChangedBy.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelSpend.asKnown().getOrNull()?.validity() ?: 0) + + (models.asKnown().getOrNull()?.size ?: 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (if (objectPermissionId.asKnown().isPresent) 1 else 0) + + (if (orgId.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (if (rotationCount.asKnown().isPresent) 1 else 0) + + (if (rotationInterval.asKnown().isPresent) 1 else 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (if (softBudgetCooldown.asKnown().isPresent) 1 else 0) + + (if (spend.asKnown().isPresent) 1 else 0) + + (if (teamId.asKnown().isPresent) 1 else 0) + + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (updatedBy.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + class Aliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Aliases]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Expires.Deserializer::class) + @JsonSerialize(using = Expires.Serializer::class) + class Expires + private constructor( + private val string: String? = null, + private val offsetDateTime: OffsetDateTime? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun offsetDateTime(): Optional = Optional.ofNullable(offsetDateTime) + + fun isString(): Boolean = string != null + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun asString(): String = string.getOrThrow("string") + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Expires = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Expires && + string == other.string && + offsetDateTime == other.offsetDateTime + } + + override fun hashCode(): Int = Objects.hash(string, offsetDateTime) + + override fun toString(): String = + when { + string != null -> "Expires{string=$string}" + offsetDateTime != null -> "Expires{offsetDateTime=$offsetDateTime}" + _json != null -> "Expires{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Expires") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Expires(string = string) + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + Expires(offsetDateTime = offsetDateTime) + } + + /** + * An interface that defines how to map each variant of [Expires] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + /** + * Maps an unknown variant of [Expires] to a value of type [T]. + * + * An instance of [Expires] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Expires: $json") + } + } + + internal class Deserializer : BaseDeserializer(Expires::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Expires { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(offsetDateTime = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Expires(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Expires(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Expires::class) { + + override fun serialize( + value: Expires, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.offsetDateTime != null -> + generator.writeObject(value.offsetDateTime) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Expires") + } + } + } + } + + class LitellmBudgetTable + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LitellmBudgetTable]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LitellmBudgetTable]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(litellmBudgetTable: LitellmBudgetTable) = apply { + additionalProperties = + litellmBudgetTable.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LitellmBudgetTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LitellmBudgetTable = + LitellmBudgetTable(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LitellmBudgetTable = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LitellmBudgetTable && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LitellmBudgetTable{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ModelMaxBudget]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelSpend + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelSpend]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelSpend]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelSpend: ModelSpend) = apply { + additionalProperties = modelSpend.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelSpend]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelSpend = ModelSpend(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelSpend = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelSpend && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelSpend{additionalProperties=$additionalProperties}" + } + + /** Represents a LiteLLM_ObjectPermissionTable record */ + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val objectPermissionId: JsonField, + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("object_permission_id") + @ExcludeMissing + objectPermissionId: JsonField = JsonMissing.of(), + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + objectPermissionId, + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun objectPermissionId(): String = + objectPermissionId.getRequired("object_permission_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun vectorStores(): Optional> = + vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [objectPermissionId]. + * + * Unlike [objectPermissionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("object_permission_id") + @ExcludeMissing + fun _objectPermissionId(): JsonField = objectPermissionId + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agents") + @ExcludeMissing + fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ObjectPermission]. + * + * The following fields are required: + * ```java + * .objectPermissionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var objectPermissionId: JsonField? = null + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + objectPermissionId = objectPermission.objectPermissionId + agentAccessGroups = + objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = + objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun objectPermissionId(objectPermissionId: String) = + objectPermissionId(JsonField.of(objectPermissionId)) + + /** + * Sets [Builder.objectPermissionId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermissionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun objectPermissionId(objectPermissionId: JsonField) = apply { + this.objectPermissionId = objectPermissionId + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with + * `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** + * Alias for calling [Builder.mcpAccessGroups] with + * `mcpAccessGroups.orElse(null)`. + */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = + mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = + mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = + apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** + * Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. + */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectPermissionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ObjectPermission = + ObjectPermission( + checkRequired("objectPermissionId", objectPermissionId), + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + objectPermissionId() + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (objectPermissionId.asKnown().isPresent) 1 else 0) + + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = + mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + objectPermissionId == other.objectPermissionId && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + objectPermissionId, + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{objectPermissionId=$objectPermissionId, agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) companion object { - @JvmField val PROXY_ADMIN = of("proxy_admin") + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val PROXY_ADMIN_VIEWER = of("proxy_admin_viewer") + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } - @JvmField val ORG_ADMIN = of("org_admin") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val INTERNAL_USER = of("internal_user") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmField val INTERNAL_USER_VIEWER = of("internal_user_viewer") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmField val TEAM = of("team") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmField val CUSTOMER = of("customer") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic fun of(value: String) = UserRole(JsonField.of(value)) + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) } - /** An enum containing [UserRole]'s known values. */ - enum class Known { - PROXY_ADMIN, - PROXY_ADMIN_VIEWER, - ORG_ADMIN, - INTERNAL_USER, - INTERNAL_USER_VIEWER, - TEAM, - CUSTOMER, + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + /** - * An enum containing [UserRole]'s known values, as well as an [_UNKNOWN] member. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * An instance of [UserRole] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Used for best match union deserialization. */ - enum class Value { - PROXY_ADMIN, - PROXY_ADMIN_VIEWER, - ORG_ADMIN, - INTERNAL_USER, - INTERNAL_USER_VIEWER, - TEAM, - CUSTOMER, + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + class RouterSettings + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + /** - * An enum member indicating that [UserRole] was instantiated with an unknown - * value. + * Returns a mutable builder for constructing an instance of [RouterSettings]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PROXY_ADMIN -> Value.PROXY_ADMIN - PROXY_ADMIN_VIEWER -> Value.PROXY_ADMIN_VIEWER - ORG_ADMIN -> Value.ORG_ADMIN - INTERNAL_USER -> Value.INTERNAL_USER - INTERNAL_USER_VIEWER -> Value.INTERNAL_USER_VIEWER - TEAM -> Value.TEAM - CUSTOMER -> Value.CUSTOMER - else -> Value._UNKNOWN + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + additionalProperties = routerSettings.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws HanzoInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PROXY_ADMIN -> Known.PROXY_ADMIN - PROXY_ADMIN_VIEWER -> Known.PROXY_ADMIN_VIEWER - ORG_ADMIN -> Known.ORG_ADMIN - INTERNAL_USER -> Known.INTERNAL_USER - INTERNAL_USER_VIEWER -> Known.INTERNAL_USER_VIEWER - TEAM -> Known.TEAM - CUSTOMER -> Known.CUSTOMER - else -> throw HanzoInvalidDataException("Unknown UserRole: $value") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws HanzoInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - HanzoInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = RouterSettings(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): UserRole = apply { + fun validate(): RouterSettings = apply { if (validated) { return@apply } - known() validated = true } @@ -3461,19 +10217,27 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is UserRole && value == other.value + return other is RouterSettings && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouterSettings{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3481,122 +10245,98 @@ private constructor( return true } - return other is UserApiKeyAuth && + return other is LiteLlmDeletedVerificationToken && + id == other.id && token == other.token && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && - allowedModelRegion == other.allowedModelRegion && - apiKey == other.apiKey && + allowedRoutes == other.allowedRoutes && + autoRotate == other.autoRotate && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetResetAt == other.budgetResetAt && config == other.config && createdAt == other.createdAt && createdBy == other.createdBy && - endUserId == other.endUserId && - endUserMaxBudget == other.endUserMaxBudget && - endUserRpmLimit == other.endUserRpmLimit && - endUserTpmLimit == other.endUserTpmLimit && + deletedAt == other.deletedAt && + deletedBy == other.deletedBy && + deletedByApiKey == other.deletedByApiKey && expires == other.expires && keyAlias == other.keyAlias && keyName == other.keyName && - lastRefreshedAt == other.lastRefreshedAt && - llmBudgetTable == other.llmBudgetTable && + keyRotationAt == other.keyRotationAt && + lastRotationAt == other.lastRotationAt && + litellmBudgetTable == other.litellmBudgetTable && + litellmChangedBy == other.litellmChangedBy && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && modelMaxBudget == other.modelMaxBudget && modelSpend == other.modelSpend && models == other.models && + objectPermission == other.objectPermission && + objectPermissionId == other.objectPermissionId && orgId == other.orgId && - parentOtelSpan == other.parentOtelSpan && permissions == other.permissions && + rotationCount == other.rotationCount && + rotationInterval == other.rotationInterval && + routerSettings == other.routerSettings && rpmLimit == other.rpmLimit && - rpmLimitPerModel == other.rpmLimitPerModel && - softBudget == other.softBudget && softBudgetCooldown == other.softBudgetCooldown && spend == other.spend && - teamAlias == other.teamAlias && - teamBlocked == other.teamBlocked && teamId == other.teamId && - teamMaxBudget == other.teamMaxBudget && - teamMember == other.teamMember && - teamMemberSpend == other.teamMemberSpend && - teamMetadata == other.teamMetadata && - teamModelAliases == other.teamModelAliases && - teamModels == other.teamModels && - teamRpmLimit == other.teamRpmLimit && - teamSpend == other.teamSpend && - teamTpmLimit == other.teamTpmLimit && tpmLimit == other.tpmLimit && - tpmLimitPerModel == other.tpmLimitPerModel && updatedAt == other.updatedAt && updatedBy == other.updatedBy && - userEmail == other.userEmail && userId == other.userId && - userRole == other.userRole && - userRpmLimit == other.userRpmLimit && - userTpmLimit == other.userTpmLimit && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, token, aliases, allowedCacheControls, - allowedModelRegion, - apiKey, + allowedRoutes, + autoRotate, blocked, budgetDuration, budgetResetAt, config, createdAt, createdBy, - endUserId, - endUserMaxBudget, - endUserRpmLimit, - endUserTpmLimit, + deletedAt, + deletedBy, + deletedByApiKey, expires, keyAlias, keyName, - lastRefreshedAt, - llmBudgetTable, + keyRotationAt, + lastRotationAt, + litellmBudgetTable, + litellmChangedBy, maxBudget, maxParallelRequests, metadata, modelMaxBudget, modelSpend, models, + objectPermission, + objectPermissionId, orgId, - parentOtelSpan, permissions, + rotationCount, + rotationInterval, + routerSettings, rpmLimit, - rpmLimitPerModel, - softBudget, softBudgetCooldown, spend, - teamAlias, - teamBlocked, teamId, - teamMaxBudget, - teamMember, - teamMemberSpend, - teamMetadata, - teamModelAliases, - teamModels, - teamRpmLimit, - teamSpend, - teamTpmLimit, tpmLimit, - tpmLimitPerModel, updatedAt, updatedBy, - userEmail, userId, - userRole, - userRpmLimit, - userTpmLimit, additionalProperties, ) } @@ -3604,7 +10344,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UserApiKeyAuth{token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedModelRegion=$allowedModelRegion, apiKey=$apiKey, blocked=$blocked, budgetDuration=$budgetDuration, budgetResetAt=$budgetResetAt, config=$config, createdAt=$createdAt, createdBy=$createdBy, endUserId=$endUserId, endUserMaxBudget=$endUserMaxBudget, endUserRpmLimit=$endUserRpmLimit, endUserTpmLimit=$endUserTpmLimit, expires=$expires, keyAlias=$keyAlias, keyName=$keyName, lastRefreshedAt=$lastRefreshedAt, llmBudgetTable=$llmBudgetTable, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelSpend=$modelSpend, models=$models, orgId=$orgId, parentOtelSpan=$parentOtelSpan, permissions=$permissions, rpmLimit=$rpmLimit, rpmLimitPerModel=$rpmLimitPerModel, softBudget=$softBudget, softBudgetCooldown=$softBudgetCooldown, spend=$spend, teamAlias=$teamAlias, teamBlocked=$teamBlocked, teamId=$teamId, teamMaxBudget=$teamMaxBudget, teamMember=$teamMember, teamMemberSpend=$teamMemberSpend, teamMetadata=$teamMetadata, teamModelAliases=$teamModelAliases, teamModels=$teamModels, teamRpmLimit=$teamRpmLimit, teamSpend=$teamSpend, teamTpmLimit=$teamTpmLimit, tpmLimit=$tpmLimit, tpmLimitPerModel=$tpmLimitPerModel, updatedAt=$updatedAt, updatedBy=$updatedBy, userEmail=$userEmail, userId=$userId, userRole=$userRole, userRpmLimit=$userRpmLimit, userTpmLimit=$userTpmLimit, additionalProperties=$additionalProperties}" + "LiteLlmDeletedVerificationToken{id=$id, token=$token, aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedRoutes=$allowedRoutes, autoRotate=$autoRotate, blocked=$blocked, budgetDuration=$budgetDuration, budgetResetAt=$budgetResetAt, config=$config, createdAt=$createdAt, createdBy=$createdBy, deletedAt=$deletedAt, deletedBy=$deletedBy, deletedByApiKey=$deletedByApiKey, expires=$expires, keyAlias=$keyAlias, keyName=$keyName, keyRotationAt=$keyRotationAt, lastRotationAt=$lastRotationAt, litellmBudgetTable=$litellmBudgetTable, litellmChangedBy=$litellmChangedBy, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelSpend=$modelSpend, models=$models, objectPermission=$objectPermission, objectPermissionId=$objectPermissionId, orgId=$orgId, permissions=$permissions, rotationCount=$rotationCount, rotationInterval=$rotationInterval, routerSettings=$routerSettings, rpmLimit=$rpmLimit, softBudgetCooldown=$softBudgetCooldown, spend=$spend, teamId=$teamId, tpmLimit=$tpmLimit, updatedAt=$updatedAt, updatedBy=$updatedBy, userId=$userId, additionalProperties=$additionalProperties}" } } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt index a8ffba8e..6f4ffd66 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRegenerateByKeyParams.kt @@ -18,6 +18,10 @@ import kotlin.jvm.optionals.getOrNull * Parameters: * - key: str (path parameter) - The key to regenerate * - data: Optional[RegenerateKeyRequest] - Request body containing optional parameters to update + * - key: Optional[str] - The key to regenerate. + * - new_master_key: Optional[str] - The new master key to use, if key is the master key. + * - new_key: Optional[str] - The new key to use, if key is not the master key. If both set, + * new_master_key will be used. * - key_alias: Optional[str] - User-friendly key alias * - user_id: Optional[str] - User ID associated with key * - team_id: Optional[str] - Team ID associated with key @@ -61,7 +65,7 @@ import kotlin.jvm.optionals.getOrNull class KeyRegenerateByKeyParams private constructor( private val pathKey: String?, - private val llmChangedBy: String?, + private val litellmChangedBy: String?, private val regenerateKeyRequest: RegenerateKeyRequest?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -70,10 +74,10 @@ private constructor( fun pathKey(): Optional = Optional.ofNullable(pathKey) /** - * The llm-changed-by header enables tracking of actions performed by authorized users on behalf - * of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users on + * behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(): Optional = Optional.ofNullable(llmChangedBy) + fun litellmChangedBy(): Optional = Optional.ofNullable(litellmChangedBy) fun regenerateKeyRequest(): Optional = Optional.ofNullable(regenerateKeyRequest) @@ -101,7 +105,7 @@ private constructor( class Builder internal constructor() { private var pathKey: String? = null - private var llmChangedBy: String? = null + private var litellmChangedBy: String? = null private var regenerateKeyRequest: RegenerateKeyRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -109,7 +113,7 @@ private constructor( @JvmSynthetic internal fun from(keyRegenerateByKeyParams: KeyRegenerateByKeyParams) = apply { pathKey = keyRegenerateByKeyParams.pathKey - llmChangedBy = keyRegenerateByKeyParams.llmChangedBy + litellmChangedBy = keyRegenerateByKeyParams.litellmChangedBy regenerateKeyRequest = keyRegenerateByKeyParams.regenerateKeyRequest additionalHeaders = keyRegenerateByKeyParams.additionalHeaders.toBuilder() additionalQueryParams = keyRegenerateByKeyParams.additionalQueryParams.toBuilder() @@ -121,13 +125,16 @@ private constructor( fun pathKey(pathKey: Optional) = pathKey(pathKey.getOrNull()) /** - * The llm-changed-by header enables tracking of actions performed by authorized users on - * behalf of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users + * on behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(llmChangedBy: String?) = apply { this.llmChangedBy = llmChangedBy } + fun litellmChangedBy(litellmChangedBy: String?) = apply { + this.litellmChangedBy = litellmChangedBy + } - /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ - fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** Alias for calling [Builder.litellmChangedBy] with `litellmChangedBy.orElse(null)`. */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) fun regenerateKeyRequest(regenerateKeyRequest: RegenerateKeyRequest?) = apply { this.regenerateKeyRequest = regenerateKeyRequest @@ -246,7 +253,7 @@ private constructor( fun build(): KeyRegenerateByKeyParams = KeyRegenerateByKeyParams( pathKey, - llmChangedBy, + litellmChangedBy, regenerateKeyRequest, additionalHeaders.build(), additionalQueryParams.build(), @@ -264,7 +271,7 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - llmChangedBy?.let { put("llm-changed-by", it) } + litellmChangedBy?.let { put("litellm-changed-by", it) } putAll(additionalHeaders) } .build() @@ -278,7 +285,7 @@ private constructor( return other is KeyRegenerateByKeyParams && pathKey == other.pathKey && - llmChangedBy == other.llmChangedBy && + litellmChangedBy == other.litellmChangedBy && regenerateKeyRequest == other.regenerateKeyRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -287,12 +294,12 @@ private constructor( override fun hashCode(): Int = Objects.hash( pathKey, - llmChangedBy, + litellmChangedBy, regenerateKeyRequest, additionalHeaders, additionalQueryParams, ) override fun toString() = - "KeyRegenerateByKeyParams{pathKey=$pathKey, llmChangedBy=$llmChangedBy, regenerateKeyRequest=$regenerateKeyRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyRegenerateByKeyParams{pathKey=$pathKey, litellmChangedBy=$litellmChangedBy, regenerateKeyRequest=$regenerateKeyRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParams.kt index b080a229..abc8ce75 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyRetrieveInfoParams.kt @@ -16,13 +16,13 @@ import kotlin.jvm.optionals.getOrNull * * Example Curl: * ``` - * curl -X GET "http://0.0.0.0:4000/key/info?key=sk-02Wr4IAlN3NvPXvL5JVvDA" -H "Authorization: Bearer sk-1234" + * curl -X GET "http://0.0.0.0:4000/key/info?key=sk-test-example-key-123" -H "Authorization: Bearer sk-1234" * ``` * * Example Curl - if no key is passed, it will use the Key Passed in Authorization Header * * ``` - * curl -X GET "http://0.0.0.0:4000/key/info" -H "Authorization: Bearer sk-02Wr4IAlN3NvPXvL5JVvDA" + * curl -X GET "http://0.0.0.0:4000/key/info" -H "Authorization: Bearer sk-test-example-key-123" * ``` */ class KeyRetrieveInfoParams diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt index 219bd386..9d84c55c 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUnblockParams.kt @@ -28,17 +28,17 @@ import kotlin.jvm.optionals.getOrNull */ class KeyUnblockParams private constructor( - private val llmChangedBy: String?, + private val litellmChangedBy: String?, private val blockKeyRequest: BlockKeyRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The llm-changed-by header enables tracking of actions performed by authorized users on behalf - * of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users on + * behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(): Optional = Optional.ofNullable(llmChangedBy) + fun litellmChangedBy(): Optional = Optional.ofNullable(litellmChangedBy) fun blockKeyRequest(): BlockKeyRequest = blockKeyRequest @@ -69,27 +69,30 @@ private constructor( /** A builder for [KeyUnblockParams]. */ class Builder internal constructor() { - private var llmChangedBy: String? = null + private var litellmChangedBy: String? = null private var blockKeyRequest: BlockKeyRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(keyUnblockParams: KeyUnblockParams) = apply { - llmChangedBy = keyUnblockParams.llmChangedBy + litellmChangedBy = keyUnblockParams.litellmChangedBy blockKeyRequest = keyUnblockParams.blockKeyRequest additionalHeaders = keyUnblockParams.additionalHeaders.toBuilder() additionalQueryParams = keyUnblockParams.additionalQueryParams.toBuilder() } /** - * The llm-changed-by header enables tracking of actions performed by authorized users on - * behalf of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users + * on behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(llmChangedBy: String?) = apply { this.llmChangedBy = llmChangedBy } + fun litellmChangedBy(litellmChangedBy: String?) = apply { + this.litellmChangedBy = litellmChangedBy + } - /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ - fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** Alias for calling [Builder.litellmChangedBy] with `litellmChangedBy.orElse(null)`. */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) fun blockKeyRequest(blockKeyRequest: BlockKeyRequest) = apply { this.blockKeyRequest = blockKeyRequest @@ -207,7 +210,7 @@ private constructor( */ fun build(): KeyUnblockParams = KeyUnblockParams( - llmChangedBy, + litellmChangedBy, checkRequired("blockKeyRequest", blockKeyRequest), additionalHeaders.build(), additionalQueryParams.build(), @@ -219,7 +222,7 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - llmChangedBy?.let { put("llm-changed-by", it) } + litellmChangedBy?.let { put("litellm-changed-by", it) } putAll(additionalHeaders) } .build() @@ -232,15 +235,15 @@ private constructor( } return other is KeyUnblockParams && - llmChangedBy == other.llmChangedBy && + litellmChangedBy == other.litellmChangedBy && blockKeyRequest == other.blockKeyRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(llmChangedBy, blockKeyRequest, additionalHeaders, additionalQueryParams) + Objects.hash(litellmChangedBy, blockKeyRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "KeyUnblockParams{llmChangedBy=$llmChangedBy, blockKeyRequest=$blockKeyRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyUnblockParams{litellmChangedBy=$litellmChangedBy, blockKeyRequest=$blockKeyRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt index 8b8e82b6..b28e4109 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/KeyUpdateParams.kt @@ -2,6 +2,7 @@ package ai.hanzo.api.models.key +import ai.hanzo.api.core.Enum import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing @@ -35,8 +36,9 @@ import kotlin.jvm.optionals.getOrNull * `/budget/new`. * - models: Optional[list] - Model_name's a user is allowed to call * - tags: Optional[List[str]] - Tags for organizing keys (Enterprise only) + * - prompts: Optional[List[str]] - List of prompts that the key is allowed to use. * - enforced_params: Optional[List[str]] - List of enforced params for the key (Enterprise only). - * [Docs](https://docs.hanzo.ai/docs/proxy/enterprise#enforce-required-params-for-llm-requests) + * [Docs](https://docs.litellm.ai/docs/proxy/enterprise#enforce-required-params-for-llm-requests) * - spend: Optional[float] - Amount spent by key * - max_budget: Optional[float] - Max budget for key * - model_max_budget: Optional[Dict[str, BudgetConfig]] - Model-specific budgets {"gpt-4": @@ -51,19 +53,48 @@ import kotlin.jvm.optionals.getOrNull * - model_rpm_limit: Optional[dict] - Model-specific RPM limits {"gpt-4": 100, "claude-v1": 200} * - model_tpm_limit: Optional[dict] - Model-specific TPM limits {"gpt-4": 100000, "claude-v1": * 200000} + * - tpm_limit_type: Optional[str] - TPM rate limit type - "best_effort_throughput", + * "guaranteed_throughput", or "dynamic" + * - rpm_limit_type: Optional[str] - RPM rate limit type - "best_effort_throughput", + * "guaranteed_throughput", or "dynamic" * - allowed_cache_controls: Optional[list] - List of allowed cache control values - * - duration: Optional[str] - Key validity duration ("30d", "1h", etc.) + * - duration: Optional[str] - Key validity duration ("30d", "1h", etc.) or "-1" to never expire * - permissions: Optional[dict] - Key-specific permissions * - send_invite_email: Optional[bool] - Send invite email to user_id * - guardrails: Optional[List[str]] - List of active guardrails for the key + * - disable_global_guardrails: Optional[bool] - Whether to disable global guardrails for the key. + * - prompts: Optional[List[str]] - List of prompts that the key is allowed to use. * - blocked: Optional[bool] - Whether the key is blocked * - aliases: Optional[dict] - Model aliases for the - * key - [Docs](https://llm.vercel.app/docs/proxy/virtual_keys#model-aliases) + * key - [Docs](https://litellm.vercel.app/docs/proxy/virtual_keys#model-aliases) * - config: Optional[dict] - [DEPRECATED PARAM] Key-specific config. * - temp_budget_increase: Optional[float] - Temporary budget increase for the key (Enterprise * only). * - temp_budget_expiry: Optional[str] - Expiry time for the temporary budget increase (Enterprise * only). + * - allowed_routes: Optional[list] - List of allowed routes for the key. Store the actual route or + * store a wildcard pattern for a set of routes. + * Example - ["/chat/completions", "/embeddings", "/keys/*"] + * - allowed_passthrough_routes: Optional[list] - List of allowed pass through routes for the key. + * Store the actual route or store a wildcard pattern for a set of routes. + * Example - ["/my-custom-endpoint"]. Use this instead of allowed_routes, if you just want to + * specify which pass through routes the key can access, without specifying the routes. If + * allowed_routes is specified, allowed_passthrough_routes is ignored. + * - prompts: Optional[List[str]] - List of allowed prompts for the key. If specified, the key will + * only be able to use these specific prompts. + * - object_permission: Optional[LiteLLM_ObjectPermissionBase] - key-specific object permission. + * Example - {"vector_stores": ["vector_store_1", "vector_store_2"], "agents": + * ["agent_1", "agent_2"], "agent_access_groups": ["dev_group"]}. IF null or {} then no object + * permission. + * - auto_rotate: Optional[bool] - Whether this key should be automatically rotated + * - rotation_interval: Optional[str] - How often to rotate this key (e.g., '30d', '90d'). Required + * if auto_rotate=True + * - allowed_vector_store_indexes: Optional[List[dict]] - List of allowed vector store indexes for + * the key. Example - [{"index_name": "my-index", "index_permissions": ["write", "read"]}]. If + * specified, the key will only be able to use these specific vector store indexes. Create index, + * using `/v1/indexes` endpoint. + * - router_settings: Optional[UpdateRouterConfig] - key-specific router settings. Example - + * {"model_group_retry_policy": {"max_retries": 5}}. IF null or {} then no router settings. * * Example: * ```bash @@ -79,17 +110,17 @@ import kotlin.jvm.optionals.getOrNull */ class KeyUpdateParams private constructor( - private val llmChangedBy: String?, + private val litellmChangedBy: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The llm-changed-by header enables tracking of actions performed by authorized users on behalf - * of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users on + * behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(): Optional = Optional.ofNullable(llmChangedBy) + fun litellmChangedBy(): Optional = Optional.ofNullable(litellmChangedBy) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -97,7 +128,11 @@ private constructor( */ fun key(): String = body.key() - fun _aliases(): JsonValue = body._aliases() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = body.aliases() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -105,6 +140,31 @@ private constructor( */ fun allowedCacheControls(): Optional> = body.allowedCacheControls() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedPassthroughRoutes(): Optional> = body.allowedPassthroughRoutes() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = body.allowedRoutes() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedVectorStoreIndexes(): Optional> = + body.allowedVectorStoreIndexes() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoRotate(): Optional = body.autoRotate() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -123,7 +183,11 @@ private constructor( */ fun budgetId(): Optional = body.budgetId() - fun _config(): JsonValue = body._config() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = body.config() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -161,13 +225,29 @@ private constructor( */ fun maxParallelRequests(): Optional = body.maxParallelRequests() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() - fun _modelMaxBudget(): JsonValue = body._modelMaxBudget() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = body.modelMaxBudget() - fun _modelRpmLimit(): JsonValue = body._modelRpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelRpmLimit(): Optional = body.modelRpmLimit() - fun _modelTpmLimit(): JsonValue = body._modelTpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelTpmLimit(): Optional = body.modelTpmLimit() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -175,7 +255,37 @@ private constructor( */ fun models(): Optional> = body.models() - fun _permissions(): JsonValue = body._permissions() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = body.objectPermission() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = body.permissions() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompts(): Optional> = body.prompts() + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationInterval(): Optional = body.rotationInterval() + + /** + * Set of params that you can modify via `router.update_settings()`. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = body.routerSettings() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -183,6 +293,12 @@ private constructor( */ fun rpmLimit(): Optional = body.rpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpmLimitType(): Optional = body.rpmLimitType() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -219,6 +335,12 @@ private constructor( */ fun tpmLimit(): Optional = body.tpmLimit() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tpmLimitType(): Optional = body.tpmLimitType() + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -232,6 +354,13 @@ private constructor( */ fun _key(): JsonField = body._key() + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _aliases(): JsonField = body._aliases() + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -240,6 +369,37 @@ private constructor( */ fun _allowedCacheControls(): JsonField> = body._allowedCacheControls() + /** + * Returns the raw JSON value of [allowedPassthroughRoutes]. + * + * Unlike [allowedPassthroughRoutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _allowedPassthroughRoutes(): JsonField> = body._allowedPassthroughRoutes() + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _allowedRoutes(): JsonField> = body._allowedRoutes() + + /** + * Returns the raw JSON value of [allowedVectorStoreIndexes]. + * + * Unlike [allowedVectorStoreIndexes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _allowedVectorStoreIndexes(): JsonField> = + body._allowedVectorStoreIndexes() + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoRotate(): JsonField = body._autoRotate() + /** * Returns the raw JSON value of [blocked]. * @@ -261,6 +421,13 @@ private constructor( */ fun _budgetId(): JsonField = body._budgetId() + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + /** * Returns the raw JSON value of [duration]. * @@ -304,6 +471,34 @@ private constructor( */ fun _maxParallelRequests(): JsonField = body._maxParallelRequests() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modelMaxBudget(): JsonField = body._modelMaxBudget() + + /** + * Returns the raw JSON value of [modelRpmLimit]. + * + * Unlike [modelRpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modelRpmLimit(): JsonField = body._modelRpmLimit() + + /** + * Returns the raw JSON value of [modelTpmLimit]. + * + * Unlike [modelTpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modelTpmLimit(): JsonField = body._modelTpmLimit() + /** * Returns the raw JSON value of [models]. * @@ -311,6 +506,43 @@ private constructor( */ fun _models(): JsonField> = body._models() + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _objectPermission(): JsonField = body._objectPermission() + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _permissions(): JsonField = body._permissions() + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _prompts(): JsonField> = body._prompts() + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _rotationInterval(): JsonField = body._rotationInterval() + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _routerSettings(): JsonField = body._routerSettings() + /** * Returns the raw JSON value of [rpmLimit]. * @@ -318,6 +550,13 @@ private constructor( */ fun _rpmLimit(): JsonField = body._rpmLimit() + /** + * Returns the raw JSON value of [rpmLimitType]. + * + * Unlike [rpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rpmLimitType(): JsonField = body._rpmLimitType() + /** * Returns the raw JSON value of [spend]. * @@ -362,6 +601,13 @@ private constructor( */ fun _tpmLimit(): JsonField = body._tpmLimit() + /** + * Returns the raw JSON value of [tpmLimitType]. + * + * Unlike [tpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tpmLimitType(): JsonField = body._tpmLimitType() + /** * Returns the raw JSON value of [userId]. * @@ -395,27 +641,30 @@ private constructor( /** A builder for [KeyUpdateParams]. */ class Builder internal constructor() { - private var llmChangedBy: String? = null + private var litellmChangedBy: String? = null private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(keyUpdateParams: KeyUpdateParams) = apply { - llmChangedBy = keyUpdateParams.llmChangedBy + litellmChangedBy = keyUpdateParams.litellmChangedBy body = keyUpdateParams.body.toBuilder() additionalHeaders = keyUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = keyUpdateParams.additionalQueryParams.toBuilder() } /** - * The llm-changed-by header enables tracking of actions performed by authorized users on - * behalf of other users, providing an audit trail for accountability + * The litellm-changed-by header enables tracking of actions performed by authorized users + * on behalf of other users, providing an audit trail for accountability */ - fun llmChangedBy(llmChangedBy: String?) = apply { this.llmChangedBy = llmChangedBy } + fun litellmChangedBy(litellmChangedBy: String?) = apply { + this.litellmChangedBy = litellmChangedBy + } - /** Alias for calling [Builder.llmChangedBy] with `llmChangedBy.orElse(null)`. */ - fun llmChangedBy(llmChangedBy: Optional) = llmChangedBy(llmChangedBy.getOrNull()) + /** Alias for calling [Builder.litellmChangedBy] with `litellmChangedBy.orElse(null)`. */ + fun litellmChangedBy(litellmChangedBy: Optional) = + litellmChangedBy(litellmChangedBy.getOrNull()) /** * Sets the entire request body. @@ -425,8 +674,8 @@ private constructor( * - [key] * - [aliases] * - [allowedCacheControls] - * - [blocked] - * - [budgetDuration] + * - [allowedPassthroughRoutes] + * - [allowedRoutes] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -441,7 +690,18 @@ private constructor( */ fun key(key: JsonField) = apply { body.key(key) } - fun aliases(aliases: JsonValue) = apply { body.aliases(aliases) } + fun aliases(aliases: Aliases?) = apply { body.aliases(aliases) } + + /** Alias for calling [Builder.aliases] with `aliases.orElse(null)`. */ + fun aliases(aliases: Optional) = aliases(aliases.getOrNull()) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun aliases(aliases: JsonField) = apply { body.aliases(aliases) } fun allowedCacheControls(allowedCacheControls: List?) = apply { body.allowedCacheControls(allowedCacheControls) @@ -474,6 +734,117 @@ private constructor( body.addAllowedCacheControl(allowedCacheControl) } + fun allowedPassthroughRoutes(allowedPassthroughRoutes: List?) = apply { + body.allowedPassthroughRoutes(allowedPassthroughRoutes) + } + + /** + * Alias for calling [Builder.allowedPassthroughRoutes] with + * `allowedPassthroughRoutes.orElse(null)`. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: Optional>) = + allowedPassthroughRoutes(allowedPassthroughRoutes.getOrNull()) + + /** + * Sets [Builder.allowedPassthroughRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedPassthroughRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: JsonField>) = apply { + body.allowedPassthroughRoutes(allowedPassthroughRoutes) + } + + /** + * Adds a single [JsonValue] to [allowedPassthroughRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedPassthroughRoute(allowedPassthroughRoute: JsonValue) = apply { + body.addAllowedPassthroughRoute(allowedPassthroughRoute) + } + + fun allowedRoutes(allowedRoutes: List?) = apply { + body.allowedRoutes(allowedRoutes) + } + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + body.allowedRoutes(allowedRoutes) + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { body.addAllowedRoute(allowedRoute) } + + fun allowedVectorStoreIndexes(allowedVectorStoreIndexes: List?) = + apply { + body.allowedVectorStoreIndexes(allowedVectorStoreIndexes) + } + + /** + * Alias for calling [Builder.allowedVectorStoreIndexes] with + * `allowedVectorStoreIndexes.orElse(null)`. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: Optional> + ) = allowedVectorStoreIndexes(allowedVectorStoreIndexes.getOrNull()) + + /** + * Sets [Builder.allowedVectorStoreIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedVectorStoreIndexes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: JsonField> + ) = apply { body.allowedVectorStoreIndexes(allowedVectorStoreIndexes) } + + /** + * Adds a single [AllowedVectorStoreIndex] to [allowedVectorStoreIndexes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedVectorStoreIndex(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + body.addAllowedVectorStoreIndex(allowedVectorStoreIndex) + } + + fun autoRotate(autoRotate: Boolean?) = apply { body.autoRotate(autoRotate) } + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoRotate(autoRotate: JsonField) = apply { body.autoRotate(autoRotate) } + fun blocked(blocked: Boolean?) = apply { body.blocked(blocked) } /** @@ -524,7 +895,18 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { body.budgetId(budgetId) } - fun config(config: JsonValue) = apply { body.config(config) } + fun config(config: Config?) = apply { body.config(config) } + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } fun duration(duration: String?) = apply { body.duration(duration) } @@ -649,46 +1031,200 @@ private constructor( body.maxParallelRequests(maxParallelRequests) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { - body.modelMaxBudget(modelMaxBudget) - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun modelRpmLimit(modelRpmLimit: JsonValue) = apply { body.modelRpmLimit(modelRpmLimit) } - - fun modelTpmLimit(modelTpmLimit: JsonValue) = apply { body.modelTpmLimit(modelTpmLimit) } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } - fun models(models: List?) = apply { body.models(models) } + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget?) = apply { + body.modelMaxBudget(modelMaxBudget) + } - /** Alias for calling [Builder.models] with `models.orElse(null)`. */ - fun models(models: Optional>) = models(models.getOrNull()) + /** Alias for calling [Builder.modelMaxBudget] with `modelMaxBudget.orElse(null)`. */ + fun modelMaxBudget(modelMaxBudget: Optional) = + modelMaxBudget(modelMaxBudget.getOrNull()) /** - * Sets [Builder.models] to an arbitrary JSON value. + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. * - * You should usually call [Builder.models] with a well-typed `List` value + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun models(models: JsonField>) = apply { body.models(models) } + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { + body.modelMaxBudget(modelMaxBudget) + } + + fun modelRpmLimit(modelRpmLimit: ModelRpmLimit?) = apply { + body.modelRpmLimit(modelRpmLimit) + } + + /** Alias for calling [Builder.modelRpmLimit] with `modelRpmLimit.orElse(null)`. */ + fun modelRpmLimit(modelRpmLimit: Optional) = + modelRpmLimit(modelRpmLimit.getOrNull()) /** - * Adds a single [JsonValue] to [models]. + * Sets [Builder.modelRpmLimit] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.modelRpmLimit] with a well-typed [ModelRpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addModel(model: JsonValue) = apply { body.addModel(model) } + fun modelRpmLimit(modelRpmLimit: JsonField) = apply { + body.modelRpmLimit(modelRpmLimit) + } - fun permissions(permissions: JsonValue) = apply { body.permissions(permissions) } + fun modelTpmLimit(modelTpmLimit: ModelTpmLimit?) = apply { + body.modelTpmLimit(modelTpmLimit) + } - fun rpmLimit(rpmLimit: Long?) = apply { body.rpmLimit(rpmLimit) } + /** Alias for calling [Builder.modelTpmLimit] with `modelTpmLimit.orElse(null)`. */ + fun modelTpmLimit(modelTpmLimit: Optional) = + modelTpmLimit(modelTpmLimit.getOrNull()) /** - * Alias for [Builder.rpmLimit]. + * Sets [Builder.modelTpmLimit] to an arbitrary JSON value. * - * This unboxed primitive overload exists for backwards compatibility. - */ + * You should usually call [Builder.modelTpmLimit] with a well-typed [ModelTpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelTpmLimit(modelTpmLimit: JsonField) = apply { + body.modelTpmLimit(modelTpmLimit) + } + + fun models(models: List?) = apply { body.models(models) } + + /** Alias for calling [Builder.models] with `models.orElse(null)`. */ + fun models(models: Optional>) = models(models.getOrNull()) + + /** + * Sets [Builder.models] to an arbitrary JSON value. + * + * You should usually call [Builder.models] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun models(models: JsonField>) = apply { body.models(models) } + + /** + * Adds a single [JsonValue] to [models]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addModel(model: JsonValue) = apply { body.addModel(model) } + + fun objectPermission(objectPermission: ObjectPermission?) = apply { + body.objectPermission(objectPermission) + } + + /** Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed [ObjectPermission] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + body.objectPermission(objectPermission) + } + + fun permissions(permissions: Permissions?) = apply { body.permissions(permissions) } + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional) = permissions(permissions.getOrNull()) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField) = apply { + body.permissions(permissions) + } + + fun prompts(prompts: List?) = apply { body.prompts(prompts) } + + /** Alias for calling [Builder.prompts] with `prompts.orElse(null)`. */ + fun prompts(prompts: Optional>) = prompts(prompts.getOrNull()) + + /** + * Sets [Builder.prompts] to an arbitrary JSON value. + * + * You should usually call [Builder.prompts] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prompts(prompts: JsonField>) = apply { body.prompts(prompts) } + + /** + * Adds a single [String] to [prompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: String) = apply { body.addPrompt(prompt) } + + fun rotationInterval(rotationInterval: String?) = apply { + body.rotationInterval(rotationInterval) + } + + /** Alias for calling [Builder.rotationInterval] with `rotationInterval.orElse(null)`. */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + body.rotationInterval(rotationInterval) + } + + /** Set of params that you can modify via `router.update_settings()`. */ + fun routerSettings(routerSettings: RouterSettings?) = apply { + body.routerSettings(routerSettings) + } + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + body.routerSettings(routerSettings) + } + + fun rpmLimit(rpmLimit: Long?) = apply { body.rpmLimit(rpmLimit) } + + /** + * Alias for [Builder.rpmLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun rpmLimit(rpmLimit: Long) = rpmLimit(rpmLimit as Long?) /** Alias for calling [Builder.rpmLimit] with `rpmLimit.orElse(null)`. */ @@ -702,6 +1238,23 @@ private constructor( */ fun rpmLimit(rpmLimit: JsonField) = apply { body.rpmLimit(rpmLimit) } + fun rpmLimitType(rpmLimitType: RpmLimitType?) = apply { body.rpmLimitType(rpmLimitType) } + + /** Alias for calling [Builder.rpmLimitType] with `rpmLimitType.orElse(null)`. */ + fun rpmLimitType(rpmLimitType: Optional) = + rpmLimitType(rpmLimitType.getOrNull()) + + /** + * Sets [Builder.rpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimitType] with a well-typed [RpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimitType(rpmLimitType: JsonField) = apply { + body.rpmLimitType(rpmLimitType) + } + fun spend(spend: Double?) = apply { body.spend(spend) } /** @@ -824,6 +1377,23 @@ private constructor( */ fun tpmLimit(tpmLimit: JsonField) = apply { body.tpmLimit(tpmLimit) } + fun tpmLimitType(tpmLimitType: TpmLimitType?) = apply { body.tpmLimitType(tpmLimitType) } + + /** Alias for calling [Builder.tpmLimitType] with `tpmLimitType.orElse(null)`. */ + fun tpmLimitType(tpmLimitType: Optional) = + tpmLimitType(tpmLimitType.getOrNull()) + + /** + * Sets [Builder.tpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimitType] with a well-typed [TpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tpmLimitType(tpmLimitType: JsonField) = apply { + body.tpmLimitType(tpmLimitType) + } + fun userId(userId: String?) = apply { body.userId(userId) } /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -968,7 +1538,7 @@ private constructor( */ fun build(): KeyUpdateParams = KeyUpdateParams( - llmChangedBy, + litellmChangedBy, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -980,7 +1550,7 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - llmChangedBy?.let { put("llm-changed-by", it) } + litellmChangedBy?.let { put("litellm-changed-by", it) } putAll(additionalHeaders) } .build() @@ -991,31 +1561,41 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val key: JsonField, - private val aliases: JsonValue, + private val aliases: JsonField, private val allowedCacheControls: JsonField>, + private val allowedPassthroughRoutes: JsonField>, + private val allowedRoutes: JsonField>, + private val allowedVectorStoreIndexes: JsonField>, + private val autoRotate: JsonField, private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetId: JsonField, - private val config: JsonValue, + private val config: JsonField, private val duration: JsonField, private val enforcedParams: JsonField>, private val guardrails: JsonField>, private val keyAlias: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, - private val metadata: JsonValue, - private val modelMaxBudget: JsonValue, - private val modelRpmLimit: JsonValue, - private val modelTpmLimit: JsonValue, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelRpmLimit: JsonField, + private val modelTpmLimit: JsonField, private val models: JsonField>, - private val permissions: JsonValue, + private val objectPermission: JsonField, + private val permissions: JsonField, + private val prompts: JsonField>, + private val rotationInterval: JsonField, + private val routerSettings: JsonField, private val rpmLimit: JsonField, + private val rpmLimitType: JsonField, private val spend: JsonField, private val tags: JsonField>, private val teamId: JsonField, private val tempBudgetExpiry: JsonField, private val tempBudgetIncrease: JsonField, private val tpmLimit: JsonField, + private val tpmLimitType: JsonField, private val userId: JsonField, private val additionalProperties: MutableMap, ) { @@ -1023,10 +1603,22 @@ private constructor( @JsonCreator private constructor( @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), - @JsonProperty("aliases") @ExcludeMissing aliases: JsonValue = JsonMissing.of(), + @JsonProperty("aliases") @ExcludeMissing aliases: JsonField = JsonMissing.of(), @JsonProperty("allowed_cache_controls") @ExcludeMissing allowedCacheControls: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + allowedPassthroughRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + allowedVectorStoreIndexes: JsonField> = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), @JsonProperty("budget_duration") @ExcludeMissing @@ -1034,7 +1626,7 @@ private constructor( @JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @@ -1053,21 +1645,40 @@ private constructor( @JsonProperty("max_parallel_requests") @ExcludeMissing maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("model_max_budget") @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), + modelMaxBudget: JsonField = JsonMissing.of(), @JsonProperty("model_rpm_limit") @ExcludeMissing - modelRpmLimit: JsonValue = JsonMissing.of(), + modelRpmLimit: JsonField = JsonMissing.of(), @JsonProperty("model_tpm_limit") @ExcludeMissing - modelTpmLimit: JsonValue = JsonMissing.of(), + modelTpmLimit: JsonField = JsonMissing.of(), @JsonProperty("models") @ExcludeMissing models: JsonField> = JsonMissing.of(), - @JsonProperty("permissions") @ExcludeMissing permissions: JsonValue = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField = JsonMissing.of(), + @JsonProperty("prompts") + @ExcludeMissing + prompts: JsonField> = JsonMissing.of(), + @JsonProperty("rotation_interval") + @ExcludeMissing + rotationInterval: JsonField = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("rpm_limit_type") + @ExcludeMissing + rpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("spend") @ExcludeMissing spend: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("team_id") @ExcludeMissing teamId: JsonField = JsonMissing.of(), @@ -1078,11 +1689,18 @@ private constructor( @ExcludeMissing tempBudgetIncrease: JsonField = JsonMissing.of(), @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("tpm_limit_type") + @ExcludeMissing + tpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), ) : this( key, aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + autoRotate, blocked, budgetDuration, budgetId, @@ -1098,14 +1716,20 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + objectPermission, permissions, + prompts, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, spend, tags, teamId, tempBudgetExpiry, tempBudgetIncrease, tpmLimit, + tpmLimitType, userId, mutableMapOf(), ) @@ -1116,7 +1740,11 @@ private constructor( */ fun key(): String = key.getRequired("key") - @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1125,6 +1753,32 @@ private constructor( fun allowedCacheControls(): Optional> = allowedCacheControls.getOptional("allowed_cache_controls") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedPassthroughRoutes(): Optional> = + allowedPassthroughRoutes.getOptional("allowed_passthrough_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = allowedRoutes.getOptional("allowed_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedVectorStoreIndexes(): Optional> = + allowedVectorStoreIndexes.getOptional("allowed_vector_store_indexes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1143,7 +1797,11 @@ private constructor( */ fun budgetId(): Optional = budgetId.getOptional("budget_id") - @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1182,19 +1840,30 @@ private constructor( fun maxParallelRequests(): Optional = maxParallelRequests.getOptional("max_parallel_requests") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = + modelMaxBudget.getOptional("model_max_budget") - @JsonProperty("model_rpm_limit") - @ExcludeMissing - fun _modelRpmLimit(): JsonValue = modelRpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelRpmLimit(): Optional = modelRpmLimit.getOptional("model_rpm_limit") - @JsonProperty("model_tpm_limit") - @ExcludeMissing - fun _modelTpmLimit(): JsonValue = modelTpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelTpmLimit(): Optional = modelTpmLimit.getOptional("model_tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1202,7 +1871,39 @@ private constructor( */ fun models(): Optional> = models.getOptional("models") - @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompts(): Optional> = prompts.getOptional("prompts") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationInterval(): Optional = rotationInterval.getOptional("rotation_interval") + + /** + * Set of params that you can modify via `router.update_settings()`. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = + routerSettings.getOptional("router_settings") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1210,6 +1911,12 @@ private constructor( */ fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpmLimitType(): Optional = rpmLimitType.getOptional("rpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1248,6 +1955,12 @@ private constructor( */ fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tpmLimitType(): Optional = tpmLimitType.getOptional("tpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1261,6 +1974,13 @@ private constructor( */ @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -1271,6 +1991,46 @@ private constructor( @ExcludeMissing fun _allowedCacheControls(): JsonField> = allowedCacheControls + /** + * Returns the raw JSON value of [allowedPassthroughRoutes]. + * + * Unlike [allowedPassthroughRoutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + fun _allowedPassthroughRoutes(): JsonField> = allowedPassthroughRoutes + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + + /** + * Returns the raw JSON value of [allowedVectorStoreIndexes]. + * + * Unlike [allowedVectorStoreIndexes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + fun _allowedVectorStoreIndexes(): JsonField> = + allowedVectorStoreIndexes + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + /** * Returns the raw JSON value of [blocked]. * @@ -1295,6 +2055,13 @@ private constructor( */ @JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + /** * Returns the raw JSON value of [duration]. * @@ -1346,37 +2113,130 @@ private constructor( fun _maxParallelRequests(): JsonField = maxParallelRequests /** - * Returns the raw JSON value of [models]. + * Returns the raw JSON value of [metadata]. * - * Unlike [models], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("models") @ExcludeMissing fun _models(): JsonField> = models + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Returns the raw JSON value of [rpmLimit]. + * Returns the raw JSON value of [modelMaxBudget]. * - * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget /** - * Returns the raw JSON value of [spend]. + * Returns the raw JSON value of [modelRpmLimit]. * - * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [modelRpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend + @JsonProperty("model_rpm_limit") + @ExcludeMissing + fun _modelRpmLimit(): JsonField = modelRpmLimit /** - * Returns the raw JSON value of [tags]. + * Returns the raw JSON value of [modelTpmLimit]. * - * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [modelTpmLimit], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("model_tpm_limit") + @ExcludeMissing + fun _modelTpmLimit(): JsonField = modelTpmLimit /** - * Returns the raw JSON value of [teamId]. + * Returns the raw JSON value of [models]. * - * Unlike [teamId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [models], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("models") @ExcludeMissing fun _models(): JsonField> = models + + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object_permission") + @ExcludeMissing + fun _objectPermission(): JsonField = objectPermission + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompts") @ExcludeMissing fun _prompts(): JsonField> = prompts + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rotation_interval") + @ExcludeMissing + fun _rotationInterval(): JsonField = rotationInterval + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + + /** + * Returns the raw JSON value of [rpmLimit]. + * + * Unlike [rpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + + /** + * Returns the raw JSON value of [rpmLimitType]. + * + * Unlike [rpmLimitType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rpm_limit_type") + @ExcludeMissing + fun _rpmLimitType(): JsonField = rpmLimitType + + /** + * Returns the raw JSON value of [spend]. + * + * Unlike [spend], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spend") @ExcludeMissing fun _spend(): JsonField = spend + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [teamId]. + * + * Unlike [teamId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("team_id") @ExcludeMissing fun _teamId(): JsonField = teamId @@ -1407,6 +2267,16 @@ private constructor( */ @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit + /** + * Returns the raw JSON value of [tpmLimitType]. + * + * Unlike [tpmLimitType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tpm_limit_type") + @ExcludeMissing + fun _tpmLimitType(): JsonField = tpmLimitType + /** * Returns the raw JSON value of [userId]. * @@ -1443,31 +2313,43 @@ private constructor( class Builder internal constructor() { private var key: JsonField? = null - private var aliases: JsonValue = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() private var allowedCacheControls: JsonField>? = null + private var allowedPassthroughRoutes: JsonField>? = null + private var allowedRoutes: JsonField>? = null + private var allowedVectorStoreIndexes: + JsonField>? = + null + private var autoRotate: JsonField = JsonMissing.of() private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetId: JsonField = JsonMissing.of() - private var config: JsonValue = JsonMissing.of() + private var config: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var enforcedParams: JsonField>? = null private var guardrails: JsonField>? = null private var keyAlias: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var modelRpmLimit: JsonValue = JsonMissing.of() - private var modelTpmLimit: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelRpmLimit: JsonField = JsonMissing.of() + private var modelTpmLimit: JsonField = JsonMissing.of() private var models: JsonField>? = null - private var permissions: JsonValue = JsonMissing.of() + private var objectPermission: JsonField = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var prompts: JsonField>? = null + private var rotationInterval: JsonField = JsonMissing.of() + private var routerSettings: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() + private var rpmLimitType: JsonField = JsonMissing.of() private var spend: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var teamId: JsonField = JsonMissing.of() private var tempBudgetExpiry: JsonField = JsonMissing.of() private var tempBudgetIncrease: JsonField = JsonMissing.of() private var tpmLimit: JsonField = JsonMissing.of() + private var tpmLimitType: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1476,6 +2358,11 @@ private constructor( key = body.key aliases = body.aliases allowedCacheControls = body.allowedCacheControls.map { it.toMutableList() } + allowedPassthroughRoutes = body.allowedPassthroughRoutes.map { it.toMutableList() } + allowedRoutes = body.allowedRoutes.map { it.toMutableList() } + allowedVectorStoreIndexes = + body.allowedVectorStoreIndexes.map { it.toMutableList() } + autoRotate = body.autoRotate blocked = body.blocked budgetDuration = body.budgetDuration budgetId = body.budgetId @@ -1491,14 +2378,20 @@ private constructor( modelRpmLimit = body.modelRpmLimit modelTpmLimit = body.modelTpmLimit models = body.models.map { it.toMutableList() } + objectPermission = body.objectPermission permissions = body.permissions + prompts = body.prompts.map { it.toMutableList() } + rotationInterval = body.rotationInterval + routerSettings = body.routerSettings rpmLimit = body.rpmLimit + rpmLimitType = body.rpmLimitType spend = body.spend tags = body.tags.map { it.toMutableList() } teamId = body.teamId tempBudgetExpiry = body.tempBudgetExpiry tempBudgetIncrease = body.tempBudgetIncrease tpmLimit = body.tpmLimit + tpmLimitType = body.tpmLimitType userId = body.userId additionalProperties = body.additionalProperties.toMutableMap() } @@ -1514,7 +2407,19 @@ private constructor( */ fun key(key: JsonField) = apply { this.key = key } - fun aliases(aliases: JsonValue) = apply { this.aliases = aliases } + fun aliases(aliases: Aliases?) = aliases(JsonField.ofNullable(aliases)) + + /** Alias for calling [Builder.aliases] with `aliases.orElse(null)`. */ + fun aliases(aliases: Optional) = aliases(aliases.getOrNull()) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } fun allowedCacheControls(allowedCacheControls: List?) = allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) @@ -1549,6 +2454,131 @@ private constructor( } } + fun allowedPassthroughRoutes(allowedPassthroughRoutes: List?) = + allowedPassthroughRoutes(JsonField.ofNullable(allowedPassthroughRoutes)) + + /** + * Alias for calling [Builder.allowedPassthroughRoutes] with + * `allowedPassthroughRoutes.orElse(null)`. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: Optional>) = + allowedPassthroughRoutes(allowedPassthroughRoutes.getOrNull()) + + /** + * Sets [Builder.allowedPassthroughRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedPassthroughRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: JsonField>) = + apply { + this.allowedPassthroughRoutes = + allowedPassthroughRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedPassthroughRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedPassthroughRoute(allowedPassthroughRoute: JsonValue) = apply { + allowedPassthroughRoutes = + (allowedPassthroughRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedPassthroughRoutes", it).add(allowedPassthroughRoute) + } + } + + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) + + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) + + /** + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedRoutes] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [allowedRoutes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } + + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: List? + ) = allowedVectorStoreIndexes(JsonField.ofNullable(allowedVectorStoreIndexes)) + + /** + * Alias for calling [Builder.allowedVectorStoreIndexes] with + * `allowedVectorStoreIndexes.orElse(null)`. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: Optional> + ) = allowedVectorStoreIndexes(allowedVectorStoreIndexes.getOrNull()) + + /** + * Sets [Builder.allowedVectorStoreIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedVectorStoreIndexes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: JsonField> + ) = apply { + this.allowedVectorStoreIndexes = + allowedVectorStoreIndexes.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedVectorStoreIndex] to [allowedVectorStoreIndexes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedVectorStoreIndex(allowedVectorStoreIndex: AllowedVectorStoreIndex) = + apply { + allowedVectorStoreIndexes = + (allowedVectorStoreIndexes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedVectorStoreIndexes", it).add(allowedVectorStoreIndex) + } + } + + fun autoRotate(autoRotate: Boolean?) = autoRotate(JsonField.ofNullable(autoRotate)) + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { this.autoRotate = autoRotate } + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) /** @@ -1602,7 +2632,19 @@ private constructor( */ fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } - fun config(config: JsonValue) = apply { this.config = config } + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } fun duration(duration: String?) = duration(JsonField.ofNullable(duration)) @@ -1740,17 +2782,71 @@ private constructor( this.maxParallelRequests = maxParallelRequests } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget?) = + modelMaxBudget(JsonField.ofNullable(modelMaxBudget)) + + /** Alias for calling [Builder.modelMaxBudget] with `modelMaxBudget.orElse(null)`. */ + fun modelMaxBudget(modelMaxBudget: Optional) = + modelMaxBudget(modelMaxBudget.getOrNull()) - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { this.modelMaxBudget = modelMaxBudget } - fun modelRpmLimit(modelRpmLimit: JsonValue) = apply { + fun modelRpmLimit(modelRpmLimit: ModelRpmLimit?) = + modelRpmLimit(JsonField.ofNullable(modelRpmLimit)) + + /** Alias for calling [Builder.modelRpmLimit] with `modelRpmLimit.orElse(null)`. */ + fun modelRpmLimit(modelRpmLimit: Optional) = + modelRpmLimit(modelRpmLimit.getOrNull()) + + /** + * Sets [Builder.modelRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelRpmLimit] with a well-typed [ModelRpmLimit] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelRpmLimit(modelRpmLimit: JsonField) = apply { this.modelRpmLimit = modelRpmLimit } - fun modelTpmLimit(modelTpmLimit: JsonValue) = apply { + fun modelTpmLimit(modelTpmLimit: ModelTpmLimit?) = + modelTpmLimit(JsonField.ofNullable(modelTpmLimit)) + + /** Alias for calling [Builder.modelTpmLimit] with `modelTpmLimit.orElse(null)`. */ + fun modelTpmLimit(modelTpmLimit: Optional) = + modelTpmLimit(modelTpmLimit.getOrNull()) + + /** + * Sets [Builder.modelTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelTpmLimit] with a well-typed [ModelTpmLimit] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelTpmLimit(modelTpmLimit: JsonField) = apply { this.modelTpmLimit = modelTpmLimit } @@ -1782,7 +2878,110 @@ private constructor( } } - fun permissions(permissions: JsonValue) = apply { this.permissions = permissions } + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) + + /** + * Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. + */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed + * [ObjectPermission] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } + + fun permissions(permissions: Permissions?) = + permissions(JsonField.ofNullable(permissions)) + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional) = + permissions(permissions.getOrNull()) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } + + fun prompts(prompts: List?) = prompts(JsonField.ofNullable(prompts)) + + /** Alias for calling [Builder.prompts] with `prompts.orElse(null)`. */ + fun prompts(prompts: Optional>) = prompts(prompts.getOrNull()) + + /** + * Sets [Builder.prompts] to an arbitrary JSON value. + * + * You should usually call [Builder.prompts] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prompts(prompts: JsonField>) = apply { + this.prompts = prompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [prompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: String) = apply { + prompts = + (prompts ?: JsonField.of(mutableListOf())).also { + checkKnown("prompts", it).add(prompt) + } + } + + fun rotationInterval(rotationInterval: String?) = + rotationInterval(JsonField.ofNullable(rotationInterval)) + + /** + * Alias for calling [Builder.rotationInterval] with `rotationInterval.orElse(null)`. + */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + this.rotationInterval = rotationInterval + } + + /** Set of params that you can modify via `router.update_settings()`. */ + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) @@ -1805,6 +3004,24 @@ private constructor( */ fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } + fun rpmLimitType(rpmLimitType: RpmLimitType?) = + rpmLimitType(JsonField.ofNullable(rpmLimitType)) + + /** Alias for calling [Builder.rpmLimitType] with `rpmLimitType.orElse(null)`. */ + fun rpmLimitType(rpmLimitType: Optional) = + rpmLimitType(rpmLimitType.getOrNull()) + + /** + * Sets [Builder.rpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimitType] with a well-typed [RpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimitType(rpmLimitType: JsonField) = apply { + this.rpmLimitType = rpmLimitType + } + fun spend(spend: Double?) = spend(JsonField.ofNullable(spend)) /** @@ -1936,6 +3153,24 @@ private constructor( */ fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } + fun tpmLimitType(tpmLimitType: TpmLimitType?) = + tpmLimitType(JsonField.ofNullable(tpmLimitType)) + + /** Alias for calling [Builder.tpmLimitType] with `tpmLimitType.orElse(null)`. */ + fun tpmLimitType(tpmLimitType: Optional) = + tpmLimitType(tpmLimitType.getOrNull()) + + /** + * Sets [Builder.tpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimitType] with a well-typed [TpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tpmLimitType(tpmLimitType: JsonField) = apply { + this.tpmLimitType = tpmLimitType + } + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -1986,6 +3221,10 @@ private constructor( checkRequired("key", key), aliases, (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedPassthroughRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedVectorStoreIndexes ?: JsonMissing.of()).map { it.toImmutable() }, + autoRotate, blocked, budgetDuration, budgetId, @@ -2001,14 +3240,20 @@ private constructor( modelRpmLimit, modelTpmLimit, (models ?: JsonMissing.of()).map { it.toImmutable() }, + objectPermission, permissions, + (prompts ?: JsonMissing.of()).map { it.toImmutable() }, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, spend, (tags ?: JsonMissing.of()).map { it.toImmutable() }, teamId, tempBudgetExpiry, tempBudgetIncrease, tpmLimit, + tpmLimitType, userId, additionalProperties.toMutableMap(), ) @@ -2022,24 +3267,41 @@ private constructor( } key() + aliases().ifPresent { it.validate() } allowedCacheControls() + allowedPassthroughRoutes() + allowedRoutes() + allowedVectorStoreIndexes().ifPresent { it.forEach { it.validate() } } + autoRotate() blocked() budgetDuration() budgetId() + config().ifPresent { it.validate() } duration() enforcedParams() guardrails() keyAlias() maxBudget() maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelRpmLimit().ifPresent { it.validate() } + modelTpmLimit().ifPresent { it.validate() } models() + objectPermission().ifPresent { it.validate() } + permissions().ifPresent { it.validate() } + prompts() + rotationInterval() + routerSettings().ifPresent { it.validate() } rpmLimit() + rpmLimitType().ifPresent { it.validate() } spend() tags() teamId() tempBudgetExpiry() tempBudgetIncrease() tpmLimit() + tpmLimitType().ifPresent { it.validate() } userId() validated = true } @@ -2061,24 +3323,42 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (key.asKnown().isPresent) 1 else 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedPassthroughRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedVectorStoreIndexes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetId.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + (if (duration.asKnown().isPresent) 1 else 0) + (enforcedParams.asKnown().getOrNull()?.size ?: 0) + (guardrails.asKnown().getOrNull()?.size ?: 0) + (if (keyAlias.asKnown().isPresent) 1 else 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelRpmLimit.asKnown().getOrNull()?.validity() ?: 0) + + (modelTpmLimit.asKnown().getOrNull()?.validity() ?: 0) + (models.asKnown().getOrNull()?.size ?: 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (prompts.asKnown().getOrNull()?.size ?: 0) + + (if (rotationInterval.asKnown().isPresent) 1 else 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (rpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (spend.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (teamId.asKnown().isPresent) 1 else 0) + (if (tempBudgetExpiry.asKnown().isPresent) 1 else 0) + (if (tempBudgetIncrease.asKnown().isPresent) 1 else 0) + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (tpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (userId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2090,6 +3370,10 @@ private constructor( key == other.key && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && + allowedPassthroughRoutes == other.allowedPassthroughRoutes && + allowedRoutes == other.allowedRoutes && + allowedVectorStoreIndexes == other.allowedVectorStoreIndexes && + autoRotate == other.autoRotate && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetId == other.budgetId && @@ -2105,14 +3389,20 @@ private constructor( modelRpmLimit == other.modelRpmLimit && modelTpmLimit == other.modelTpmLimit && models == other.models && + objectPermission == other.objectPermission && permissions == other.permissions && + prompts == other.prompts && + rotationInterval == other.rotationInterval && + routerSettings == other.routerSettings && rpmLimit == other.rpmLimit && + rpmLimitType == other.rpmLimitType && spend == other.spend && tags == other.tags && teamId == other.teamId && tempBudgetExpiry == other.tempBudgetExpiry && tempBudgetIncrease == other.tempBudgetIncrease && tpmLimit == other.tpmLimit && + tpmLimitType == other.tpmLimitType && userId == other.userId && additionalProperties == other.additionalProperties } @@ -2122,6 +3412,10 @@ private constructor( key, aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + autoRotate, blocked, budgetDuration, budgetId, @@ -2137,14 +3431,20 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + objectPermission, permissions, + prompts, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, spend, tags, teamId, tempBudgetExpiry, tempBudgetIncrease, tpmLimit, + tpmLimitType, userId, additionalProperties, ) @@ -2153,7 +3453,3130 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{key=$key, aliases=$aliases, allowedCacheControls=$allowedCacheControls, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, keyAlias=$keyAlias, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, permissions=$permissions, rpmLimit=$rpmLimit, spend=$spend, tags=$tags, teamId=$teamId, tempBudgetExpiry=$tempBudgetExpiry, tempBudgetIncrease=$tempBudgetIncrease, tpmLimit=$tpmLimit, userId=$userId, additionalProperties=$additionalProperties}" + "Body{key=$key, aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedPassthroughRoutes=$allowedPassthroughRoutes, allowedRoutes=$allowedRoutes, allowedVectorStoreIndexes=$allowedVectorStoreIndexes, autoRotate=$autoRotate, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, keyAlias=$keyAlias, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, objectPermission=$objectPermission, permissions=$permissions, prompts=$prompts, rotationInterval=$rotationInterval, routerSettings=$routerSettings, rpmLimit=$rpmLimit, rpmLimitType=$rpmLimitType, spend=$spend, tags=$tags, teamId=$teamId, tempBudgetExpiry=$tempBudgetExpiry, tempBudgetIncrease=$tempBudgetIncrease, tpmLimit=$tpmLimit, tpmLimitType=$tpmLimitType, userId=$userId, additionalProperties=$additionalProperties}" + } + + class Aliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Aliases]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class AllowedVectorStoreIndex + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val indexName: JsonField, + private val indexPermissions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("index_name") + @ExcludeMissing + indexName: JsonField = JsonMissing.of(), + @JsonProperty("index_permissions") + @ExcludeMissing + indexPermissions: JsonField> = JsonMissing.of(), + ) : this(indexName, indexPermissions, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexName(): String = indexName.getRequired("index_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexPermissions(): List = + indexPermissions.getRequired("index_permissions") + + /** + * Returns the raw JSON value of [indexName]. + * + * Unlike [indexName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index_name") @ExcludeMissing fun _indexName(): JsonField = indexName + + /** + * Returns the raw JSON value of [indexPermissions]. + * + * Unlike [indexPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("index_permissions") + @ExcludeMissing + fun _indexPermissions(): JsonField> = indexPermissions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AllowedVectorStoreIndex]. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AllowedVectorStoreIndex]. */ + class Builder internal constructor() { + + private var indexName: JsonField? = null + private var indexPermissions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + indexName = allowedVectorStoreIndex.indexName + indexPermissions = + allowedVectorStoreIndex.indexPermissions.map { it.toMutableList() } + additionalProperties = allowedVectorStoreIndex.additionalProperties.toMutableMap() + } + + fun indexName(indexName: String) = indexName(JsonField.of(indexName)) + + /** + * Sets [Builder.indexName] to an arbitrary JSON value. + * + * You should usually call [Builder.indexName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun indexName(indexName: JsonField) = apply { this.indexName = indexName } + + fun indexPermissions(indexPermissions: List) = + indexPermissions(JsonField.of(indexPermissions)) + + /** + * Sets [Builder.indexPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.indexPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun indexPermissions(indexPermissions: JsonField>) = apply { + this.indexPermissions = indexPermissions.map { it.toMutableList() } + } + + /** + * Adds a single [IndexPermission] to [indexPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndexPermission(indexPermission: IndexPermission) = apply { + indexPermissions = + (indexPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("indexPermissions", it).add(indexPermission) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AllowedVectorStoreIndex]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AllowedVectorStoreIndex = + AllowedVectorStoreIndex( + checkRequired("indexName", indexName), + checkRequired("indexPermissions", indexPermissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AllowedVectorStoreIndex = apply { + if (validated) { + return@apply + } + + indexName() + indexPermissions().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (indexName.asKnown().isPresent) 1 else 0) + + (indexPermissions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class IndexPermission + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val READ = of("read") + + @JvmField val WRITE = of("write") + + @JvmStatic fun of(value: String) = IndexPermission(JsonField.of(value)) + } + + /** An enum containing [IndexPermission]'s known values. */ + enum class Known { + READ, + WRITE, + } + + /** + * An enum containing [IndexPermission]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IndexPermission] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + READ, + WRITE, + /** + * An enum member indicating that [IndexPermission] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + READ -> Value.READ + WRITE -> Value.WRITE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + READ -> Known.READ + WRITE -> Known.WRITE + else -> throw HanzoInvalidDataException("Unknown IndexPermission: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): IndexPermission = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexPermission && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedVectorStoreIndex && + indexName == other.indexName && + indexPermissions == other.indexPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(indexName, indexPermissions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AllowedVectorStoreIndex{indexName=$indexName, indexPermissions=$indexPermissions, additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelMaxBudget]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelRpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelRpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelRpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelRpmLimit: ModelRpmLimit) = apply { + additionalProperties = modelRpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelRpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelRpmLimit = ModelRpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelRpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelRpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelRpmLimit{additionalProperties=$additionalProperties}" + } + + class ModelTpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelTpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelTpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelTpmLimit: ModelTpmLimit) = apply { + additionalProperties = modelTpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelTpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelTpmLimit = ModelTpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelTpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelTpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelTpmLimit{additionalProperties=$additionalProperties}" + } + + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vectorStores(): Optional> = vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agents") @ExcludeMissing fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ObjectPermission]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + agentAccessGroups = objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** Alias for calling [Builder.mcpAccessGroups] with `mcpAccessGroups.orElse(null)`. */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ObjectPermission = + ObjectPermission( + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + /** Set of params that you can modify via `router.update_settings()`. */ + class RouterSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowedFails: JsonField, + private val contextWindowFallbacks: JsonField>, + private val cooldownTime: JsonField, + private val fallbacks: JsonField>, + private val maxRetries: JsonField, + private val modelGroupAlias: JsonField, + private val modelGroupRetryPolicy: JsonField, + private val numRetries: JsonField, + private val retryAfter: JsonField, + private val routingStrategy: JsonField, + private val routingStrategyArgs: JsonField, + private val timeout: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_fails") + @ExcludeMissing + allowedFails: JsonField = JsonMissing.of(), + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + contextWindowFallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("cooldown_time") + @ExcludeMissing + cooldownTime: JsonField = JsonMissing.of(), + @JsonProperty("fallbacks") + @ExcludeMissing + fallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("max_retries") + @ExcludeMissing + maxRetries: JsonField = JsonMissing.of(), + @JsonProperty("model_group_alias") + @ExcludeMissing + modelGroupAlias: JsonField = JsonMissing.of(), + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + modelGroupRetryPolicy: JsonField = JsonMissing.of(), + @JsonProperty("num_retries") + @ExcludeMissing + numRetries: JsonField = JsonMissing.of(), + @JsonProperty("retry_after") + @ExcludeMissing + retryAfter: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy") + @ExcludeMissing + routingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy_args") + @ExcludeMissing + routingStrategyArgs: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + ) : this( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedFails(): Optional = allowedFails.getOptional("allowed_fails") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbacks(): Optional> = + contextWindowFallbacks.getOptional("context_window_fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cooldownTime(): Optional = cooldownTime.getOptional("cooldown_time") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = fallbacks.getOptional("fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupAlias(): Optional = + modelGroupAlias.getOptional("model_group_alias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupRetryPolicy(): Optional = + modelGroupRetryPolicy.getOptional("model_group_retry_policy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = numRetries.getOptional("num_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun retryAfter(): Optional = retryAfter.getOptional("retry_after") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategy(): Optional = routingStrategy.getOptional("routing_strategy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategyArgs(): Optional = + routingStrategyArgs.getOptional("routing_strategy_args") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * Returns the raw JSON value of [allowedFails]. + * + * Unlike [allowedFails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_fails") + @ExcludeMissing + fun _allowedFails(): JsonField = allowedFails + + /** + * Returns the raw JSON value of [contextWindowFallbacks]. + * + * Unlike [contextWindowFallbacks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + fun _contextWindowFallbacks(): JsonField> = + contextWindowFallbacks + + /** + * Returns the raw JSON value of [cooldownTime]. + * + * Unlike [cooldownTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cooldown_time") + @ExcludeMissing + fun _cooldownTime(): JsonField = cooldownTime + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fallbacks") + @ExcludeMissing + fun _fallbacks(): JsonField> = fallbacks + + /** + * Returns the raw JSON value of [maxRetries]. + * + * Unlike [maxRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_retries") @ExcludeMissing fun _maxRetries(): JsonField = maxRetries + + /** + * Returns the raw JSON value of [modelGroupAlias]. + * + * Unlike [modelGroupAlias], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_group_alias") + @ExcludeMissing + fun _modelGroupAlias(): JsonField = modelGroupAlias + + /** + * Returns the raw JSON value of [modelGroupRetryPolicy]. + * + * Unlike [modelGroupRetryPolicy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + fun _modelGroupRetryPolicy(): JsonField = modelGroupRetryPolicy + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_retries") @ExcludeMissing fun _numRetries(): JsonField = numRetries + + /** + * Returns the raw JSON value of [retryAfter]. + * + * Unlike [retryAfter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retry_after") + @ExcludeMissing + fun _retryAfter(): JsonField = retryAfter + + /** + * Returns the raw JSON value of [routingStrategy]. + * + * Unlike [routingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_strategy") + @ExcludeMissing + fun _routingStrategy(): JsonField = routingStrategy + + /** + * Returns the raw JSON value of [routingStrategyArgs]. + * + * Unlike [routingStrategyArgs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routing_strategy_args") + @ExcludeMissing + fun _routingStrategyArgs(): JsonField = routingStrategyArgs + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RouterSettings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var allowedFails: JsonField = JsonMissing.of() + private var contextWindowFallbacks: JsonField>? = + null + private var cooldownTime: JsonField = JsonMissing.of() + private var fallbacks: JsonField>? = null + private var maxRetries: JsonField = JsonMissing.of() + private var modelGroupAlias: JsonField = JsonMissing.of() + private var modelGroupRetryPolicy: JsonField = JsonMissing.of() + private var numRetries: JsonField = JsonMissing.of() + private var retryAfter: JsonField = JsonMissing.of() + private var routingStrategy: JsonField = JsonMissing.of() + private var routingStrategyArgs: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + allowedFails = routerSettings.allowedFails + contextWindowFallbacks = + routerSettings.contextWindowFallbacks.map { it.toMutableList() } + cooldownTime = routerSettings.cooldownTime + fallbacks = routerSettings.fallbacks.map { it.toMutableList() } + maxRetries = routerSettings.maxRetries + modelGroupAlias = routerSettings.modelGroupAlias + modelGroupRetryPolicy = routerSettings.modelGroupRetryPolicy + numRetries = routerSettings.numRetries + retryAfter = routerSettings.retryAfter + routingStrategy = routerSettings.routingStrategy + routingStrategyArgs = routerSettings.routingStrategyArgs + timeout = routerSettings.timeout + additionalProperties = routerSettings.additionalProperties.toMutableMap() + } + + fun allowedFails(allowedFails: Long?) = allowedFails(JsonField.ofNullable(allowedFails)) + + /** + * Alias for [Builder.allowedFails]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allowedFails(allowedFails: Long) = allowedFails(allowedFails as Long?) + + /** Alias for calling [Builder.allowedFails] with `allowedFails.orElse(null)`. */ + fun allowedFails(allowedFails: Optional) = allowedFails(allowedFails.getOrNull()) + + /** + * Sets [Builder.allowedFails] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedFails] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedFails(allowedFails: JsonField) = apply { + this.allowedFails = allowedFails + } + + fun contextWindowFallbacks(contextWindowFallbacks: List?) = + contextWindowFallbacks(JsonField.ofNullable(contextWindowFallbacks)) + + /** + * Alias for calling [Builder.contextWindowFallbacks] with + * `contextWindowFallbacks.orElse(null)`. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: Optional> + ) = contextWindowFallbacks(contextWindowFallbacks.getOrNull()) + + /** + * Sets [Builder.contextWindowFallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbacks] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: JsonField> + ) = apply { + this.contextWindowFallbacks = contextWindowFallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [ContextWindowFallback] to [contextWindowFallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContextWindowFallback(contextWindowFallback: ContextWindowFallback) = apply { + contextWindowFallbacks = + (contextWindowFallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("contextWindowFallbacks", it).add(contextWindowFallback) + } + } + + fun cooldownTime(cooldownTime: Double?) = + cooldownTime(JsonField.ofNullable(cooldownTime)) + + /** + * Alias for [Builder.cooldownTime]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cooldownTime(cooldownTime: Double) = cooldownTime(cooldownTime as Double?) + + /** Alias for calling [Builder.cooldownTime] with `cooldownTime.orElse(null)`. */ + fun cooldownTime(cooldownTime: Optional) = + cooldownTime(cooldownTime.getOrNull()) + + /** + * Sets [Builder.cooldownTime] to an arbitrary JSON value. + * + * You should usually call [Builder.cooldownTime] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cooldownTime(cooldownTime: JsonField) = apply { + this.cooldownTime = cooldownTime + } + + fun fallbacks(fallbacks: List?) = fallbacks(JsonField.ofNullable(fallbacks)) + + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) + + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { + this.fallbacks = fallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [Fallback] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: Fallback) = apply { + fallbacks = + (fallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("fallbacks", it).add(fallback) + } + } + + fun maxRetries(maxRetries: Long?) = maxRetries(JsonField.ofNullable(maxRetries)) + + /** + * Alias for [Builder.maxRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxRetries(maxRetries: Long) = maxRetries(maxRetries as Long?) + + /** Alias for calling [Builder.maxRetries] with `maxRetries.orElse(null)`. */ + fun maxRetries(maxRetries: Optional) = maxRetries(maxRetries.getOrNull()) + + /** + * Sets [Builder.maxRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.maxRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxRetries(maxRetries: JsonField) = apply { this.maxRetries = maxRetries } + + fun modelGroupAlias(modelGroupAlias: ModelGroupAlias?) = + modelGroupAlias(JsonField.ofNullable(modelGroupAlias)) + + /** Alias for calling [Builder.modelGroupAlias] with `modelGroupAlias.orElse(null)`. */ + fun modelGroupAlias(modelGroupAlias: Optional) = + modelGroupAlias(modelGroupAlias.getOrNull()) + + /** + * Sets [Builder.modelGroupAlias] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupAlias] with a well-typed [ModelGroupAlias] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelGroupAlias(modelGroupAlias: JsonField) = apply { + this.modelGroupAlias = modelGroupAlias + } + + fun modelGroupRetryPolicy(modelGroupRetryPolicy: ModelGroupRetryPolicy?) = + modelGroupRetryPolicy(JsonField.ofNullable(modelGroupRetryPolicy)) + + /** + * Alias for calling [Builder.modelGroupRetryPolicy] with + * `modelGroupRetryPolicy.orElse(null)`. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: Optional) = + modelGroupRetryPolicy(modelGroupRetryPolicy.getOrNull()) + + /** + * Sets [Builder.modelGroupRetryPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupRetryPolicy] with a well-typed + * [ModelGroupRetryPolicy] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: JsonField) = + apply { + this.modelGroupRetryPolicy = modelGroupRetryPolicy + } + + fun numRetries(numRetries: Long?) = numRetries(JsonField.ofNullable(numRetries)) + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numRetries(numRetries: JsonField) = apply { this.numRetries = numRetries } + + fun retryAfter(retryAfter: Double?) = retryAfter(JsonField.ofNullable(retryAfter)) + + /** + * Alias for [Builder.retryAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun retryAfter(retryAfter: Double) = retryAfter(retryAfter as Double?) + + /** Alias for calling [Builder.retryAfter] with `retryAfter.orElse(null)`. */ + fun retryAfter(retryAfter: Optional) = retryAfter(retryAfter.getOrNull()) + + /** + * Sets [Builder.retryAfter] to an arbitrary JSON value. + * + * You should usually call [Builder.retryAfter] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retryAfter(retryAfter: JsonField) = apply { this.retryAfter = retryAfter } + + fun routingStrategy(routingStrategy: String?) = + routingStrategy(JsonField.ofNullable(routingStrategy)) + + /** Alias for calling [Builder.routingStrategy] with `routingStrategy.orElse(null)`. */ + fun routingStrategy(routingStrategy: Optional) = + routingStrategy(routingStrategy.getOrNull()) + + /** + * Sets [Builder.routingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routingStrategy(routingStrategy: JsonField) = apply { + this.routingStrategy = routingStrategy + } + + fun routingStrategyArgs(routingStrategyArgs: RoutingStrategyArgs?) = + routingStrategyArgs(JsonField.ofNullable(routingStrategyArgs)) + + /** + * Alias for calling [Builder.routingStrategyArgs] with + * `routingStrategyArgs.orElse(null)`. + */ + fun routingStrategyArgs(routingStrategyArgs: Optional) = + routingStrategyArgs(routingStrategyArgs.getOrNull()) + + /** + * Sets [Builder.routingStrategyArgs] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategyArgs] with a well-typed + * [RoutingStrategyArgs] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun routingStrategyArgs(routingStrategyArgs: JsonField) = apply { + this.routingStrategyArgs = routingStrategyArgs + } + + fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) + + /** + * Alias for [Builder.timeout]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun timeout(timeout: Double) = timeout(timeout as Double?) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = + RouterSettings( + allowedFails, + (contextWindowFallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + cooldownTime, + (fallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouterSettings = apply { + if (validated) { + return@apply + } + + allowedFails() + contextWindowFallbacks().ifPresent { it.forEach { it.validate() } } + cooldownTime() + fallbacks().ifPresent { it.forEach { it.validate() } } + maxRetries() + modelGroupAlias().ifPresent { it.validate() } + modelGroupRetryPolicy().ifPresent { it.validate() } + numRetries() + retryAfter() + routingStrategy() + routingStrategyArgs().ifPresent { it.validate() } + timeout() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowedFails.asKnown().isPresent) 1 else 0) + + (contextWindowFallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (cooldownTime.asKnown().isPresent) 1 else 0) + + (fallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maxRetries.asKnown().isPresent) 1 else 0) + + (modelGroupAlias.asKnown().getOrNull()?.validity() ?: 0) + + (modelGroupRetryPolicy.asKnown().getOrNull()?.validity() ?: 0) + + (if (numRetries.asKnown().isPresent) 1 else 0) + + (if (retryAfter.asKnown().isPresent) 1 else 0) + + (if (routingStrategy.asKnown().isPresent) 1 else 0) + + (routingStrategyArgs.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeout.asKnown().isPresent) 1 else 0) + + class ContextWindowFallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContextWindowFallback]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContextWindowFallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contextWindowFallback: ContextWindowFallback) = apply { + additionalProperties = contextWindowFallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContextWindowFallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContextWindowFallback = + ContextWindowFallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ContextWindowFallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContextWindowFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContextWindowFallback{additionalProperties=$additionalProperties}" + } + + class Fallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Fallback]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + additionalProperties = fallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Fallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Fallback = Fallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Fallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Fallback && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Fallback{additionalProperties=$additionalProperties}" + } + + class ModelGroupAlias + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelGroupAlias]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupAlias]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupAlias: ModelGroupAlias) = apply { + additionalProperties = modelGroupAlias.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupAlias]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupAlias = ModelGroupAlias(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupAlias = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupAlias && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelGroupAlias{additionalProperties=$additionalProperties}" + } + + class ModelGroupRetryPolicy + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelGroupRetryPolicy]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupRetryPolicy]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupRetryPolicy: ModelGroupRetryPolicy) = apply { + additionalProperties = modelGroupRetryPolicy.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupRetryPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupRetryPolicy = + ModelGroupRetryPolicy(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupRetryPolicy = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupRetryPolicy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelGroupRetryPolicy{additionalProperties=$additionalProperties}" + } + + class RoutingStrategyArgs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoutingStrategyArgs]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutingStrategyArgs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routingStrategyArgs: RoutingStrategyArgs) = apply { + additionalProperties = routingStrategyArgs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutingStrategyArgs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoutingStrategyArgs = + RoutingStrategyArgs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RoutingStrategyArgs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingStrategyArgs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutingStrategyArgs{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouterSettings && + allowedFails == other.allowedFails && + contextWindowFallbacks == other.contextWindowFallbacks && + cooldownTime == other.cooldownTime && + fallbacks == other.fallbacks && + maxRetries == other.maxRetries && + modelGroupAlias == other.modelGroupAlias && + modelGroupRetryPolicy == other.modelGroupRetryPolicy && + numRetries == other.numRetries && + retryAfter == other.retryAfter && + routingStrategy == other.routingStrategy && + routingStrategyArgs == other.routingStrategyArgs && + timeout == other.timeout && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouterSettings{allowedFails=$allowedFails, contextWindowFallbacks=$contextWindowFallbacks, cooldownTime=$cooldownTime, fallbacks=$fallbacks, maxRetries=$maxRetries, modelGroupAlias=$modelGroupAlias, modelGroupRetryPolicy=$modelGroupRetryPolicy, numRetries=$numRetries, retryAfter=$retryAfter, routingStrategy=$routingStrategy, routingStrategyArgs=$routingStrategyArgs, timeout=$timeout, additionalProperties=$additionalProperties}" + } + + class RpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = RpmLimitType(JsonField.of(value)) + } + + /** An enum containing [RpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [RpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [RpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown RpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = TpmLimitType(JsonField.of(value)) + } + + /** An enum containing [TpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [TpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [TpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown TpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2162,15 +6585,15 @@ private constructor( } return other is KeyUpdateParams && - llmChangedBy == other.llmChangedBy && + litellmChangedBy == other.litellmChangedBy && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(llmChangedBy, body, additionalHeaders, additionalQueryParams) + Objects.hash(litellmChangedBy, body, additionalHeaders, additionalQueryParams) override fun toString() = - "KeyUpdateParams{llmChangedBy=$llmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "KeyUpdateParams{litellmChangedBy=$litellmChangedBy, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt index 6a2bc94d..5cc188ed 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/key/regenerate/RegenerateKeyRequest.kt @@ -2,11 +2,13 @@ package ai.hanzo.api.models.key.regenerate +import ai.hanzo.api.core.Enum import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing import ai.hanzo.api.core.JsonValue import ai.hanzo.api.core.checkKnown +import ai.hanzo.api.core.checkRequired import ai.hanzo.api.core.toImmutable import ai.hanzo.api.errors.HanzoInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -21,49 +23,74 @@ import kotlin.jvm.optionals.getOrNull class RegenerateKeyRequest @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val aliases: JsonValue, + private val aliases: JsonField, private val allowedCacheControls: JsonField>, + private val allowedPassthroughRoutes: JsonField>, + private val allowedRoutes: JsonField>, + private val allowedVectorStoreIndexes: JsonField>, + private val autoRotate: JsonField, private val blocked: JsonField, private val budgetDuration: JsonField, private val budgetId: JsonField, - private val config: JsonValue, + private val config: JsonField, private val duration: JsonField, private val enforcedParams: JsonField>, private val guardrails: JsonField>, private val key: JsonField, private val keyAlias: JsonField, + private val keyType: JsonField, private val maxBudget: JsonField, private val maxParallelRequests: JsonField, - private val metadata: JsonValue, - private val modelMaxBudget: JsonValue, - private val modelRpmLimit: JsonValue, - private val modelTpmLimit: JsonValue, + private val metadata: JsonField, + private val modelMaxBudget: JsonField, + private val modelRpmLimit: JsonField, + private val modelTpmLimit: JsonField, private val models: JsonField>, + private val newKey: JsonField, private val newMasterKey: JsonField, - private val permissions: JsonValue, + private val objectPermission: JsonField, + private val organizationId: JsonField, + private val permissions: JsonField, + private val prompts: JsonField>, + private val rotationInterval: JsonField, + private val routerSettings: JsonField, private val rpmLimit: JsonField, + private val rpmLimitType: JsonField, private val sendInviteEmail: JsonField, private val softBudget: JsonField, private val spend: JsonField, private val tags: JsonField>, private val teamId: JsonField, private val tpmLimit: JsonField, + private val tpmLimitType: JsonField, private val userId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("aliases") @ExcludeMissing aliases: JsonValue = JsonMissing.of(), + @JsonProperty("aliases") @ExcludeMissing aliases: JsonField = JsonMissing.of(), @JsonProperty("allowed_cache_controls") @ExcludeMissing allowedCacheControls: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + allowedPassthroughRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_routes") + @ExcludeMissing + allowedRoutes: JsonField> = JsonMissing.of(), + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + allowedVectorStoreIndexes: JsonField> = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), @JsonProperty("blocked") @ExcludeMissing blocked: JsonField = JsonMissing.of(), @JsonProperty("budget_duration") @ExcludeMissing budgetDuration: JsonField = JsonMissing.of(), @JsonProperty("budget_id") @ExcludeMissing budgetId: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("enforced_params") @ExcludeMissing @@ -73,28 +100,50 @@ private constructor( guardrails: JsonField> = JsonMissing.of(), @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), @JsonProperty("key_alias") @ExcludeMissing keyAlias: JsonField = JsonMissing.of(), + @JsonProperty("key_type") @ExcludeMissing keyType: JsonField = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @JsonProperty("max_parallel_requests") @ExcludeMissing maxParallelRequests: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("model_max_budget") @ExcludeMissing - modelMaxBudget: JsonValue = JsonMissing.of(), + modelMaxBudget: JsonField = JsonMissing.of(), @JsonProperty("model_rpm_limit") @ExcludeMissing - modelRpmLimit: JsonValue = JsonMissing.of(), + modelRpmLimit: JsonField = JsonMissing.of(), @JsonProperty("model_tpm_limit") @ExcludeMissing - modelTpmLimit: JsonValue = JsonMissing.of(), + modelTpmLimit: JsonField = JsonMissing.of(), @JsonProperty("models") @ExcludeMissing models: JsonField> = JsonMissing.of(), + @JsonProperty("new_key") @ExcludeMissing newKey: JsonField = JsonMissing.of(), @JsonProperty("new_master_key") @ExcludeMissing newMasterKey: JsonField = JsonMissing.of(), - @JsonProperty("permissions") @ExcludeMissing permissions: JsonValue = JsonMissing.of(), + @JsonProperty("object_permission") + @ExcludeMissing + objectPermission: JsonField = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField = JsonMissing.of(), + @JsonProperty("prompts") + @ExcludeMissing + prompts: JsonField> = JsonMissing.of(), + @JsonProperty("rotation_interval") + @ExcludeMissing + rotationInterval: JsonField = JsonMissing.of(), + @JsonProperty("router_settings") + @ExcludeMissing + routerSettings: JsonField = JsonMissing.of(), @JsonProperty("rpm_limit") @ExcludeMissing rpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("rpm_limit_type") + @ExcludeMissing + rpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("send_invite_email") @ExcludeMissing sendInviteEmail: JsonField = JsonMissing.of(), @@ -105,10 +154,17 @@ private constructor( @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("team_id") @ExcludeMissing teamId: JsonField = JsonMissing.of(), @JsonProperty("tpm_limit") @ExcludeMissing tpmLimit: JsonField = JsonMissing.of(), + @JsonProperty("tpm_limit_type") + @ExcludeMissing + tpmLimitType: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), ) : this( aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + autoRotate, blocked, budgetDuration, budgetId, @@ -118,6 +174,7 @@ private constructor( guardrails, key, keyAlias, + keyType, maxBudget, maxParallelRequests, metadata, @@ -125,20 +182,32 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + newKey, newMasterKey, + objectPermission, + organizationId, permissions, + prompts, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, sendInviteEmail, softBudget, spend, tags, teamId, tpmLimit, + tpmLimitType, userId, mutableMapOf(), ) - @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonValue = aliases + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aliases(): Optional = aliases.getOptional("aliases") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -147,6 +216,34 @@ private constructor( fun allowedCacheControls(): Optional> = allowedCacheControls.getOptional("allowed_cache_controls") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedPassthroughRoutes(): Optional> = + allowedPassthroughRoutes.getOptional("allowed_passthrough_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedRoutes(): Optional> = allowedRoutes.getOptional("allowed_routes") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedVectorStoreIndexes(): Optional> = + allowedVectorStoreIndexes.getOptional("allowed_vector_store_indexes") + + /** + * Whether this key should be automatically rotated + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -165,7 +262,11 @@ private constructor( */ fun budgetId(): Optional = budgetId.getOptional("budget_id") - @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -197,6 +298,14 @@ private constructor( */ fun keyAlias(): Optional = keyAlias.getOptional("key_alias") + /** + * Enum for key types that determine what routes a key can access + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun keyType(): Optional = keyType.getOptional("key_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -210,15 +319,29 @@ private constructor( fun maxParallelRequests(): Optional = maxParallelRequests.getOptional("max_parallel_requests") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("model_max_budget") - @ExcludeMissing - fun _modelMaxBudget(): JsonValue = modelMaxBudget + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelMaxBudget(): Optional = modelMaxBudget.getOptional("model_max_budget") - @JsonProperty("model_rpm_limit") @ExcludeMissing fun _modelRpmLimit(): JsonValue = modelRpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelRpmLimit(): Optional = modelRpmLimit.getOptional("model_rpm_limit") - @JsonProperty("model_tpm_limit") @ExcludeMissing fun _modelTpmLimit(): JsonValue = modelTpmLimit + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelTpmLimit(): Optional = modelTpmLimit.getOptional("model_tpm_limit") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -226,13 +349,58 @@ private constructor( */ fun models(): Optional> = models.getOptional("models") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun newKey(): Optional = newKey.getOptional("new_key") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun newMasterKey(): Optional = newMasterKey.getOptional("new_master_key") - @JsonProperty("permissions") @ExcludeMissing fun _permissions(): JsonValue = permissions + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun objectPermission(): Optional = + objectPermission.getOptional("object_permission") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun organizationId(): Optional = organizationId.getOptional("organization_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional = permissions.getOptional("permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prompts(): Optional> = prompts.getOptional("prompts") + + /** + * How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotationInterval(): Optional = rotationInterval.getOptional("rotation_interval") + + /** + * Set of params that you can modify via `router.update_settings()`. + * + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routerSettings(): Optional = routerSettings.getOptional("router_settings") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -240,6 +408,12 @@ private constructor( */ fun rpmLimit(): Optional = rpmLimit.getOptional("rpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpmLimitType(): Optional = rpmLimitType.getOptional("rpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -276,12 +450,25 @@ private constructor( */ fun tpmLimit(): Optional = tpmLimit.getOptional("tpm_limit") + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tpmLimitType(): Optional = tpmLimitType.getOptional("tpm_limit_type") + /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun userId(): Optional = userId.getOptional("user_id") + /** + * Returns the raw JSON value of [aliases]. + * + * Unlike [aliases], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aliases") @ExcludeMissing fun _aliases(): JsonField = aliases + /** * Returns the raw JSON value of [allowedCacheControls]. * @@ -292,6 +479,43 @@ private constructor( @ExcludeMissing fun _allowedCacheControls(): JsonField> = allowedCacheControls + /** + * Returns the raw JSON value of [allowedPassthroughRoutes]. + * + * Unlike [allowedPassthroughRoutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_passthrough_routes") + @ExcludeMissing + fun _allowedPassthroughRoutes(): JsonField> = allowedPassthroughRoutes + + /** + * Returns the raw JSON value of [allowedRoutes]. + * + * Unlike [allowedRoutes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed_routes") + @ExcludeMissing + fun _allowedRoutes(): JsonField> = allowedRoutes + + /** + * Returns the raw JSON value of [allowedVectorStoreIndexes]. + * + * Unlike [allowedVectorStoreIndexes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowed_vector_store_indexes") + @ExcludeMissing + fun _allowedVectorStoreIndexes(): JsonField> = + allowedVectorStoreIndexes + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_rotate") @ExcludeMissing fun _autoRotate(): JsonField = autoRotate + /** * Returns the raw JSON value of [blocked]. * @@ -315,6 +539,13 @@ private constructor( */ @JsonProperty("budget_id") @ExcludeMissing fun _budgetId(): JsonField = budgetId + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + /** * Returns the raw JSON value of [duration]. * @@ -354,6 +585,13 @@ private constructor( */ @JsonProperty("key_alias") @ExcludeMissing fun _keyAlias(): JsonField = keyAlias + /** + * Returns the raw JSON value of [keyType]. + * + * Unlike [keyType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key_type") @ExcludeMissing fun _keyType(): JsonField = keyType + /** * Returns the raw JSON value of [maxBudget]. * @@ -371,6 +609,40 @@ private constructor( @ExcludeMissing fun _maxParallelRequests(): JsonField = maxParallelRequests + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [modelMaxBudget]. + * + * Unlike [modelMaxBudget], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_max_budget") + @ExcludeMissing + fun _modelMaxBudget(): JsonField = modelMaxBudget + + /** + * Returns the raw JSON value of [modelRpmLimit]. + * + * Unlike [modelRpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_rpm_limit") + @ExcludeMissing + fun _modelRpmLimit(): JsonField = modelRpmLimit + + /** + * Returns the raw JSON value of [modelTpmLimit]. + * + * Unlike [modelTpmLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_tpm_limit") + @ExcludeMissing + fun _modelTpmLimit(): JsonField = modelTpmLimit + /** * Returns the raw JSON value of [models]. * @@ -378,6 +650,13 @@ private constructor( */ @JsonProperty("models") @ExcludeMissing fun _models(): JsonField> = models + /** + * Returns the raw JSON value of [newKey]. + * + * Unlike [newKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("new_key") @ExcludeMissing fun _newKey(): JsonField = newKey + /** * Returns the raw JSON value of [newMasterKey]. * @@ -387,6 +666,60 @@ private constructor( @ExcludeMissing fun _newMasterKey(): JsonField = newMasterKey + /** + * Returns the raw JSON value of [objectPermission]. + * + * Unlike [objectPermission], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object_permission") + @ExcludeMissing + fun _objectPermission(): JsonField = objectPermission + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField = organizationId + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField = permissions + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompts") @ExcludeMissing fun _prompts(): JsonField> = prompts + + /** + * Returns the raw JSON value of [rotationInterval]. + * + * Unlike [rotationInterval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rotation_interval") + @ExcludeMissing + fun _rotationInterval(): JsonField = rotationInterval + + /** + * Returns the raw JSON value of [routerSettings]. + * + * Unlike [routerSettings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("router_settings") + @ExcludeMissing + fun _routerSettings(): JsonField = routerSettings + /** * Returns the raw JSON value of [rpmLimit]. * @@ -394,6 +727,15 @@ private constructor( */ @JsonProperty("rpm_limit") @ExcludeMissing fun _rpmLimit(): JsonField = rpmLimit + /** + * Returns the raw JSON value of [rpmLimitType]. + * + * Unlike [rpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rpm_limit_type") + @ExcludeMissing + fun _rpmLimitType(): JsonField = rpmLimitType + /** * Returns the raw JSON value of [sendInviteEmail]. * @@ -438,6 +780,15 @@ private constructor( */ @JsonProperty("tpm_limit") @ExcludeMissing fun _tpmLimit(): JsonField = tpmLimit + /** + * Returns the raw JSON value of [tpmLimitType]. + * + * Unlike [tpmLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tpm_limit_type") + @ExcludeMissing + fun _tpmLimitType(): JsonField = tpmLimitType + /** * Returns the raw JSON value of [userId]. * @@ -466,33 +817,47 @@ private constructor( /** A builder for [RegenerateKeyRequest]. */ class Builder internal constructor() { - private var aliases: JsonValue = JsonMissing.of() + private var aliases: JsonField = JsonMissing.of() private var allowedCacheControls: JsonField>? = null + private var allowedPassthroughRoutes: JsonField>? = null + private var allowedRoutes: JsonField>? = null + private var allowedVectorStoreIndexes: JsonField>? = + null + private var autoRotate: JsonField = JsonMissing.of() private var blocked: JsonField = JsonMissing.of() private var budgetDuration: JsonField = JsonMissing.of() private var budgetId: JsonField = JsonMissing.of() - private var config: JsonValue = JsonMissing.of() + private var config: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var enforcedParams: JsonField>? = null private var guardrails: JsonField>? = null private var key: JsonField = JsonMissing.of() private var keyAlias: JsonField = JsonMissing.of() + private var keyType: JsonField = JsonMissing.of() private var maxBudget: JsonField = JsonMissing.of() private var maxParallelRequests: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var modelMaxBudget: JsonValue = JsonMissing.of() - private var modelRpmLimit: JsonValue = JsonMissing.of() - private var modelTpmLimit: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var modelMaxBudget: JsonField = JsonMissing.of() + private var modelRpmLimit: JsonField = JsonMissing.of() + private var modelTpmLimit: JsonField = JsonMissing.of() private var models: JsonField>? = null + private var newKey: JsonField = JsonMissing.of() private var newMasterKey: JsonField = JsonMissing.of() - private var permissions: JsonValue = JsonMissing.of() + private var objectPermission: JsonField = JsonMissing.of() + private var organizationId: JsonField = JsonMissing.of() + private var permissions: JsonField = JsonMissing.of() + private var prompts: JsonField>? = null + private var rotationInterval: JsonField = JsonMissing.of() + private var routerSettings: JsonField = JsonMissing.of() private var rpmLimit: JsonField = JsonMissing.of() + private var rpmLimitType: JsonField = JsonMissing.of() private var sendInviteEmail: JsonField = JsonMissing.of() private var softBudget: JsonField = JsonMissing.of() private var spend: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var teamId: JsonField = JsonMissing.of() private var tpmLimit: JsonField = JsonMissing.of() + private var tpmLimitType: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +866,12 @@ private constructor( aliases = regenerateKeyRequest.aliases allowedCacheControls = regenerateKeyRequest.allowedCacheControls.map { it.toMutableList() } + allowedPassthroughRoutes = + regenerateKeyRequest.allowedPassthroughRoutes.map { it.toMutableList() } + allowedRoutes = regenerateKeyRequest.allowedRoutes.map { it.toMutableList() } + allowedVectorStoreIndexes = + regenerateKeyRequest.allowedVectorStoreIndexes.map { it.toMutableList() } + autoRotate = regenerateKeyRequest.autoRotate blocked = regenerateKeyRequest.blocked budgetDuration = regenerateKeyRequest.budgetDuration budgetId = regenerateKeyRequest.budgetId @@ -510,6 +881,7 @@ private constructor( guardrails = regenerateKeyRequest.guardrails.map { it.toMutableList() } key = regenerateKeyRequest.key keyAlias = regenerateKeyRequest.keyAlias + keyType = regenerateKeyRequest.keyType maxBudget = regenerateKeyRequest.maxBudget maxParallelRequests = regenerateKeyRequest.maxParallelRequests metadata = regenerateKeyRequest.metadata @@ -517,20 +889,39 @@ private constructor( modelRpmLimit = regenerateKeyRequest.modelRpmLimit modelTpmLimit = regenerateKeyRequest.modelTpmLimit models = regenerateKeyRequest.models.map { it.toMutableList() } + newKey = regenerateKeyRequest.newKey newMasterKey = regenerateKeyRequest.newMasterKey + objectPermission = regenerateKeyRequest.objectPermission + organizationId = regenerateKeyRequest.organizationId permissions = regenerateKeyRequest.permissions + prompts = regenerateKeyRequest.prompts.map { it.toMutableList() } + rotationInterval = regenerateKeyRequest.rotationInterval + routerSettings = regenerateKeyRequest.routerSettings rpmLimit = regenerateKeyRequest.rpmLimit + rpmLimitType = regenerateKeyRequest.rpmLimitType sendInviteEmail = regenerateKeyRequest.sendInviteEmail softBudget = regenerateKeyRequest.softBudget spend = regenerateKeyRequest.spend tags = regenerateKeyRequest.tags.map { it.toMutableList() } teamId = regenerateKeyRequest.teamId tpmLimit = regenerateKeyRequest.tpmLimit + tpmLimitType = regenerateKeyRequest.tpmLimitType userId = regenerateKeyRequest.userId additionalProperties = regenerateKeyRequest.additionalProperties.toMutableMap() } - fun aliases(aliases: JsonValue) = apply { this.aliases = aliases } + fun aliases(aliases: Aliases?) = aliases(JsonField.ofNullable(aliases)) + + /** Alias for calling [Builder.aliases] with `aliases.orElse(null)`. */ + fun aliases(aliases: Optional) = aliases(aliases.getOrNull()) + + /** + * Sets [Builder.aliases] to an arbitrary JSON value. + * + * You should usually call [Builder.aliases] with a well-typed [Aliases] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun aliases(aliases: JsonField) = apply { this.aliases = aliases } fun allowedCacheControls(allowedCacheControls: List?) = allowedCacheControls(JsonField.ofNullable(allowedCacheControls)) @@ -565,60 +956,192 @@ private constructor( } } - fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) + fun allowedPassthroughRoutes(allowedPassthroughRoutes: List?) = + allowedPassthroughRoutes(JsonField.ofNullable(allowedPassthroughRoutes)) /** - * Alias for [Builder.blocked]. - * - * This unboxed primitive overload exists for backwards compatibility. + * Alias for calling [Builder.allowedPassthroughRoutes] with + * `allowedPassthroughRoutes.orElse(null)`. */ - fun blocked(blocked: Boolean) = blocked(blocked as Boolean?) + fun allowedPassthroughRoutes(allowedPassthroughRoutes: Optional>) = + allowedPassthroughRoutes(allowedPassthroughRoutes.getOrNull()) - /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ - fun blocked(blocked: Optional) = blocked(blocked.getOrNull()) + /** + * Sets [Builder.allowedPassthroughRoutes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedPassthroughRoutes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowedPassthroughRoutes(allowedPassthroughRoutes: JsonField>) = apply { + this.allowedPassthroughRoutes = allowedPassthroughRoutes.map { it.toMutableList() } + } /** - * Sets [Builder.blocked] to an arbitrary JSON value. + * Adds a single [JsonValue] to [allowedPassthroughRoutes]. * - * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun blocked(blocked: JsonField) = apply { this.blocked = blocked } + fun addAllowedPassthroughRoute(allowedPassthroughRoute: JsonValue) = apply { + allowedPassthroughRoutes = + (allowedPassthroughRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedPassthroughRoutes", it).add(allowedPassthroughRoute) + } + } - fun budgetDuration(budgetDuration: String?) = - budgetDuration(JsonField.ofNullable(budgetDuration)) + fun allowedRoutes(allowedRoutes: List?) = + allowedRoutes(JsonField.ofNullable(allowedRoutes)) - /** Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. */ - fun budgetDuration(budgetDuration: Optional) = - budgetDuration(budgetDuration.getOrNull()) + /** Alias for calling [Builder.allowedRoutes] with `allowedRoutes.orElse(null)`. */ + fun allowedRoutes(allowedRoutes: Optional>) = + allowedRoutes(allowedRoutes.getOrNull()) /** - * Sets [Builder.budgetDuration] to an arbitrary JSON value. + * Sets [Builder.allowedRoutes] to an arbitrary JSON value. * - * You should usually call [Builder.budgetDuration] with a well-typed [String] value + * You should usually call [Builder.allowedRoutes] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun budgetDuration(budgetDuration: JsonField) = apply { - this.budgetDuration = budgetDuration + fun allowedRoutes(allowedRoutes: JsonField>) = apply { + this.allowedRoutes = allowedRoutes.map { it.toMutableList() } } - fun budgetId(budgetId: String?) = budgetId(JsonField.ofNullable(budgetId)) - - /** Alias for calling [Builder.budgetId] with `budgetId.orElse(null)`. */ - fun budgetId(budgetId: Optional) = budgetId(budgetId.getOrNull()) - /** - * Sets [Builder.budgetId] to an arbitrary JSON value. + * Adds a single [JsonValue] to [allowedRoutes]. * - * You should usually call [Builder.budgetId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } - - fun config(config: JsonValue) = apply { this.config = config } + fun addAllowedRoute(allowedRoute: JsonValue) = apply { + allowedRoutes = + (allowedRoutes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedRoutes", it).add(allowedRoute) + } + } - fun duration(duration: String?) = duration(JsonField.ofNullable(duration)) + fun allowedVectorStoreIndexes(allowedVectorStoreIndexes: List?) = + allowedVectorStoreIndexes(JsonField.ofNullable(allowedVectorStoreIndexes)) + + /** + * Alias for calling [Builder.allowedVectorStoreIndexes] with + * `allowedVectorStoreIndexes.orElse(null)`. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: Optional> + ) = allowedVectorStoreIndexes(allowedVectorStoreIndexes.getOrNull()) + + /** + * Sets [Builder.allowedVectorStoreIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedVectorStoreIndexes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun allowedVectorStoreIndexes( + allowedVectorStoreIndexes: JsonField> + ) = apply { + this.allowedVectorStoreIndexes = allowedVectorStoreIndexes.map { it.toMutableList() } + } + + /** + * Adds a single [AllowedVectorStoreIndex] to [allowedVectorStoreIndexes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedVectorStoreIndex(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + allowedVectorStoreIndexes = + (allowedVectorStoreIndexes ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedVectorStoreIndexes", it).add(allowedVectorStoreIndex) + } + } + + /** Whether this key should be automatically rotated */ + fun autoRotate(autoRotate: Boolean?) = autoRotate(JsonField.ofNullable(autoRotate)) + + /** + * Alias for [Builder.autoRotate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoRotate(autoRotate: Boolean) = autoRotate(autoRotate as Boolean?) + + /** Alias for calling [Builder.autoRotate] with `autoRotate.orElse(null)`. */ + fun autoRotate(autoRotate: Optional) = autoRotate(autoRotate.getOrNull()) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoRotate(autoRotate: JsonField) = apply { this.autoRotate = autoRotate } + + fun blocked(blocked: Boolean?) = blocked(JsonField.ofNullable(blocked)) + + /** + * Alias for [Builder.blocked]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun blocked(blocked: Boolean) = blocked(blocked as Boolean?) + + /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ + fun blocked(blocked: Optional) = blocked(blocked.getOrNull()) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun blocked(blocked: JsonField) = apply { this.blocked = blocked } + + fun budgetDuration(budgetDuration: String?) = + budgetDuration(JsonField.ofNullable(budgetDuration)) + + /** Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. */ + fun budgetDuration(budgetDuration: Optional) = + budgetDuration(budgetDuration.getOrNull()) + + /** + * Sets [Builder.budgetDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetDuration] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun budgetDuration(budgetDuration: JsonField) = apply { + this.budgetDuration = budgetDuration + } + + fun budgetId(budgetId: String?) = budgetId(JsonField.ofNullable(budgetId)) + + /** Alias for calling [Builder.budgetId] with `budgetId.orElse(null)`. */ + fun budgetId(budgetId: Optional) = budgetId(budgetId.getOrNull()) + + /** + * Sets [Builder.budgetId] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun budgetId(budgetId: JsonField) = apply { this.budgetId = budgetId } + + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + fun duration(duration: String?) = duration(JsonField.ofNullable(duration)) /** Alias for calling [Builder.duration] with `duration.orElse(null)`. */ fun duration(duration: Optional) = duration(duration.getOrNull()) @@ -715,6 +1238,20 @@ private constructor( */ fun keyAlias(keyAlias: JsonField) = apply { this.keyAlias = keyAlias } + /** Enum for key types that determine what routes a key can access */ + fun keyType(keyType: KeyType?) = keyType(JsonField.ofNullable(keyType)) + + /** Alias for calling [Builder.keyType] with `keyType.orElse(null)`. */ + fun keyType(keyType: Optional) = keyType(keyType.getOrNull()) + + /** + * Sets [Builder.keyType] to an arbitrary JSON value. + * + * You should usually call [Builder.keyType] with a well-typed [KeyType] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun keyType(keyType: JsonField) = apply { this.keyType = keyType } + fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) /** @@ -764,15 +1301,73 @@ private constructor( this.maxParallelRequests = maxParallelRequests } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun modelMaxBudget(modelMaxBudget: JsonValue) = apply { + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun modelMaxBudget(modelMaxBudget: ModelMaxBudget?) = + modelMaxBudget(JsonField.ofNullable(modelMaxBudget)) + + /** Alias for calling [Builder.modelMaxBudget] with `modelMaxBudget.orElse(null)`. */ + fun modelMaxBudget(modelMaxBudget: Optional) = + modelMaxBudget(modelMaxBudget.getOrNull()) + + /** + * Sets [Builder.modelMaxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.modelMaxBudget] with a well-typed [ModelMaxBudget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelMaxBudget(modelMaxBudget: JsonField) = apply { this.modelMaxBudget = modelMaxBudget } - fun modelRpmLimit(modelRpmLimit: JsonValue) = apply { this.modelRpmLimit = modelRpmLimit } + fun modelRpmLimit(modelRpmLimit: ModelRpmLimit?) = + modelRpmLimit(JsonField.ofNullable(modelRpmLimit)) + + /** Alias for calling [Builder.modelRpmLimit] with `modelRpmLimit.orElse(null)`. */ + fun modelRpmLimit(modelRpmLimit: Optional) = + modelRpmLimit(modelRpmLimit.getOrNull()) + + /** + * Sets [Builder.modelRpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelRpmLimit] with a well-typed [ModelRpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelRpmLimit(modelRpmLimit: JsonField) = apply { + this.modelRpmLimit = modelRpmLimit + } + + fun modelTpmLimit(modelTpmLimit: ModelTpmLimit?) = + modelTpmLimit(JsonField.ofNullable(modelTpmLimit)) - fun modelTpmLimit(modelTpmLimit: JsonValue) = apply { this.modelTpmLimit = modelTpmLimit } + /** Alias for calling [Builder.modelTpmLimit] with `modelTpmLimit.orElse(null)`. */ + fun modelTpmLimit(modelTpmLimit: Optional) = + modelTpmLimit(modelTpmLimit.getOrNull()) + + /** + * Sets [Builder.modelTpmLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.modelTpmLimit] with a well-typed [ModelTpmLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelTpmLimit(modelTpmLimit: JsonField) = apply { + this.modelTpmLimit = modelTpmLimit + } fun models(models: List?) = models(JsonField.ofNullable(models)) @@ -802,6 +1397,19 @@ private constructor( } } + fun newKey(newKey: String?) = newKey(JsonField.ofNullable(newKey)) + + /** Alias for calling [Builder.newKey] with `newKey.orElse(null)`. */ + fun newKey(newKey: Optional) = newKey(newKey.getOrNull()) + + /** + * Sets [Builder.newKey] to an arbitrary JSON value. + * + * You should usually call [Builder.newKey] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun newKey(newKey: JsonField) = apply { this.newKey = newKey } + fun newMasterKey(newMasterKey: String?) = newMasterKey(JsonField.ofNullable(newMasterKey)) /** Alias for calling [Builder.newMasterKey] with `newMasterKey.orElse(null)`. */ @@ -818,7 +1426,123 @@ private constructor( this.newMasterKey = newMasterKey } - fun permissions(permissions: JsonValue) = apply { this.permissions = permissions } + fun objectPermission(objectPermission: ObjectPermission?) = + objectPermission(JsonField.ofNullable(objectPermission)) + + /** Alias for calling [Builder.objectPermission] with `objectPermission.orElse(null)`. */ + fun objectPermission(objectPermission: Optional) = + objectPermission(objectPermission.getOrNull()) + + /** + * Sets [Builder.objectPermission] to an arbitrary JSON value. + * + * You should usually call [Builder.objectPermission] with a well-typed [ObjectPermission] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun objectPermission(objectPermission: JsonField) = apply { + this.objectPermission = objectPermission + } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField) = apply { + this.organizationId = organizationId + } + + fun permissions(permissions: Permissions?) = permissions(JsonField.ofNullable(permissions)) + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional) = permissions(permissions.getOrNull()) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed [Permissions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField) = apply { + this.permissions = permissions + } + + fun prompts(prompts: List?) = prompts(JsonField.ofNullable(prompts)) + + /** Alias for calling [Builder.prompts] with `prompts.orElse(null)`. */ + fun prompts(prompts: Optional>) = prompts(prompts.getOrNull()) + + /** + * Sets [Builder.prompts] to an arbitrary JSON value. + * + * You should usually call [Builder.prompts] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prompts(prompts: JsonField>) = apply { + this.prompts = prompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [prompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: String) = apply { + prompts = + (prompts ?: JsonField.of(mutableListOf())).also { + checkKnown("prompts", it).add(prompt) + } + } + + /** How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True */ + fun rotationInterval(rotationInterval: String?) = + rotationInterval(JsonField.ofNullable(rotationInterval)) + + /** Alias for calling [Builder.rotationInterval] with `rotationInterval.orElse(null)`. */ + fun rotationInterval(rotationInterval: Optional) = + rotationInterval(rotationInterval.getOrNull()) + + /** + * Sets [Builder.rotationInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.rotationInterval] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rotationInterval(rotationInterval: JsonField) = apply { + this.rotationInterval = rotationInterval + } + + /** Set of params that you can modify via `router.update_settings()`. */ + fun routerSettings(routerSettings: RouterSettings?) = + routerSettings(JsonField.ofNullable(routerSettings)) + + /** Alias for calling [Builder.routerSettings] with `routerSettings.orElse(null)`. */ + fun routerSettings(routerSettings: Optional) = + routerSettings(routerSettings.getOrNull()) + + /** + * Sets [Builder.routerSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.routerSettings] with a well-typed [RouterSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routerSettings(routerSettings: JsonField) = apply { + this.routerSettings = routerSettings + } fun rpmLimit(rpmLimit: Long?) = rpmLimit(JsonField.ofNullable(rpmLimit)) @@ -840,6 +1564,24 @@ private constructor( */ fun rpmLimit(rpmLimit: JsonField) = apply { this.rpmLimit = rpmLimit } + fun rpmLimitType(rpmLimitType: RpmLimitType?) = + rpmLimitType(JsonField.ofNullable(rpmLimitType)) + + /** Alias for calling [Builder.rpmLimitType] with `rpmLimitType.orElse(null)`. */ + fun rpmLimitType(rpmLimitType: Optional) = + rpmLimitType(rpmLimitType.getOrNull()) + + /** + * Sets [Builder.rpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.rpmLimitType] with a well-typed [RpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rpmLimitType(rpmLimitType: JsonField) = apply { + this.rpmLimitType = rpmLimitType + } + fun sendInviteEmail(sendInviteEmail: Boolean?) = sendInviteEmail(JsonField.ofNullable(sendInviteEmail)) @@ -964,6 +1706,24 @@ private constructor( */ fun tpmLimit(tpmLimit: JsonField) = apply { this.tpmLimit = tpmLimit } + fun tpmLimitType(tpmLimitType: TpmLimitType?) = + tpmLimitType(JsonField.ofNullable(tpmLimitType)) + + /** Alias for calling [Builder.tpmLimitType] with `tpmLimitType.orElse(null)`. */ + fun tpmLimitType(tpmLimitType: Optional) = + tpmLimitType(tpmLimitType.getOrNull()) + + /** + * Sets [Builder.tpmLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.tpmLimitType] with a well-typed [TpmLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tpmLimitType(tpmLimitType: JsonField) = apply { + this.tpmLimitType = tpmLimitType + } + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -1005,6 +1765,10 @@ private constructor( RegenerateKeyRequest( aliases, (allowedCacheControls ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedPassthroughRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedRoutes ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedVectorStoreIndexes ?: JsonMissing.of()).map { it.toImmutable() }, + autoRotate, blocked, budgetDuration, budgetId, @@ -1014,6 +1778,7 @@ private constructor( (guardrails ?: JsonMissing.of()).map { it.toImmutable() }, key, keyAlias, + keyType, maxBudget, maxParallelRequests, metadata, @@ -1021,15 +1786,23 @@ private constructor( modelRpmLimit, modelTpmLimit, (models ?: JsonMissing.of()).map { it.toImmutable() }, + newKey, newMasterKey, + objectPermission, + organizationId, permissions, + (prompts ?: JsonMissing.of()).map { it.toImmutable() }, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, sendInviteEmail, softBudget, spend, (tags ?: JsonMissing.of()).map { it.toImmutable() }, teamId, tpmLimit, + tpmLimitType, userId, additionalProperties.toMutableMap(), ) @@ -1042,26 +1815,46 @@ private constructor( return@apply } + aliases().ifPresent { it.validate() } allowedCacheControls() + allowedPassthroughRoutes() + allowedRoutes() + allowedVectorStoreIndexes().ifPresent { it.forEach { it.validate() } } + autoRotate() blocked() budgetDuration() budgetId() + config().ifPresent { it.validate() } duration() enforcedParams() guardrails() key() keyAlias() + keyType().ifPresent { it.validate() } maxBudget() maxParallelRequests() + metadata().ifPresent { it.validate() } + modelMaxBudget().ifPresent { it.validate() } + modelRpmLimit().ifPresent { it.validate() } + modelTpmLimit().ifPresent { it.validate() } models() + newKey() newMasterKey() + objectPermission().ifPresent { it.validate() } + organizationId() + permissions().ifPresent { it.validate() } + prompts() + rotationInterval() + routerSettings().ifPresent { it.validate() } rpmLimit() + rpmLimitType().ifPresent { it.validate() } sendInviteEmail() softBudget() spend() tags() teamId() tpmLimit() + tpmLimitType().ifPresent { it.validate() } userId() validated = true } @@ -1081,28 +1874,3309 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (aliases.asKnown().getOrNull()?.validity() ?: 0) + + (allowedCacheControls.asKnown().getOrNull()?.size ?: 0) + + (allowedPassthroughRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedRoutes.asKnown().getOrNull()?.size ?: 0) + + (allowedVectorStoreIndexes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + (if (blocked.asKnown().isPresent) 1 else 0) + (if (budgetDuration.asKnown().isPresent) 1 else 0) + (if (budgetId.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + (if (duration.asKnown().isPresent) 1 else 0) + (enforcedParams.asKnown().getOrNull()?.size ?: 0) + (guardrails.asKnown().getOrNull()?.size ?: 0) + (if (key.asKnown().isPresent) 1 else 0) + (if (keyAlias.asKnown().isPresent) 1 else 0) + + (keyType.asKnown().getOrNull()?.validity() ?: 0) + (if (maxBudget.asKnown().isPresent) 1 else 0) + (if (maxParallelRequests.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (modelMaxBudget.asKnown().getOrNull()?.validity() ?: 0) + + (modelRpmLimit.asKnown().getOrNull()?.validity() ?: 0) + + (modelTpmLimit.asKnown().getOrNull()?.validity() ?: 0) + (models.asKnown().getOrNull()?.size ?: 0) + + (if (newKey.asKnown().isPresent) 1 else 0) + (if (newMasterKey.asKnown().isPresent) 1 else 0) + + (objectPermission.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.validity() ?: 0) + + (prompts.asKnown().getOrNull()?.size ?: 0) + + (if (rotationInterval.asKnown().isPresent) 1 else 0) + + (routerSettings.asKnown().getOrNull()?.validity() ?: 0) + (if (rpmLimit.asKnown().isPresent) 1 else 0) + + (rpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (sendInviteEmail.asKnown().isPresent) 1 else 0) + (if (softBudget.asKnown().isPresent) 1 else 0) + (if (spend.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (teamId.asKnown().isPresent) 1 else 0) + (if (tpmLimit.asKnown().isPresent) 1 else 0) + + (tpmLimitType.asKnown().getOrNull()?.validity() ?: 0) + (if (userId.asKnown().isPresent) 1 else 0) + class Aliases + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Aliases]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Aliases]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aliases: Aliases) = apply { + additionalProperties = aliases.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Aliases]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Aliases = Aliases(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Aliases = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aliases && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Aliases{additionalProperties=$additionalProperties}" + } + + class AllowedVectorStoreIndex + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val indexName: JsonField, + private val indexPermissions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("index_name") + @ExcludeMissing + indexName: JsonField = JsonMissing.of(), + @JsonProperty("index_permissions") + @ExcludeMissing + indexPermissions: JsonField> = JsonMissing.of(), + ) : this(indexName, indexPermissions, mutableMapOf()) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexName(): String = indexName.getRequired("index_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun indexPermissions(): List = + indexPermissions.getRequired("index_permissions") + + /** + * Returns the raw JSON value of [indexName]. + * + * Unlike [indexName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index_name") @ExcludeMissing fun _indexName(): JsonField = indexName + + /** + * Returns the raw JSON value of [indexPermissions]. + * + * Unlike [indexPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("index_permissions") + @ExcludeMissing + fun _indexPermissions(): JsonField> = indexPermissions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AllowedVectorStoreIndex]. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AllowedVectorStoreIndex]. */ + class Builder internal constructor() { + + private var indexName: JsonField? = null + private var indexPermissions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowedVectorStoreIndex: AllowedVectorStoreIndex) = apply { + indexName = allowedVectorStoreIndex.indexName + indexPermissions = + allowedVectorStoreIndex.indexPermissions.map { it.toMutableList() } + additionalProperties = allowedVectorStoreIndex.additionalProperties.toMutableMap() + } + + fun indexName(indexName: String) = indexName(JsonField.of(indexName)) + + /** + * Sets [Builder.indexName] to an arbitrary JSON value. + * + * You should usually call [Builder.indexName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun indexName(indexName: JsonField) = apply { this.indexName = indexName } + + fun indexPermissions(indexPermissions: List) = + indexPermissions(JsonField.of(indexPermissions)) + + /** + * Sets [Builder.indexPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.indexPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun indexPermissions(indexPermissions: JsonField>) = apply { + this.indexPermissions = indexPermissions.map { it.toMutableList() } + } + + /** + * Adds a single [IndexPermission] to [indexPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndexPermission(indexPermission: IndexPermission) = apply { + indexPermissions = + (indexPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("indexPermissions", it).add(indexPermission) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AllowedVectorStoreIndex]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .indexName() + * .indexPermissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AllowedVectorStoreIndex = + AllowedVectorStoreIndex( + checkRequired("indexName", indexName), + checkRequired("indexPermissions", indexPermissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AllowedVectorStoreIndex = apply { + if (validated) { + return@apply + } + + indexName() + indexPermissions().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (indexName.asKnown().isPresent) 1 else 0) + + (indexPermissions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class IndexPermission + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val READ = of("read") + + @JvmField val WRITE = of("write") + + @JvmStatic fun of(value: String) = IndexPermission(JsonField.of(value)) + } + + /** An enum containing [IndexPermission]'s known values. */ + enum class Known { + READ, + WRITE, + } + + /** + * An enum containing [IndexPermission]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IndexPermission] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + READ, + WRITE, + /** + * An enum member indicating that [IndexPermission] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + READ -> Value.READ + WRITE -> Value.WRITE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + READ -> Known.READ + WRITE -> Known.WRITE + else -> throw HanzoInvalidDataException("Unknown IndexPermission: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + HanzoInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): IndexPermission = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexPermission && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AllowedVectorStoreIndex && + indexName == other.indexName && + indexPermissions == other.indexPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(indexName, indexPermissions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AllowedVectorStoreIndex{indexName=$indexName, indexPermissions=$indexPermissions, additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + /** Enum for key types that determine what routes a key can access */ + class KeyType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_API = of("llm_api") + + @JvmField val MANAGEMENT = of("management") + + @JvmField val READ_ONLY = of("read_only") + + @JvmField val DEFAULT = of("default") + + @JvmStatic fun of(value: String) = KeyType(JsonField.of(value)) + } + + /** An enum containing [KeyType]'s known values. */ + enum class Known { + LLM_API, + MANAGEMENT, + READ_ONLY, + DEFAULT, + } + + /** + * An enum containing [KeyType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [KeyType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_API, + MANAGEMENT, + READ_ONLY, + DEFAULT, + /** An enum member indicating that [KeyType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_API -> Value.LLM_API + MANAGEMENT -> Value.MANAGEMENT + READ_ONLY -> Value.READ_ONLY + DEFAULT -> Value.DEFAULT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + LLM_API -> Known.LLM_API + MANAGEMENT -> Known.MANAGEMENT + READ_ONLY -> Known.READ_ONLY + DEFAULT -> Known.DEFAULT + else -> throw HanzoInvalidDataException("Unknown KeyType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): KeyType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KeyType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelMaxBudget + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelMaxBudget]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelMaxBudget]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelMaxBudget: ModelMaxBudget) = apply { + additionalProperties = modelMaxBudget.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelMaxBudget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelMaxBudget = ModelMaxBudget(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelMaxBudget = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelMaxBudget && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelMaxBudget{additionalProperties=$additionalProperties}" + } + + class ModelRpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelRpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelRpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelRpmLimit: ModelRpmLimit) = apply { + additionalProperties = modelRpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelRpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelRpmLimit = ModelRpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelRpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelRpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelRpmLimit{additionalProperties=$additionalProperties}" + } + + class ModelTpmLimit + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelTpmLimit]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelTpmLimit]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelTpmLimit: ModelTpmLimit) = apply { + additionalProperties = modelTpmLimit.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelTpmLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelTpmLimit = ModelTpmLimit(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelTpmLimit = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelTpmLimit && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelTpmLimit{additionalProperties=$additionalProperties}" + } + + class ObjectPermission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agentAccessGroups: JsonField>, + private val agents: JsonField>, + private val mcpAccessGroups: JsonField>, + private val mcpServers: JsonField>, + private val mcpToolPermissions: JsonField, + private val vectorStores: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent_access_groups") + @ExcludeMissing + agentAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("agents") + @ExcludeMissing + agents: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_access_groups") + @ExcludeMissing + mcpAccessGroups: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_servers") + @ExcludeMissing + mcpServers: JsonField> = JsonMissing.of(), + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + mcpToolPermissions: JsonField = JsonMissing.of(), + @JsonProperty("vector_stores") + @ExcludeMissing + vectorStores: JsonField> = JsonMissing.of(), + ) : this( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agentAccessGroups(): Optional> = + agentAccessGroups.getOptional("agent_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agents(): Optional> = agents.getOptional("agents") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpAccessGroups(): Optional> = + mcpAccessGroups.getOptional("mcp_access_groups") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpServers(): Optional> = mcpServers.getOptional("mcp_servers") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcpToolPermissions(): Optional = + mcpToolPermissions.getOptional("mcp_tool_permissions") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vectorStores(): Optional> = vectorStores.getOptional("vector_stores") + + /** + * Returns the raw JSON value of [agentAccessGroups]. + * + * Unlike [agentAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agent_access_groups") + @ExcludeMissing + fun _agentAccessGroups(): JsonField> = agentAccessGroups + + /** + * Returns the raw JSON value of [agents]. + * + * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agents") @ExcludeMissing fun _agents(): JsonField> = agents + + /** + * Returns the raw JSON value of [mcpAccessGroups]. + * + * Unlike [mcpAccessGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mcp_access_groups") + @ExcludeMissing + fun _mcpAccessGroups(): JsonField> = mcpAccessGroups + + /** + * Returns the raw JSON value of [mcpServers]. + * + * Unlike [mcpServers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcp_servers") + @ExcludeMissing + fun _mcpServers(): JsonField> = mcpServers + + /** + * Returns the raw JSON value of [mcpToolPermissions]. + * + * Unlike [mcpToolPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mcp_tool_permissions") + @ExcludeMissing + fun _mcpToolPermissions(): JsonField = mcpToolPermissions + + /** + * Returns the raw JSON value of [vectorStores]. + * + * Unlike [vectorStores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vector_stores") + @ExcludeMissing + fun _vectorStores(): JsonField> = vectorStores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ObjectPermission]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectPermission]. */ + class Builder internal constructor() { + + private var agentAccessGroups: JsonField>? = null + private var agents: JsonField>? = null + private var mcpAccessGroups: JsonField>? = null + private var mcpServers: JsonField>? = null + private var mcpToolPermissions: JsonField = JsonMissing.of() + private var vectorStores: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectPermission: ObjectPermission) = apply { + agentAccessGroups = objectPermission.agentAccessGroups.map { it.toMutableList() } + agents = objectPermission.agents.map { it.toMutableList() } + mcpAccessGroups = objectPermission.mcpAccessGroups.map { it.toMutableList() } + mcpServers = objectPermission.mcpServers.map { it.toMutableList() } + mcpToolPermissions = objectPermission.mcpToolPermissions + vectorStores = objectPermission.vectorStores.map { it.toMutableList() } + additionalProperties = objectPermission.additionalProperties.toMutableMap() + } + + fun agentAccessGroups(agentAccessGroups: List?) = + agentAccessGroups(JsonField.ofNullable(agentAccessGroups)) + + /** + * Alias for calling [Builder.agentAccessGroups] with `agentAccessGroups.orElse(null)`. + */ + fun agentAccessGroups(agentAccessGroups: Optional>) = + agentAccessGroups(agentAccessGroups.getOrNull()) + + /** + * Sets [Builder.agentAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.agentAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun agentAccessGroups(agentAccessGroups: JsonField>) = apply { + this.agentAccessGroups = agentAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agentAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentAccessGroup(agentAccessGroup: String) = apply { + agentAccessGroups = + (agentAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("agentAccessGroups", it).add(agentAccessGroup) + } + } + + fun agents(agents: List?) = agents(JsonField.ofNullable(agents)) + + /** Alias for calling [Builder.agents] with `agents.orElse(null)`. */ + fun agents(agents: Optional>) = agents(agents.getOrNull()) + + /** + * Sets [Builder.agents] to an arbitrary JSON value. + * + * You should usually call [Builder.agents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agents(agents: JsonField>) = apply { + this.agents = agents.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [agents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgent(agent: String) = apply { + agents = + (agents ?: JsonField.of(mutableListOf())).also { + checkKnown("agents", it).add(agent) + } + } + + fun mcpAccessGroups(mcpAccessGroups: List?) = + mcpAccessGroups(JsonField.ofNullable(mcpAccessGroups)) + + /** Alias for calling [Builder.mcpAccessGroups] with `mcpAccessGroups.orElse(null)`. */ + fun mcpAccessGroups(mcpAccessGroups: Optional>) = + mcpAccessGroups(mcpAccessGroups.getOrNull()) + + /** + * Sets [Builder.mcpAccessGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpAccessGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mcpAccessGroups(mcpAccessGroups: JsonField>) = apply { + this.mcpAccessGroups = mcpAccessGroups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpAccessGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpAccessGroup(mcpAccessGroup: String) = apply { + mcpAccessGroups = + (mcpAccessGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpAccessGroups", it).add(mcpAccessGroup) + } + } + + fun mcpServers(mcpServers: List?) = mcpServers(JsonField.ofNullable(mcpServers)) + + /** Alias for calling [Builder.mcpServers] with `mcpServers.orElse(null)`. */ + fun mcpServers(mcpServers: Optional>) = mcpServers(mcpServers.getOrNull()) + + /** + * Sets [Builder.mcpServers] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpServers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mcpServers(mcpServers: JsonField>) = apply { + this.mcpServers = mcpServers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [mcpServers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMcpServer(mcpServer: String) = apply { + mcpServers = + (mcpServers ?: JsonField.of(mutableListOf())).also { + checkKnown("mcpServers", it).add(mcpServer) + } + } + + fun mcpToolPermissions(mcpToolPermissions: McpToolPermissions?) = + mcpToolPermissions(JsonField.ofNullable(mcpToolPermissions)) + + /** + * Alias for calling [Builder.mcpToolPermissions] with + * `mcpToolPermissions.orElse(null)`. + */ + fun mcpToolPermissions(mcpToolPermissions: Optional) = + mcpToolPermissions(mcpToolPermissions.getOrNull()) + + /** + * Sets [Builder.mcpToolPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.mcpToolPermissions] with a well-typed + * [McpToolPermissions] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun mcpToolPermissions(mcpToolPermissions: JsonField) = apply { + this.mcpToolPermissions = mcpToolPermissions + } + + fun vectorStores(vectorStores: List?) = + vectorStores(JsonField.ofNullable(vectorStores)) + + /** Alias for calling [Builder.vectorStores] with `vectorStores.orElse(null)`. */ + fun vectorStores(vectorStores: Optional>) = + vectorStores(vectorStores.getOrNull()) + + /** + * Sets [Builder.vectorStores] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStores] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vectorStores(vectorStores: JsonField>) = apply { + this.vectorStores = vectorStores.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [vectorStores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVectorStore(vectorStore: String) = apply { + vectorStores = + (vectorStores ?: JsonField.of(mutableListOf())).also { + checkKnown("vectorStores", it).add(vectorStore) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ObjectPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ObjectPermission = + ObjectPermission( + (agentAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (agents ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpAccessGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (mcpServers ?: JsonMissing.of()).map { it.toImmutable() }, + mcpToolPermissions, + (vectorStores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ObjectPermission = apply { + if (validated) { + return@apply + } + + agentAccessGroups() + agents() + mcpAccessGroups() + mcpServers() + mcpToolPermissions().ifPresent { it.validate() } + vectorStores() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (agentAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (agents.asKnown().getOrNull()?.size ?: 0) + + (mcpAccessGroups.asKnown().getOrNull()?.size ?: 0) + + (mcpServers.asKnown().getOrNull()?.size ?: 0) + + (mcpToolPermissions.asKnown().getOrNull()?.validity() ?: 0) + + (vectorStores.asKnown().getOrNull()?.size ?: 0) + + class McpToolPermissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolPermissions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolPermissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolPermissions: McpToolPermissions) = apply { + additionalProperties = mcpToolPermissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolPermissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): McpToolPermissions = + McpToolPermissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): McpToolPermissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolPermissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolPermissions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ObjectPermission && + agentAccessGroups == other.agentAccessGroups && + agents == other.agents && + mcpAccessGroups == other.mcpAccessGroups && + mcpServers == other.mcpServers && + mcpToolPermissions == other.mcpToolPermissions && + vectorStores == other.vectorStores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agentAccessGroups, + agents, + mcpAccessGroups, + mcpServers, + mcpToolPermissions, + vectorStores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectPermission{agentAccessGroups=$agentAccessGroups, agents=$agents, mcpAccessGroups=$mcpAccessGroups, mcpServers=$mcpServers, mcpToolPermissions=$mcpToolPermissions, vectorStores=$vectorStores, additionalProperties=$additionalProperties}" + } + + class Permissions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Permissions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Permissions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(permissions: Permissions) = apply { + additionalProperties = permissions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Permissions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Permissions = Permissions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Permissions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permissions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Permissions{additionalProperties=$additionalProperties}" + } + + /** Set of params that you can modify via `router.update_settings()`. */ + class RouterSettings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowedFails: JsonField, + private val contextWindowFallbacks: JsonField>, + private val cooldownTime: JsonField, + private val fallbacks: JsonField>, + private val maxRetries: JsonField, + private val modelGroupAlias: JsonField, + private val modelGroupRetryPolicy: JsonField, + private val numRetries: JsonField, + private val retryAfter: JsonField, + private val routingStrategy: JsonField, + private val routingStrategyArgs: JsonField, + private val timeout: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed_fails") + @ExcludeMissing + allowedFails: JsonField = JsonMissing.of(), + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + contextWindowFallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("cooldown_time") + @ExcludeMissing + cooldownTime: JsonField = JsonMissing.of(), + @JsonProperty("fallbacks") + @ExcludeMissing + fallbacks: JsonField> = JsonMissing.of(), + @JsonProperty("max_retries") + @ExcludeMissing + maxRetries: JsonField = JsonMissing.of(), + @JsonProperty("model_group_alias") + @ExcludeMissing + modelGroupAlias: JsonField = JsonMissing.of(), + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + modelGroupRetryPolicy: JsonField = JsonMissing.of(), + @JsonProperty("num_retries") + @ExcludeMissing + numRetries: JsonField = JsonMissing.of(), + @JsonProperty("retry_after") + @ExcludeMissing + retryAfter: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy") + @ExcludeMissing + routingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("routing_strategy_args") + @ExcludeMissing + routingStrategyArgs: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + ) : this( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedFails(): Optional = allowedFails.getOptional("allowed_fails") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowFallbacks(): Optional> = + contextWindowFallbacks.getOptional("context_window_fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cooldownTime(): Optional = cooldownTime.getOptional("cooldown_time") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fallbacks(): Optional> = fallbacks.getOptional("fallbacks") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupAlias(): Optional = + modelGroupAlias.getOptional("model_group_alias") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelGroupRetryPolicy(): Optional = + modelGroupRetryPolicy.getOptional("model_group_retry_policy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numRetries(): Optional = numRetries.getOptional("num_retries") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun retryAfter(): Optional = retryAfter.getOptional("retry_after") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategy(): Optional = routingStrategy.getOptional("routing_strategy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingStrategyArgs(): Optional = + routingStrategyArgs.getOptional("routing_strategy_args") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * Returns the raw JSON value of [allowedFails]. + * + * Unlike [allowedFails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_fails") + @ExcludeMissing + fun _allowedFails(): JsonField = allowedFails + + /** + * Returns the raw JSON value of [contextWindowFallbacks]. + * + * Unlike [contextWindowFallbacks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("context_window_fallbacks") + @ExcludeMissing + fun _contextWindowFallbacks(): JsonField> = + contextWindowFallbacks + + /** + * Returns the raw JSON value of [cooldownTime]. + * + * Unlike [cooldownTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cooldown_time") + @ExcludeMissing + fun _cooldownTime(): JsonField = cooldownTime + + /** + * Returns the raw JSON value of [fallbacks]. + * + * Unlike [fallbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fallbacks") + @ExcludeMissing + fun _fallbacks(): JsonField> = fallbacks + + /** + * Returns the raw JSON value of [maxRetries]. + * + * Unlike [maxRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_retries") @ExcludeMissing fun _maxRetries(): JsonField = maxRetries + + /** + * Returns the raw JSON value of [modelGroupAlias]. + * + * Unlike [modelGroupAlias], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_group_alias") + @ExcludeMissing + fun _modelGroupAlias(): JsonField = modelGroupAlias + + /** + * Returns the raw JSON value of [modelGroupRetryPolicy]. + * + * Unlike [modelGroupRetryPolicy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("model_group_retry_policy") + @ExcludeMissing + fun _modelGroupRetryPolicy(): JsonField = modelGroupRetryPolicy + + /** + * Returns the raw JSON value of [numRetries]. + * + * Unlike [numRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_retries") @ExcludeMissing fun _numRetries(): JsonField = numRetries + + /** + * Returns the raw JSON value of [retryAfter]. + * + * Unlike [retryAfter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retry_after") + @ExcludeMissing + fun _retryAfter(): JsonField = retryAfter + + /** + * Returns the raw JSON value of [routingStrategy]. + * + * Unlike [routingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_strategy") + @ExcludeMissing + fun _routingStrategy(): JsonField = routingStrategy + + /** + * Returns the raw JSON value of [routingStrategyArgs]. + * + * Unlike [routingStrategyArgs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routing_strategy_args") + @ExcludeMissing + fun _routingStrategyArgs(): JsonField = routingStrategyArgs + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RouterSettings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouterSettings]. */ + class Builder internal constructor() { + + private var allowedFails: JsonField = JsonMissing.of() + private var contextWindowFallbacks: JsonField>? = + null + private var cooldownTime: JsonField = JsonMissing.of() + private var fallbacks: JsonField>? = null + private var maxRetries: JsonField = JsonMissing.of() + private var modelGroupAlias: JsonField = JsonMissing.of() + private var modelGroupRetryPolicy: JsonField = JsonMissing.of() + private var numRetries: JsonField = JsonMissing.of() + private var retryAfter: JsonField = JsonMissing.of() + private var routingStrategy: JsonField = JsonMissing.of() + private var routingStrategyArgs: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routerSettings: RouterSettings) = apply { + allowedFails = routerSettings.allowedFails + contextWindowFallbacks = + routerSettings.contextWindowFallbacks.map { it.toMutableList() } + cooldownTime = routerSettings.cooldownTime + fallbacks = routerSettings.fallbacks.map { it.toMutableList() } + maxRetries = routerSettings.maxRetries + modelGroupAlias = routerSettings.modelGroupAlias + modelGroupRetryPolicy = routerSettings.modelGroupRetryPolicy + numRetries = routerSettings.numRetries + retryAfter = routerSettings.retryAfter + routingStrategy = routerSettings.routingStrategy + routingStrategyArgs = routerSettings.routingStrategyArgs + timeout = routerSettings.timeout + additionalProperties = routerSettings.additionalProperties.toMutableMap() + } + + fun allowedFails(allowedFails: Long?) = allowedFails(JsonField.ofNullable(allowedFails)) + + /** + * Alias for [Builder.allowedFails]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allowedFails(allowedFails: Long) = allowedFails(allowedFails as Long?) + + /** Alias for calling [Builder.allowedFails] with `allowedFails.orElse(null)`. */ + fun allowedFails(allowedFails: Optional) = allowedFails(allowedFails.getOrNull()) + + /** + * Sets [Builder.allowedFails] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedFails] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowedFails(allowedFails: JsonField) = apply { + this.allowedFails = allowedFails + } + + fun contextWindowFallbacks(contextWindowFallbacks: List?) = + contextWindowFallbacks(JsonField.ofNullable(contextWindowFallbacks)) + + /** + * Alias for calling [Builder.contextWindowFallbacks] with + * `contextWindowFallbacks.orElse(null)`. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: Optional> + ) = contextWindowFallbacks(contextWindowFallbacks.getOrNull()) + + /** + * Sets [Builder.contextWindowFallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowFallbacks] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun contextWindowFallbacks( + contextWindowFallbacks: JsonField> + ) = apply { + this.contextWindowFallbacks = contextWindowFallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [ContextWindowFallback] to [contextWindowFallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContextWindowFallback(contextWindowFallback: ContextWindowFallback) = apply { + contextWindowFallbacks = + (contextWindowFallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("contextWindowFallbacks", it).add(contextWindowFallback) + } + } + + fun cooldownTime(cooldownTime: Double?) = + cooldownTime(JsonField.ofNullable(cooldownTime)) + + /** + * Alias for [Builder.cooldownTime]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cooldownTime(cooldownTime: Double) = cooldownTime(cooldownTime as Double?) + + /** Alias for calling [Builder.cooldownTime] with `cooldownTime.orElse(null)`. */ + fun cooldownTime(cooldownTime: Optional) = + cooldownTime(cooldownTime.getOrNull()) + + /** + * Sets [Builder.cooldownTime] to an arbitrary JSON value. + * + * You should usually call [Builder.cooldownTime] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cooldownTime(cooldownTime: JsonField) = apply { + this.cooldownTime = cooldownTime + } + + fun fallbacks(fallbacks: List?) = fallbacks(JsonField.ofNullable(fallbacks)) + + /** Alias for calling [Builder.fallbacks] with `fallbacks.orElse(null)`. */ + fun fallbacks(fallbacks: Optional>) = fallbacks(fallbacks.getOrNull()) + + /** + * Sets [Builder.fallbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.fallbacks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fallbacks(fallbacks: JsonField>) = apply { + this.fallbacks = fallbacks.map { it.toMutableList() } + } + + /** + * Adds a single [Fallback] to [fallbacks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFallback(fallback: Fallback) = apply { + fallbacks = + (fallbacks ?: JsonField.of(mutableListOf())).also { + checkKnown("fallbacks", it).add(fallback) + } + } + + fun maxRetries(maxRetries: Long?) = maxRetries(JsonField.ofNullable(maxRetries)) + + /** + * Alias for [Builder.maxRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxRetries(maxRetries: Long) = maxRetries(maxRetries as Long?) + + /** Alias for calling [Builder.maxRetries] with `maxRetries.orElse(null)`. */ + fun maxRetries(maxRetries: Optional) = maxRetries(maxRetries.getOrNull()) + + /** + * Sets [Builder.maxRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.maxRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxRetries(maxRetries: JsonField) = apply { this.maxRetries = maxRetries } + + fun modelGroupAlias(modelGroupAlias: ModelGroupAlias?) = + modelGroupAlias(JsonField.ofNullable(modelGroupAlias)) + + /** Alias for calling [Builder.modelGroupAlias] with `modelGroupAlias.orElse(null)`. */ + fun modelGroupAlias(modelGroupAlias: Optional) = + modelGroupAlias(modelGroupAlias.getOrNull()) + + /** + * Sets [Builder.modelGroupAlias] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupAlias] with a well-typed [ModelGroupAlias] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelGroupAlias(modelGroupAlias: JsonField) = apply { + this.modelGroupAlias = modelGroupAlias + } + + fun modelGroupRetryPolicy(modelGroupRetryPolicy: ModelGroupRetryPolicy?) = + modelGroupRetryPolicy(JsonField.ofNullable(modelGroupRetryPolicy)) + + /** + * Alias for calling [Builder.modelGroupRetryPolicy] with + * `modelGroupRetryPolicy.orElse(null)`. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: Optional) = + modelGroupRetryPolicy(modelGroupRetryPolicy.getOrNull()) + + /** + * Sets [Builder.modelGroupRetryPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.modelGroupRetryPolicy] with a well-typed + * [ModelGroupRetryPolicy] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun modelGroupRetryPolicy(modelGroupRetryPolicy: JsonField) = + apply { + this.modelGroupRetryPolicy = modelGroupRetryPolicy + } + + fun numRetries(numRetries: Long?) = numRetries(JsonField.ofNullable(numRetries)) + + /** + * Alias for [Builder.numRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numRetries(numRetries: Long) = numRetries(numRetries as Long?) + + /** Alias for calling [Builder.numRetries] with `numRetries.orElse(null)`. */ + fun numRetries(numRetries: Optional) = numRetries(numRetries.getOrNull()) + + /** + * Sets [Builder.numRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.numRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numRetries(numRetries: JsonField) = apply { this.numRetries = numRetries } + + fun retryAfter(retryAfter: Double?) = retryAfter(JsonField.ofNullable(retryAfter)) + + /** + * Alias for [Builder.retryAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun retryAfter(retryAfter: Double) = retryAfter(retryAfter as Double?) + + /** Alias for calling [Builder.retryAfter] with `retryAfter.orElse(null)`. */ + fun retryAfter(retryAfter: Optional) = retryAfter(retryAfter.getOrNull()) + + /** + * Sets [Builder.retryAfter] to an arbitrary JSON value. + * + * You should usually call [Builder.retryAfter] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retryAfter(retryAfter: JsonField) = apply { this.retryAfter = retryAfter } + + fun routingStrategy(routingStrategy: String?) = + routingStrategy(JsonField.ofNullable(routingStrategy)) + + /** Alias for calling [Builder.routingStrategy] with `routingStrategy.orElse(null)`. */ + fun routingStrategy(routingStrategy: Optional) = + routingStrategy(routingStrategy.getOrNull()) + + /** + * Sets [Builder.routingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routingStrategy(routingStrategy: JsonField) = apply { + this.routingStrategy = routingStrategy + } + + fun routingStrategyArgs(routingStrategyArgs: RoutingStrategyArgs?) = + routingStrategyArgs(JsonField.ofNullable(routingStrategyArgs)) + + /** + * Alias for calling [Builder.routingStrategyArgs] with + * `routingStrategyArgs.orElse(null)`. + */ + fun routingStrategyArgs(routingStrategyArgs: Optional) = + routingStrategyArgs(routingStrategyArgs.getOrNull()) + + /** + * Sets [Builder.routingStrategyArgs] to an arbitrary JSON value. + * + * You should usually call [Builder.routingStrategyArgs] with a well-typed + * [RoutingStrategyArgs] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun routingStrategyArgs(routingStrategyArgs: JsonField) = apply { + this.routingStrategyArgs = routingStrategyArgs + } + + fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) + + /** + * Alias for [Builder.timeout]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun timeout(timeout: Double) = timeout(timeout as Double?) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RouterSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouterSettings = + RouterSettings( + allowedFails, + (contextWindowFallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + cooldownTime, + (fallbacks ?: JsonMissing.of()).map { it.toImmutable() }, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouterSettings = apply { + if (validated) { + return@apply + } + + allowedFails() + contextWindowFallbacks().ifPresent { it.forEach { it.validate() } } + cooldownTime() + fallbacks().ifPresent { it.forEach { it.validate() } } + maxRetries() + modelGroupAlias().ifPresent { it.validate() } + modelGroupRetryPolicy().ifPresent { it.validate() } + numRetries() + retryAfter() + routingStrategy() + routingStrategyArgs().ifPresent { it.validate() } + timeout() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowedFails.asKnown().isPresent) 1 else 0) + + (contextWindowFallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (cooldownTime.asKnown().isPresent) 1 else 0) + + (fallbacks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maxRetries.asKnown().isPresent) 1 else 0) + + (modelGroupAlias.asKnown().getOrNull()?.validity() ?: 0) + + (modelGroupRetryPolicy.asKnown().getOrNull()?.validity() ?: 0) + + (if (numRetries.asKnown().isPresent) 1 else 0) + + (if (retryAfter.asKnown().isPresent) 1 else 0) + + (if (routingStrategy.asKnown().isPresent) 1 else 0) + + (routingStrategyArgs.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeout.asKnown().isPresent) 1 else 0) + + class ContextWindowFallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContextWindowFallback]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContextWindowFallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contextWindowFallback: ContextWindowFallback) = apply { + additionalProperties = contextWindowFallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContextWindowFallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContextWindowFallback = + ContextWindowFallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ContextWindowFallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContextWindowFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContextWindowFallback{additionalProperties=$additionalProperties}" + } + + class Fallback + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Fallback]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fallback]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + additionalProperties = fallback.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Fallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Fallback = Fallback(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Fallback = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Fallback && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Fallback{additionalProperties=$additionalProperties}" + } + + class ModelGroupAlias + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelGroupAlias]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupAlias]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupAlias: ModelGroupAlias) = apply { + additionalProperties = modelGroupAlias.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupAlias]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupAlias = ModelGroupAlias(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupAlias = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupAlias && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ModelGroupAlias{additionalProperties=$additionalProperties}" + } + + class ModelGroupRetryPolicy + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelGroupRetryPolicy]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelGroupRetryPolicy]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelGroupRetryPolicy: ModelGroupRetryPolicy) = apply { + additionalProperties = modelGroupRetryPolicy.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelGroupRetryPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelGroupRetryPolicy = + ModelGroupRetryPolicy(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ModelGroupRetryPolicy = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelGroupRetryPolicy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelGroupRetryPolicy{additionalProperties=$additionalProperties}" + } + + class RoutingStrategyArgs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoutingStrategyArgs]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutingStrategyArgs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routingStrategyArgs: RoutingStrategyArgs) = apply { + additionalProperties = routingStrategyArgs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutingStrategyArgs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoutingStrategyArgs = + RoutingStrategyArgs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RoutingStrategyArgs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingStrategyArgs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutingStrategyArgs{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouterSettings && + allowedFails == other.allowedFails && + contextWindowFallbacks == other.contextWindowFallbacks && + cooldownTime == other.cooldownTime && + fallbacks == other.fallbacks && + maxRetries == other.maxRetries && + modelGroupAlias == other.modelGroupAlias && + modelGroupRetryPolicy == other.modelGroupRetryPolicy && + numRetries == other.numRetries && + retryAfter == other.retryAfter && + routingStrategy == other.routingStrategy && + routingStrategyArgs == other.routingStrategyArgs && + timeout == other.timeout && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowedFails, + contextWindowFallbacks, + cooldownTime, + fallbacks, + maxRetries, + modelGroupAlias, + modelGroupRetryPolicy, + numRetries, + retryAfter, + routingStrategy, + routingStrategyArgs, + timeout, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouterSettings{allowedFails=$allowedFails, contextWindowFallbacks=$contextWindowFallbacks, cooldownTime=$cooldownTime, fallbacks=$fallbacks, maxRetries=$maxRetries, modelGroupAlias=$modelGroupAlias, modelGroupRetryPolicy=$modelGroupRetryPolicy, numRetries=$numRetries, retryAfter=$retryAfter, routingStrategy=$routingStrategy, routingStrategyArgs=$routingStrategyArgs, timeout=$timeout, additionalProperties=$additionalProperties}" + } + + class RpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = RpmLimitType(JsonField.of(value)) + } + + /** An enum containing [RpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [RpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [RpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown RpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TpmLimitType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GUARANTEED_THROUGHPUT = of("guaranteed_throughput") + + @JvmField val BEST_EFFORT_THROUGHPUT = of("best_effort_throughput") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = TpmLimitType(JsonField.of(value)) + } + + /** An enum containing [TpmLimitType]'s known values. */ + enum class Known { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + } + + /** + * An enum containing [TpmLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TpmLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GUARANTEED_THROUGHPUT, + BEST_EFFORT_THROUGHPUT, + DYNAMIC, + /** + * An enum member indicating that [TpmLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GUARANTEED_THROUGHPUT -> Value.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Value.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws HanzoInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_THROUGHPUT -> Known.GUARANTEED_THROUGHPUT + BEST_EFFORT_THROUGHPUT -> Known.BEST_EFFORT_THROUGHPUT + DYNAMIC -> Known.DYNAMIC + else -> throw HanzoInvalidDataException("Unknown TpmLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws HanzoInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { HanzoInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TpmLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TpmLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1111,6 +5185,10 @@ private constructor( return other is RegenerateKeyRequest && aliases == other.aliases && allowedCacheControls == other.allowedCacheControls && + allowedPassthroughRoutes == other.allowedPassthroughRoutes && + allowedRoutes == other.allowedRoutes && + allowedVectorStoreIndexes == other.allowedVectorStoreIndexes && + autoRotate == other.autoRotate && blocked == other.blocked && budgetDuration == other.budgetDuration && budgetId == other.budgetId && @@ -1120,6 +5198,7 @@ private constructor( guardrails == other.guardrails && key == other.key && keyAlias == other.keyAlias && + keyType == other.keyType && maxBudget == other.maxBudget && maxParallelRequests == other.maxParallelRequests && metadata == other.metadata && @@ -1127,15 +5206,23 @@ private constructor( modelRpmLimit == other.modelRpmLimit && modelTpmLimit == other.modelTpmLimit && models == other.models && + newKey == other.newKey && newMasterKey == other.newMasterKey && + objectPermission == other.objectPermission && + organizationId == other.organizationId && permissions == other.permissions && + prompts == other.prompts && + rotationInterval == other.rotationInterval && + routerSettings == other.routerSettings && rpmLimit == other.rpmLimit && + rpmLimitType == other.rpmLimitType && sendInviteEmail == other.sendInviteEmail && softBudget == other.softBudget && spend == other.spend && tags == other.tags && teamId == other.teamId && tpmLimit == other.tpmLimit && + tpmLimitType == other.tpmLimitType && userId == other.userId && additionalProperties == other.additionalProperties } @@ -1144,6 +5231,10 @@ private constructor( Objects.hash( aliases, allowedCacheControls, + allowedPassthroughRoutes, + allowedRoutes, + allowedVectorStoreIndexes, + autoRotate, blocked, budgetDuration, budgetId, @@ -1153,6 +5244,7 @@ private constructor( guardrails, key, keyAlias, + keyType, maxBudget, maxParallelRequests, metadata, @@ -1160,15 +5252,23 @@ private constructor( modelRpmLimit, modelTpmLimit, models, + newKey, newMasterKey, + objectPermission, + organizationId, permissions, + prompts, + rotationInterval, + routerSettings, rpmLimit, + rpmLimitType, sendInviteEmail, softBudget, spend, tags, teamId, tpmLimit, + tpmLimitType, userId, additionalProperties, ) @@ -1177,5 +5277,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RegenerateKeyRequest{aliases=$aliases, allowedCacheControls=$allowedCacheControls, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, key=$key, keyAlias=$keyAlias, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, newMasterKey=$newMasterKey, permissions=$permissions, rpmLimit=$rpmLimit, sendInviteEmail=$sendInviteEmail, softBudget=$softBudget, spend=$spend, tags=$tags, teamId=$teamId, tpmLimit=$tpmLimit, userId=$userId, additionalProperties=$additionalProperties}" + "RegenerateKeyRequest{aliases=$aliases, allowedCacheControls=$allowedCacheControls, allowedPassthroughRoutes=$allowedPassthroughRoutes, allowedRoutes=$allowedRoutes, allowedVectorStoreIndexes=$allowedVectorStoreIndexes, autoRotate=$autoRotate, blocked=$blocked, budgetDuration=$budgetDuration, budgetId=$budgetId, config=$config, duration=$duration, enforcedParams=$enforcedParams, guardrails=$guardrails, key=$key, keyAlias=$keyAlias, keyType=$keyType, maxBudget=$maxBudget, maxParallelRequests=$maxParallelRequests, metadata=$metadata, modelMaxBudget=$modelMaxBudget, modelRpmLimit=$modelRpmLimit, modelTpmLimit=$modelTpmLimit, models=$models, newKey=$newKey, newMasterKey=$newMasterKey, objectPermission=$objectPermission, organizationId=$organizationId, permissions=$permissions, prompts=$prompts, rotationInterval=$rotationInterval, routerSettings=$routerSettings, rpmLimit=$rpmLimit, rpmLimitType=$rpmLimitType, sendInviteEmail=$sendInviteEmail, softBudget=$softBudget, spend=$spend, tags=$tags, teamId=$teamId, tpmLimit=$tpmLimit, tpmLimitType=$tpmLimitType, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt index a8e33a8d..b75d04ea 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseCreateParams.kt @@ -12,9 +12,9 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Call Langfuse via LLM proxy. Works with Langfuse SDK. + * Call Langfuse via LiteLLM proxy. Works with Langfuse SDK. * - * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) + * [Docs](https://docs.litellm.ai/docs/pass_through/langfuse) */ class LangfuseCreateParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt index b84201b3..3e4544ae 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseDeleteParams.kt @@ -12,9 +12,9 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Call Langfuse via LLM proxy. Works with Langfuse SDK. + * Call Langfuse via LiteLLM proxy. Works with Langfuse SDK. * - * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) + * [Docs](https://docs.litellm.ai/docs/pass_through/langfuse) */ class LangfuseDeleteParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt index 30024e69..65fc68ab 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfusePatchParams.kt @@ -12,9 +12,9 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Call Langfuse via LLM proxy. Works with Langfuse SDK. + * Call Langfuse via LiteLLM proxy. Works with Langfuse SDK. * - * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) + * [Docs](https://docs.litellm.ai/docs/pass_through/langfuse) */ class LangfusePatchParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt index 68fb7fac..178d8270 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseRetrieveParams.kt @@ -10,9 +10,9 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Call Langfuse via LLM proxy. Works with Langfuse SDK. + * Call Langfuse via LiteLLM proxy. Works with Langfuse SDK. * - * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) + * [Docs](https://docs.litellm.ai/docs/pass_through/langfuse) */ class LangfuseRetrieveParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt index 957e072b..599a5d5e 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/langfuse/LangfuseUpdateParams.kt @@ -12,9 +12,9 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Call Langfuse via LLM proxy. Works with Langfuse SDK. + * Call Langfuse via LiteLLM proxy. Works with Langfuse SDK. * - * [Docs](https://docs.hanzo.ai/docs/pass_through/langfuse) + * [Docs](https://docs.litellm.ai/docs/pass_through/langfuse) */ class LangfuseUpdateParams private constructor( diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt deleted file mode 100644 index 5ae85912..00000000 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ConfigurableClientsideParamsCustomAuth.kt +++ /dev/null @@ -1,174 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.hanzo.api.models.model - -import ai.hanzo.api.core.ExcludeMissing -import ai.hanzo.api.core.JsonField -import ai.hanzo.api.core.JsonMissing -import ai.hanzo.api.core.JsonValue -import ai.hanzo.api.core.checkRequired -import ai.hanzo.api.errors.HanzoInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class ConfigurableClientsideParamsCustomAuth -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val apiBase: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("api_base") @ExcludeMissing apiBase: JsonField = JsonMissing.of() - ) : this(apiBase, mutableMapOf()) - - /** - * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). - */ - fun apiBase(): String = apiBase.getRequired("api_base") - - /** - * Returns the raw JSON value of [apiBase]. - * - * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("api_base") @ExcludeMissing fun _apiBase(): JsonField = apiBase - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [ConfigurableClientsideParamsCustomAuth]. - * - * The following fields are required: - * ```java - * .apiBase() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ConfigurableClientsideParamsCustomAuth]. */ - class Builder internal constructor() { - - private var apiBase: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - configurableClientsideParamsCustomAuth: ConfigurableClientsideParamsCustomAuth - ) = apply { - apiBase = configurableClientsideParamsCustomAuth.apiBase - additionalProperties = - configurableClientsideParamsCustomAuth.additionalProperties.toMutableMap() - } - - fun apiBase(apiBase: String) = apiBase(JsonField.of(apiBase)) - - /** - * Sets [Builder.apiBase] to an arbitrary JSON value. - * - * You should usually call [Builder.apiBase] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ConfigurableClientsideParamsCustomAuth]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .apiBase() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ConfigurableClientsideParamsCustomAuth = - ConfigurableClientsideParamsCustomAuth( - checkRequired("apiBase", apiBase), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ConfigurableClientsideParamsCustomAuth = apply { - if (validated) { - return@apply - } - - apiBase() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: HanzoInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (apiBase.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConfigurableClientsideParamsCustomAuth && - apiBase == other.apiBase && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(apiBase, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ConfigurableClientsideParamsCustomAuth{apiBase=$apiBase, additionalProperties=$additionalProperties}" -} diff --git a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt index 07b6b3bb..e6f80eca 100644 --- a/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt +++ b/hanzo-java-core/src/main/kotlin/ai/hanzo/api/models/model/ModelCreateParams.kt @@ -4,6 +4,7 @@ package ai.hanzo.api.models.model import ai.hanzo.api.core.BaseDeserializer import ai.hanzo.api.core.BaseSerializer +import ai.hanzo.api.core.Enum import ai.hanzo.api.core.ExcludeMissing import ai.hanzo.api.core.JsonField import ai.hanzo.api.core.JsonMissing @@ -42,12 +43,12 @@ private constructor( ) : Params { /** - * LLM Params with 'model' requirement - used for completions + * LiteLLM Params with 'model' requirement - used for completions * * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun llmParams(): LlmParams = body.llmParams() + fun litellmParams(): LitellmParams = body.litellmParams() /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -62,11 +63,11 @@ private constructor( fun modelName(): String = body.modelName() /** - * Returns the raw JSON value of [llmParams]. + * Returns the raw JSON value of [litellmParams]. * - * Unlike [llmParams], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [litellmParams], this method doesn't throw if the JSON field has an unexpected type. */ - fun _llmParams(): JsonField = body._llmParams() + fun _litellmParams(): JsonField = body._litellmParams() /** * Returns the raw JSON value of [modelInfo]. @@ -99,7 +100,7 @@ private constructor( * * The following fields are required: * ```java - * .llmParams() + * .litellmParams() * .modelInfo() * .modelName() * ``` @@ -126,23 +127,27 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: - * - [llmParams] + * - [litellmParams] * - [modelInfo] * - [modelName] */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** LLM Params with 'model' requirement - used for completions */ - fun llmParams(llmParams: LlmParams) = apply { body.llmParams(llmParams) } + /** LiteLLM Params with 'model' requirement - used for completions */ + fun litellmParams(litellmParams: LitellmParams) = apply { + body.litellmParams(litellmParams) + } /** - * Sets [Builder.llmParams] to an arbitrary JSON value. + * Sets [Builder.litellmParams] to an arbitrary JSON value. * - * You should usually call [Builder.llmParams] with a well-typed [LlmParams] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.litellmParams] with a well-typed [LitellmParams] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun llmParams(llmParams: JsonField) = apply { body.llmParams(llmParams) } + fun litellmParams(litellmParams: JsonField) = apply { + body.litellmParams(litellmParams) + } fun modelInfo(modelInfo: ModelInfo) = apply { body.modelInfo(modelInfo) } @@ -290,7 +295,7 @@ private constructor( * * The following fields are required: * ```java - * .llmParams() + * .litellmParams() * .modelInfo() * .modelName() * ``` @@ -314,7 +319,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val llmParams: JsonField, + private val litellmParams: JsonField, private val modelInfo: JsonField, private val modelName: JsonField, private val additionalProperties: MutableMap, @@ -322,24 +327,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("llm_params") + @JsonProperty("litellm_params") @ExcludeMissing - llmParams: JsonField = JsonMissing.of(), + litellmParams: JsonField = JsonMissing.of(), @JsonProperty("model_info") @ExcludeMissing modelInfo: JsonField = JsonMissing.of(), @JsonProperty("model_name") @ExcludeMissing modelName: JsonField = JsonMissing.of(), - ) : this(llmParams, modelInfo, modelName, mutableMapOf()) + ) : this(litellmParams, modelInfo, modelName, mutableMapOf()) /** - * LLM Params with 'model' requirement - used for completions + * LiteLLM Params with 'model' requirement - used for completions * * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun llmParams(): LlmParams = llmParams.getRequired("llm_params") + fun litellmParams(): LitellmParams = litellmParams.getRequired("litellm_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is @@ -354,13 +359,14 @@ private constructor( fun modelName(): String = modelName.getRequired("model_name") /** - * Returns the raw JSON value of [llmParams]. + * Returns the raw JSON value of [litellmParams]. * - * Unlike [llmParams], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [litellmParams], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("llm_params") + @JsonProperty("litellm_params") @ExcludeMissing - fun _llmParams(): JsonField = llmParams + fun _litellmParams(): JsonField = litellmParams /** * Returns the raw JSON value of [modelInfo]. @@ -397,7 +403,7 @@ private constructor( * * The following fields are required: * ```java - * .llmParams() + * .litellmParams() * .modelInfo() * .modelName() * ``` @@ -408,30 +414,33 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var llmParams: JsonField? = null + private var litellmParams: JsonField? = null private var modelInfo: JsonField? = null private var modelName: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { - llmParams = body.llmParams + litellmParams = body.litellmParams modelInfo = body.modelInfo modelName = body.modelName additionalProperties = body.additionalProperties.toMutableMap() } - /** LLM Params with 'model' requirement - used for completions */ - fun llmParams(llmParams: LlmParams) = llmParams(JsonField.of(llmParams)) + /** LiteLLM Params with 'model' requirement - used for completions */ + fun litellmParams(litellmParams: LitellmParams) = + litellmParams(JsonField.of(litellmParams)) /** - * Sets [Builder.llmParams] to an arbitrary JSON value. + * Sets [Builder.litellmParams] to an arbitrary JSON value. * - * You should usually call [Builder.llmParams] with a well-typed [LlmParams] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.litellmParams] with a well-typed [LitellmParams] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun llmParams(llmParams: JsonField) = apply { this.llmParams = llmParams } + fun litellmParams(litellmParams: JsonField) = apply { + this.litellmParams = litellmParams + } fun modelInfo(modelInfo: ModelInfo) = modelInfo(JsonField.of(modelInfo)) @@ -481,7 +490,7 @@ private constructor( * * The following fields are required: * ```java - * .llmParams() + * .litellmParams() * .modelInfo() * .modelName() * ``` @@ -490,7 +499,7 @@ private constructor( */ fun build(): Body = Body( - checkRequired("llmParams", llmParams), + checkRequired("litellmParams", litellmParams), checkRequired("modelInfo", modelInfo), checkRequired("modelName", modelName), additionalProperties.toMutableMap(), @@ -504,7 +513,7 @@ private constructor( return@apply } - llmParams().validate() + litellmParams().validate() modelInfo().validate() modelName() validated = true @@ -526,7 +535,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (llmParams.asKnown().getOrNull()?.validity() ?: 0) + + (litellmParams.asKnown().getOrNull()?.validity() ?: 0) + (modelInfo.asKnown().getOrNull()?.validity() ?: 0) + (if (modelName.asKnown().isPresent) 1 else 0) @@ -536,54 +545,112 @@ private constructor( } return other is Body && - llmParams == other.llmParams && + litellmParams == other.litellmParams && modelInfo == other.modelInfo && modelName == other.modelName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(llmParams, modelInfo, modelName, additionalProperties) + Objects.hash(litellmParams, modelInfo, modelName, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{llmParams=$llmParams, modelInfo=$modelInfo, modelName=$modelName, additionalProperties=$additionalProperties}" + "Body{litellmParams=$litellmParams, modelInfo=$modelInfo, modelName=$modelName, additionalProperties=$additionalProperties}" } - /** LLM Params with 'model' requirement - used for completions */ - class LlmParams + /** LiteLLM Params with 'model' requirement - used for completions */ + class LitellmParams @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val model: JsonField, private val apiBase: JsonField, private val apiKey: JsonField, private val apiVersion: JsonField, + private val autoRouterConfig: JsonField, + private val autoRouterConfigPath: JsonField, + private val autoRouterDefaultModel: JsonField, + private val autoRouterEmbeddingModel: JsonField, private val awsAccessKeyId: JsonField, + private val awsBedrockRuntimeEndpoint: JsonField, private val awsRegionName: JsonField, private val awsSecretAccessKey: JsonField, private val budgetDuration: JsonField, + private val cacheCreationInputAudioTokenCost: JsonField, + private val cacheCreationInputTokenCost: JsonField, + private val cacheCreationInputTokenCostAbove1hr: JsonField, + private val cacheCreationInputTokenCostAbove200kTokens: JsonField, + private val cacheReadInputAudioTokenCost: JsonField, + private val cacheReadInputTokenCost: JsonField, + private val cacheReadInputTokenCostAbove200kTokens: JsonField, + private val cacheReadInputTokenCostFlex: JsonField, + private val cacheReadInputTokenCostPriority: JsonField, + private val citationCostPerToken: JsonField, private val configurableClientsideAuthParams: JsonField>, private val customLlmProvider: JsonField, + private val gcsBucketName: JsonField, + private val inputCostPerAudioPerSecond: JsonField, + private val inputCostPerAudioPerSecondAbove128kTokens: JsonField, + private val inputCostPerAudioToken: JsonField, + private val inputCostPerCharacter: JsonField, + private val inputCostPerCharacterAbove128kTokens: JsonField, + private val inputCostPerImage: JsonField, + private val inputCostPerImageAbove128kTokens: JsonField, + private val inputCostPerPixel: JsonField, + private val inputCostPerQuery: JsonField, private val inputCostPerSecond: JsonField, private val inputCostPerToken: JsonField, - private val llmTraceId: JsonField, + private val inputCostPerTokenAbove128kTokens: JsonField, + private val inputCostPerTokenAbove200kTokens: JsonField, + private val inputCostPerTokenBatches: JsonField, + private val inputCostPerTokenCacheHit: JsonField, + private val inputCostPerTokenFlex: JsonField, + private val inputCostPerTokenPriority: JsonField, + private val inputCostPerVideoPerSecond: JsonField, + private val inputCostPerVideoPerSecondAbove128kTokens: JsonField, + private val inputCostPerVideoPerSecondAbove15sInterval: JsonField, + private val inputCostPerVideoPerSecondAbove8sInterval: JsonField, + private val litellmCredentialName: JsonField, + private val litellmTraceId: JsonField, private val maxBudget: JsonField, private val maxFileSizeMb: JsonField, private val maxRetries: JsonField, private val mergeReasoningContentInChoices: JsonField, - private val modelInfo: JsonValue, + private val milvusTextField: JsonField, + private val mockResponse: JsonField, + private val modelInfo: JsonField, private val organization: JsonField, + private val outputCostPerAudioPerSecond: JsonField, + private val outputCostPerAudioToken: JsonField, + private val outputCostPerCharacter: JsonField, + private val outputCostPerCharacterAbove128kTokens: JsonField, + private val outputCostPerImage: JsonField, + private val outputCostPerImageToken: JsonField, + private val outputCostPerPixel: JsonField, + private val outputCostPerReasoningToken: JsonField, private val outputCostPerSecond: JsonField, private val outputCostPerToken: JsonField, + private val outputCostPerTokenAbove128kTokens: JsonField, + private val outputCostPerTokenAbove200kTokens: JsonField, + private val outputCostPerTokenBatches: JsonField, + private val outputCostPerTokenFlex: JsonField, + private val outputCostPerTokenPriority: JsonField, + private val outputCostPerVideoPerSecond: JsonField, private val regionName: JsonField, private val rpm: JsonField, + private val s3BucketName: JsonField, + private val s3EncryptionKeyId: JsonField, + private val searchContextCostPerQuery: JsonField, private val streamTimeout: JsonField, + private val tieredPricing: JsonField>, private val timeout: JsonField, private val tpm: JsonField, private val useInPassThrough: JsonField, + private val useLitellmProxy: JsonField, + private val vectorStoreId: JsonField, private val vertexCredentials: JsonField, private val vertexLocation: JsonField, private val vertexProject: JsonField, @@ -599,9 +666,24 @@ private constructor( @JsonProperty("api_version") @ExcludeMissing apiVersion: JsonField = JsonMissing.of(), + @JsonProperty("auto_router_config") + @ExcludeMissing + autoRouterConfig: JsonField = JsonMissing.of(), + @JsonProperty("auto_router_config_path") + @ExcludeMissing + autoRouterConfigPath: JsonField = JsonMissing.of(), + @JsonProperty("auto_router_default_model") + @ExcludeMissing + autoRouterDefaultModel: JsonField = JsonMissing.of(), + @JsonProperty("auto_router_embedding_model") + @ExcludeMissing + autoRouterEmbeddingModel: JsonField = JsonMissing.of(), @JsonProperty("aws_access_key_id") @ExcludeMissing awsAccessKeyId: JsonField = JsonMissing.of(), + @JsonProperty("aws_bedrock_runtime_endpoint") + @ExcludeMissing + awsBedrockRuntimeEndpoint: JsonField = JsonMissing.of(), @JsonProperty("aws_region_name") @ExcludeMissing awsRegionName: JsonField = JsonMissing.of(), @@ -611,6 +693,36 @@ private constructor( @JsonProperty("budget_duration") @ExcludeMissing budgetDuration: JsonField = JsonMissing.of(), + @JsonProperty("cache_creation_input_audio_token_cost") + @ExcludeMissing + cacheCreationInputAudioTokenCost: JsonField = JsonMissing.of(), + @JsonProperty("cache_creation_input_token_cost") + @ExcludeMissing + cacheCreationInputTokenCost: JsonField = JsonMissing.of(), + @JsonProperty("cache_creation_input_token_cost_above_1hr") + @ExcludeMissing + cacheCreationInputTokenCostAbove1hr: JsonField = JsonMissing.of(), + @JsonProperty("cache_creation_input_token_cost_above_200k_tokens") + @ExcludeMissing + cacheCreationInputTokenCostAbove200kTokens: JsonField = JsonMissing.of(), + @JsonProperty("cache_read_input_audio_token_cost") + @ExcludeMissing + cacheReadInputAudioTokenCost: JsonField = JsonMissing.of(), + @JsonProperty("cache_read_input_token_cost") + @ExcludeMissing + cacheReadInputTokenCost: JsonField = JsonMissing.of(), + @JsonProperty("cache_read_input_token_cost_above_200k_tokens") + @ExcludeMissing + cacheReadInputTokenCostAbove200kTokens: JsonField = JsonMissing.of(), + @JsonProperty("cache_read_input_token_cost_flex") + @ExcludeMissing + cacheReadInputTokenCostFlex: JsonField = JsonMissing.of(), + @JsonProperty("cache_read_input_token_cost_priority") + @ExcludeMissing + cacheReadInputTokenCostPriority: JsonField = JsonMissing.of(), + @JsonProperty("citation_cost_per_token") + @ExcludeMissing + citationCostPerToken: JsonField = JsonMissing.of(), @JsonProperty("configurable_clientside_auth_params") @ExcludeMissing configurableClientsideAuthParams: JsonField> = @@ -618,15 +730,78 @@ private constructor( @JsonProperty("custom_llm_provider") @ExcludeMissing customLlmProvider: JsonField = JsonMissing.of(), + @JsonProperty("gcs_bucket_name") + @ExcludeMissing + gcsBucketName: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_audio_per_second") + @ExcludeMissing + inputCostPerAudioPerSecond: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_audio_per_second_above_128k_tokens") + @ExcludeMissing + inputCostPerAudioPerSecondAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_audio_token") + @ExcludeMissing + inputCostPerAudioToken: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_character") + @ExcludeMissing + inputCostPerCharacter: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_character_above_128k_tokens") + @ExcludeMissing + inputCostPerCharacterAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_image") + @ExcludeMissing + inputCostPerImage: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_image_above_128k_tokens") + @ExcludeMissing + inputCostPerImageAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_pixel") + @ExcludeMissing + inputCostPerPixel: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_query") + @ExcludeMissing + inputCostPerQuery: JsonField = JsonMissing.of(), @JsonProperty("input_cost_per_second") @ExcludeMissing inputCostPerSecond: JsonField = JsonMissing.of(), @JsonProperty("input_cost_per_token") @ExcludeMissing inputCostPerToken: JsonField = JsonMissing.of(), - @JsonProperty("llm_trace_id") + @JsonProperty("input_cost_per_token_above_128k_tokens") + @ExcludeMissing + inputCostPerTokenAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_token_above_200k_tokens") + @ExcludeMissing + inputCostPerTokenAbove200kTokens: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_token_batches") + @ExcludeMissing + inputCostPerTokenBatches: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_token_cache_hit") + @ExcludeMissing + inputCostPerTokenCacheHit: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_token_flex") @ExcludeMissing - llmTraceId: JsonField = JsonMissing.of(), + inputCostPerTokenFlex: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_token_priority") + @ExcludeMissing + inputCostPerTokenPriority: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_video_per_second") + @ExcludeMissing + inputCostPerVideoPerSecond: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_video_per_second_above_128k_tokens") + @ExcludeMissing + inputCostPerVideoPerSecondAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_video_per_second_above_15s_interval") + @ExcludeMissing + inputCostPerVideoPerSecondAbove15sInterval: JsonField = JsonMissing.of(), + @JsonProperty("input_cost_per_video_per_second_above_8s_interval") + @ExcludeMissing + inputCostPerVideoPerSecondAbove8sInterval: JsonField = JsonMissing.of(), + @JsonProperty("litellm_credential_name") + @ExcludeMissing + litellmCredentialName: JsonField = JsonMissing.of(), + @JsonProperty("litellm_trace_id") + @ExcludeMissing + litellmTraceId: JsonField = JsonMissing.of(), @JsonProperty("max_budget") @ExcludeMissing maxBudget: JsonField = JsonMissing.of(), @@ -639,28 +814,96 @@ private constructor( @JsonProperty("merge_reasoning_content_in_choices") @ExcludeMissing mergeReasoningContentInChoices: JsonField = JsonMissing.of(), - @JsonProperty("model_info") @ExcludeMissing modelInfo: JsonValue = JsonMissing.of(), + @JsonProperty("milvus_text_field") + @ExcludeMissing + milvusTextField: JsonField = JsonMissing.of(), + @JsonProperty("mock_response") + @ExcludeMissing + mockResponse: JsonField = JsonMissing.of(), + @JsonProperty("model_info") + @ExcludeMissing + modelInfo: JsonField = JsonMissing.of(), @JsonProperty("organization") @ExcludeMissing organization: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_audio_per_second") + @ExcludeMissing + outputCostPerAudioPerSecond: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_audio_token") + @ExcludeMissing + outputCostPerAudioToken: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_character") + @ExcludeMissing + outputCostPerCharacter: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_character_above_128k_tokens") + @ExcludeMissing + outputCostPerCharacterAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_image") + @ExcludeMissing + outputCostPerImage: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_image_token") + @ExcludeMissing + outputCostPerImageToken: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_pixel") + @ExcludeMissing + outputCostPerPixel: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_reasoning_token") + @ExcludeMissing + outputCostPerReasoningToken: JsonField = JsonMissing.of(), @JsonProperty("output_cost_per_second") @ExcludeMissing outputCostPerSecond: JsonField = JsonMissing.of(), @JsonProperty("output_cost_per_token") @ExcludeMissing outputCostPerToken: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_token_above_128k_tokens") + @ExcludeMissing + outputCostPerTokenAbove128kTokens: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_token_above_200k_tokens") + @ExcludeMissing + outputCostPerTokenAbove200kTokens: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_token_batches") + @ExcludeMissing + outputCostPerTokenBatches: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_token_flex") + @ExcludeMissing + outputCostPerTokenFlex: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_token_priority") + @ExcludeMissing + outputCostPerTokenPriority: JsonField = JsonMissing.of(), + @JsonProperty("output_cost_per_video_per_second") + @ExcludeMissing + outputCostPerVideoPerSecond: JsonField = JsonMissing.of(), @JsonProperty("region_name") @ExcludeMissing regionName: JsonField = JsonMissing.of(), @JsonProperty("rpm") @ExcludeMissing rpm: JsonField = JsonMissing.of(), + @JsonProperty("s3_bucket_name") + @ExcludeMissing + s3BucketName: JsonField = JsonMissing.of(), + @JsonProperty("s3_encryption_key_id") + @ExcludeMissing + s3EncryptionKeyId: JsonField = JsonMissing.of(), + @JsonProperty("search_context_cost_per_query") + @ExcludeMissing + searchContextCostPerQuery: JsonField = JsonMissing.of(), @JsonProperty("stream_timeout") @ExcludeMissing streamTimeout: JsonField = JsonMissing.of(), + @JsonProperty("tiered_pricing") + @ExcludeMissing + tieredPricing: JsonField> = JsonMissing.of(), @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), @JsonProperty("tpm") @ExcludeMissing tpm: JsonField = JsonMissing.of(), @JsonProperty("use_in_pass_through") @ExcludeMissing useInPassThrough: JsonField = JsonMissing.of(), + @JsonProperty("use_litellm_proxy") + @ExcludeMissing + useLitellmProxy: JsonField = JsonMissing.of(), + @JsonProperty("vector_store_id") + @ExcludeMissing + vectorStoreId: JsonField = JsonMissing.of(), @JsonProperty("vertex_credentials") @ExcludeMissing vertexCredentials: JsonField = JsonMissing.of(), @@ -678,29 +921,87 @@ private constructor( apiBase, apiKey, apiVersion, + autoRouterConfig, + autoRouterConfigPath, + autoRouterDefaultModel, + autoRouterEmbeddingModel, awsAccessKeyId, + awsBedrockRuntimeEndpoint, awsRegionName, awsSecretAccessKey, budgetDuration, + cacheCreationInputAudioTokenCost, + cacheCreationInputTokenCost, + cacheCreationInputTokenCostAbove1hr, + cacheCreationInputTokenCostAbove200kTokens, + cacheReadInputAudioTokenCost, + cacheReadInputTokenCost, + cacheReadInputTokenCostAbove200kTokens, + cacheReadInputTokenCostFlex, + cacheReadInputTokenCostPriority, + citationCostPerToken, configurableClientsideAuthParams, customLlmProvider, + gcsBucketName, + inputCostPerAudioPerSecond, + inputCostPerAudioPerSecondAbove128kTokens, + inputCostPerAudioToken, + inputCostPerCharacter, + inputCostPerCharacterAbove128kTokens, + inputCostPerImage, + inputCostPerImageAbove128kTokens, + inputCostPerPixel, + inputCostPerQuery, inputCostPerSecond, inputCostPerToken, - llmTraceId, + inputCostPerTokenAbove128kTokens, + inputCostPerTokenAbove200kTokens, + inputCostPerTokenBatches, + inputCostPerTokenCacheHit, + inputCostPerTokenFlex, + inputCostPerTokenPriority, + inputCostPerVideoPerSecond, + inputCostPerVideoPerSecondAbove128kTokens, + inputCostPerVideoPerSecondAbove15sInterval, + inputCostPerVideoPerSecondAbove8sInterval, + litellmCredentialName, + litellmTraceId, maxBudget, maxFileSizeMb, maxRetries, mergeReasoningContentInChoices, + milvusTextField, + mockResponse, modelInfo, organization, + outputCostPerAudioPerSecond, + outputCostPerAudioToken, + outputCostPerCharacter, + outputCostPerCharacterAbove128kTokens, + outputCostPerImage, + outputCostPerImageToken, + outputCostPerPixel, + outputCostPerReasoningToken, outputCostPerSecond, outputCostPerToken, + outputCostPerTokenAbove128kTokens, + outputCostPerTokenAbove200kTokens, + outputCostPerTokenBatches, + outputCostPerTokenFlex, + outputCostPerTokenPriority, + outputCostPerVideoPerSecond, regionName, rpm, + s3BucketName, + s3EncryptionKeyId, + searchContextCostPerQuery, streamTimeout, + tieredPricing, timeout, tpm, useInPassThrough, + useLitellmProxy, + vectorStoreId, vertexCredentials, vertexLocation, vertexProject, @@ -736,1424 +1037,11832 @@ private constructor( * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsAccessKeyId(): Optional = awsAccessKeyId.getOptional("aws_access_key_id") + fun autoRouterConfig(): Optional = + autoRouterConfig.getOptional("auto_router_config") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsRegionName(): Optional = awsRegionName.getOptional("aws_region_name") + fun autoRouterConfigPath(): Optional = + autoRouterConfigPath.getOptional("auto_router_config_path") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun awsSecretAccessKey(): Optional = - awsSecretAccessKey.getOptional("aws_secret_access_key") + fun autoRouterDefaultModel(): Optional = + autoRouterDefaultModel.getOptional("auto_router_default_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") + fun autoRouterEmbeddingModel(): Optional = + autoRouterEmbeddingModel.getOptional("auto_router_embedding_model") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun configurableClientsideAuthParams(): Optional> = - configurableClientsideAuthParams.getOptional("configurable_clientside_auth_params") + fun awsAccessKeyId(): Optional = awsAccessKeyId.getOptional("aws_access_key_id") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun customLlmProvider(): Optional = - customLlmProvider.getOptional("custom_llm_provider") + fun awsBedrockRuntimeEndpoint(): Optional = + awsBedrockRuntimeEndpoint.getOptional("aws_bedrock_runtime_endpoint") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun inputCostPerSecond(): Optional = - inputCostPerSecond.getOptional("input_cost_per_second") + fun awsRegionName(): Optional = awsRegionName.getOptional("aws_region_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun inputCostPerToken(): Optional = - inputCostPerToken.getOptional("input_cost_per_token") + fun awsSecretAccessKey(): Optional = + awsSecretAccessKey.getOptional("aws_secret_access_key") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun llmTraceId(): Optional = llmTraceId.getOptional("llm_trace_id") + fun budgetDuration(): Optional = budgetDuration.getOptional("budget_duration") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxBudget(): Optional = maxBudget.getOptional("max_budget") + fun cacheCreationInputAudioTokenCost(): Optional = + cacheCreationInputAudioTokenCost.getOptional("cache_creation_input_audio_token_cost") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxFileSizeMb(): Optional = maxFileSizeMb.getOptional("max_file_size_mb") + fun cacheCreationInputTokenCost(): Optional = + cacheCreationInputTokenCost.getOptional("cache_creation_input_token_cost") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun maxRetries(): Optional = maxRetries.getOptional("max_retries") + fun cacheCreationInputTokenCostAbove1hr(): Optional = + cacheCreationInputTokenCostAbove1hr.getOptional( + "cache_creation_input_token_cost_above_1hr" + ) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun mergeReasoningContentInChoices(): Optional = - mergeReasoningContentInChoices.getOptional("merge_reasoning_content_in_choices") - - @JsonProperty("model_info") @ExcludeMissing fun _modelInfo(): JsonValue = modelInfo + fun cacheCreationInputTokenCostAbove200kTokens(): Optional = + cacheCreationInputTokenCostAbove200kTokens.getOptional( + "cache_creation_input_token_cost_above_200k_tokens" + ) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun organization(): Optional = organization.getOptional("organization") + fun cacheReadInputAudioTokenCost(): Optional = + cacheReadInputAudioTokenCost.getOptional("cache_read_input_audio_token_cost") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun outputCostPerSecond(): Optional = - outputCostPerSecond.getOptional("output_cost_per_second") + fun cacheReadInputTokenCost(): Optional = + cacheReadInputTokenCost.getOptional("cache_read_input_token_cost") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun outputCostPerToken(): Optional = - outputCostPerToken.getOptional("output_cost_per_token") + fun cacheReadInputTokenCostAbove200kTokens(): Optional = + cacheReadInputTokenCostAbove200kTokens.getOptional( + "cache_read_input_token_cost_above_200k_tokens" + ) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun regionName(): Optional = regionName.getOptional("region_name") + fun cacheReadInputTokenCostFlex(): Optional = + cacheReadInputTokenCostFlex.getOptional("cache_read_input_token_cost_flex") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun rpm(): Optional = rpm.getOptional("rpm") + fun cacheReadInputTokenCostPriority(): Optional = + cacheReadInputTokenCostPriority.getOptional("cache_read_input_token_cost_priority") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun streamTimeout(): Optional = streamTimeout.getOptional("stream_timeout") + fun citationCostPerToken(): Optional = + citationCostPerToken.getOptional("citation_cost_per_token") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun timeout(): Optional = timeout.getOptional("timeout") + fun configurableClientsideAuthParams(): Optional> = + configurableClientsideAuthParams.getOptional("configurable_clientside_auth_params") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tpm(): Optional = tpm.getOptional("tpm") + fun customLlmProvider(): Optional = + customLlmProvider.getOptional("custom_llm_provider") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun useInPassThrough(): Optional = - useInPassThrough.getOptional("use_in_pass_through") + fun gcsBucketName(): Optional = gcsBucketName.getOptional("gcs_bucket_name") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexCredentials(): Optional = - vertexCredentials.getOptional("vertex_credentials") + fun inputCostPerAudioPerSecond(): Optional = + inputCostPerAudioPerSecond.getOptional("input_cost_per_audio_per_second") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexLocation(): Optional = vertexLocation.getOptional("vertex_location") + fun inputCostPerAudioPerSecondAbove128kTokens(): Optional = + inputCostPerAudioPerSecondAbove128kTokens.getOptional( + "input_cost_per_audio_per_second_above_128k_tokens" + ) /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun vertexProject(): Optional = vertexProject.getOptional("vertex_project") + fun inputCostPerAudioToken(): Optional = + inputCostPerAudioToken.getOptional("input_cost_per_audio_token") /** * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun watsonxRegionName(): Optional = - watsonxRegionName.getOptional("watsonx_region_name") + fun inputCostPerCharacter(): Optional = + inputCostPerCharacter.getOptional("input_cost_per_character") /** - * Returns the raw JSON value of [model]. - * - * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + fun inputCostPerCharacterAbove128kTokens(): Optional = + inputCostPerCharacterAbove128kTokens.getOptional( + "input_cost_per_character_above_128k_tokens" + ) /** - * Returns the raw JSON value of [apiBase]. - * - * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("api_base") @ExcludeMissing fun _apiBase(): JsonField = apiBase + fun inputCostPerImage(): Optional = + inputCostPerImage.getOptional("input_cost_per_image") /** - * Returns the raw JSON value of [apiKey]. - * - * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + fun inputCostPerImageAbove128kTokens(): Optional = + inputCostPerImageAbove128kTokens.getOptional("input_cost_per_image_above_128k_tokens") /** - * Returns the raw JSON value of [apiVersion]. - * - * Unlike [apiVersion], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("api_version") - @ExcludeMissing - fun _apiVersion(): JsonField = apiVersion + fun inputCostPerPixel(): Optional = + inputCostPerPixel.getOptional("input_cost_per_pixel") /** - * Returns the raw JSON value of [awsAccessKeyId]. - * - * Unlike [awsAccessKeyId], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("aws_access_key_id") - @ExcludeMissing - fun _awsAccessKeyId(): JsonField = awsAccessKeyId + fun inputCostPerQuery(): Optional = + inputCostPerQuery.getOptional("input_cost_per_query") /** - * Returns the raw JSON value of [awsRegionName]. - * - * Unlike [awsRegionName], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("aws_region_name") - @ExcludeMissing - fun _awsRegionName(): JsonField = awsRegionName + fun inputCostPerSecond(): Optional = + inputCostPerSecond.getOptional("input_cost_per_second") /** - * Returns the raw JSON value of [awsSecretAccessKey]. - * - * Unlike [awsSecretAccessKey], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("aws_secret_access_key") - @ExcludeMissing - fun _awsSecretAccessKey(): JsonField = awsSecretAccessKey + fun inputCostPerToken(): Optional = + inputCostPerToken.getOptional("input_cost_per_token") /** - * Returns the raw JSON value of [budgetDuration]. - * - * Unlike [budgetDuration], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("budget_duration") - @ExcludeMissing - fun _budgetDuration(): JsonField = budgetDuration + fun inputCostPerTokenAbove128kTokens(): Optional = + inputCostPerTokenAbove128kTokens.getOptional("input_cost_per_token_above_128k_tokens") /** - * Returns the raw JSON value of [configurableClientsideAuthParams]. - * - * Unlike [configurableClientsideAuthParams], this method doesn't throw if the JSON field - * has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("configurable_clientside_auth_params") - @ExcludeMissing - fun _configurableClientsideAuthParams(): JsonField> = - configurableClientsideAuthParams + fun inputCostPerTokenAbove200kTokens(): Optional = + inputCostPerTokenAbove200kTokens.getOptional("input_cost_per_token_above_200k_tokens") /** - * Returns the raw JSON value of [customLlmProvider]. - * - * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("custom_llm_provider") - @ExcludeMissing - fun _customLlmProvider(): JsonField = customLlmProvider + fun inputCostPerTokenBatches(): Optional = + inputCostPerTokenBatches.getOptional("input_cost_per_token_batches") /** - * Returns the raw JSON value of [inputCostPerSecond]. - * - * Unlike [inputCostPerSecond], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("input_cost_per_second") - @ExcludeMissing - fun _inputCostPerSecond(): JsonField = inputCostPerSecond + fun inputCostPerTokenCacheHit(): Optional = + inputCostPerTokenCacheHit.getOptional("input_cost_per_token_cache_hit") /** - * Returns the raw JSON value of [inputCostPerToken]. - * - * Unlike [inputCostPerToken], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("input_cost_per_token") - @ExcludeMissing - fun _inputCostPerToken(): JsonField = inputCostPerToken + fun inputCostPerTokenFlex(): Optional = + inputCostPerTokenFlex.getOptional("input_cost_per_token_flex") /** - * Returns the raw JSON value of [llmTraceId]. - * - * Unlike [llmTraceId], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("llm_trace_id") - @ExcludeMissing - fun _llmTraceId(): JsonField = llmTraceId + fun inputCostPerTokenPriority(): Optional = + inputCostPerTokenPriority.getOptional("input_cost_per_token_priority") /** - * Returns the raw JSON value of [maxBudget]. - * - * Unlike [maxBudget], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("max_budget") @ExcludeMissing fun _maxBudget(): JsonField = maxBudget + fun inputCostPerVideoPerSecond(): Optional = + inputCostPerVideoPerSecond.getOptional("input_cost_per_video_per_second") /** - * Returns the raw JSON value of [maxFileSizeMb]. - * - * Unlike [maxFileSizeMb], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("max_file_size_mb") - @ExcludeMissing - fun _maxFileSizeMb(): JsonField = maxFileSizeMb + fun inputCostPerVideoPerSecondAbove128kTokens(): Optional = + inputCostPerVideoPerSecondAbove128kTokens.getOptional( + "input_cost_per_video_per_second_above_128k_tokens" + ) /** - * Returns the raw JSON value of [maxRetries]. - * - * Unlike [maxRetries], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("max_retries") @ExcludeMissing fun _maxRetries(): JsonField = maxRetries + fun inputCostPerVideoPerSecondAbove15sInterval(): Optional = + inputCostPerVideoPerSecondAbove15sInterval.getOptional( + "input_cost_per_video_per_second_above_15s_interval" + ) /** - * Returns the raw JSON value of [mergeReasoningContentInChoices]. - * - * Unlike [mergeReasoningContentInChoices], this method doesn't throw if the JSON field has - * an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("merge_reasoning_content_in_choices") - @ExcludeMissing - fun _mergeReasoningContentInChoices(): JsonField = mergeReasoningContentInChoices + fun inputCostPerVideoPerSecondAbove8sInterval(): Optional = + inputCostPerVideoPerSecondAbove8sInterval.getOptional( + "input_cost_per_video_per_second_above_8s_interval" + ) /** - * Returns the raw JSON value of [organization]. - * - * Unlike [organization], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("organization") - @ExcludeMissing - fun _organization(): JsonField = organization + fun litellmCredentialName(): Optional = + litellmCredentialName.getOptional("litellm_credential_name") /** - * Returns the raw JSON value of [outputCostPerSecond]. - * - * Unlike [outputCostPerSecond], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("output_cost_per_second") - @ExcludeMissing - fun _outputCostPerSecond(): JsonField = outputCostPerSecond + fun litellmTraceId(): Optional = litellmTraceId.getOptional("litellm_trace_id") /** - * Returns the raw JSON value of [outputCostPerToken]. - * - * Unlike [outputCostPerToken], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("output_cost_per_token") - @ExcludeMissing - fun _outputCostPerToken(): JsonField = outputCostPerToken + fun maxBudget(): Optional = maxBudget.getOptional("max_budget") /** - * Returns the raw JSON value of [regionName]. - * - * Unlike [regionName], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("region_name") - @ExcludeMissing - fun _regionName(): JsonField = regionName + fun maxFileSizeMb(): Optional = maxFileSizeMb.getOptional("max_file_size_mb") /** - * Returns the raw JSON value of [rpm]. - * - * Unlike [rpm], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("rpm") @ExcludeMissing fun _rpm(): JsonField = rpm + fun maxRetries(): Optional = maxRetries.getOptional("max_retries") /** - * Returns the raw JSON value of [streamTimeout]. - * - * Unlike [streamTimeout], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("stream_timeout") - @ExcludeMissing - fun _streamTimeout(): JsonField = streamTimeout + fun mergeReasoningContentInChoices(): Optional = + mergeReasoningContentInChoices.getOptional("merge_reasoning_content_in_choices") /** - * Returns the raw JSON value of [timeout]. - * - * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + fun milvusTextField(): Optional = milvusTextField.getOptional("milvus_text_field") /** - * Returns the raw JSON value of [tpm]. - * - * Unlike [tpm], this method doesn't throw if the JSON field has an unexpected type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("tpm") @ExcludeMissing fun _tpm(): JsonField = tpm + fun mockResponse(): Optional = mockResponse.getOptional("mock_response") /** - * Returns the raw JSON value of [useInPassThrough]. - * - * Unlike [useInPassThrough], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("use_in_pass_through") - @ExcludeMissing - fun _useInPassThrough(): JsonField = useInPassThrough + fun modelInfo(): Optional = modelInfo.getOptional("model_info") /** - * Returns the raw JSON value of [vertexCredentials]. - * - * Unlike [vertexCredentials], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("vertex_credentials") - @ExcludeMissing - fun _vertexCredentials(): JsonField = vertexCredentials + fun organization(): Optional = organization.getOptional("organization") /** - * Returns the raw JSON value of [vertexLocation]. - * - * Unlike [vertexLocation], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("vertex_location") - @ExcludeMissing - fun _vertexLocation(): JsonField = vertexLocation + fun outputCostPerAudioPerSecond(): Optional = + outputCostPerAudioPerSecond.getOptional("output_cost_per_audio_per_second") /** - * Returns the raw JSON value of [vertexProject]. - * - * Unlike [vertexProject], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("vertex_project") - @ExcludeMissing - fun _vertexProject(): JsonField = vertexProject + fun outputCostPerAudioToken(): Optional = + outputCostPerAudioToken.getOptional("output_cost_per_audio_token") /** - * Returns the raw JSON value of [watsonxRegionName]. - * - * Unlike [watsonxRegionName], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("watsonx_region_name") - @ExcludeMissing - fun _watsonxRegionName(): JsonField = watsonxRegionName + fun outputCostPerCharacter(): Optional = + outputCostPerCharacter.getOptional("output_cost_per_character") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerCharacterAbove128kTokens(): Optional = + outputCostPerCharacterAbove128kTokens.getOptional( + "output_cost_per_character_above_128k_tokens" + ) - fun toBuilder() = Builder().from(this) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerImage(): Optional = + outputCostPerImage.getOptional("output_cost_per_image") - companion object { + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerImageToken(): Optional = + outputCostPerImageToken.getOptional("output_cost_per_image_token") - /** - * Returns a mutable builder for constructing an instance of [LlmParams]. - * - * The following fields are required: - * ```java - * .model() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerPixel(): Optional = + outputCostPerPixel.getOptional("output_cost_per_pixel") - /** A builder for [LlmParams]. */ - class Builder internal constructor() { + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerReasoningToken(): Optional = + outputCostPerReasoningToken.getOptional("output_cost_per_reasoning_token") - private var model: JsonField? = null - private var apiBase: JsonField = JsonMissing.of() - private var apiKey: JsonField = JsonMissing.of() - private var apiVersion: JsonField = JsonMissing.of() - private var awsAccessKeyId: JsonField = JsonMissing.of() - private var awsRegionName: JsonField = JsonMissing.of() - private var awsSecretAccessKey: JsonField = JsonMissing.of() - private var budgetDuration: JsonField = JsonMissing.of() - private var configurableClientsideAuthParams: - JsonField>? = - null - private var customLlmProvider: JsonField = JsonMissing.of() - private var inputCostPerSecond: JsonField = JsonMissing.of() - private var inputCostPerToken: JsonField = JsonMissing.of() - private var llmTraceId: JsonField = JsonMissing.of() - private var maxBudget: JsonField = JsonMissing.of() - private var maxFileSizeMb: JsonField = JsonMissing.of() - private var maxRetries: JsonField = JsonMissing.of() - private var mergeReasoningContentInChoices: JsonField = JsonMissing.of() - private var modelInfo: JsonValue = JsonMissing.of() - private var organization: JsonField = JsonMissing.of() - private var outputCostPerSecond: JsonField = JsonMissing.of() - private var outputCostPerToken: JsonField = JsonMissing.of() - private var regionName: JsonField = JsonMissing.of() - private var rpm: JsonField = JsonMissing.of() - private var streamTimeout: JsonField = JsonMissing.of() - private var timeout: JsonField = JsonMissing.of() - private var tpm: JsonField = JsonMissing.of() - private var useInPassThrough: JsonField = JsonMissing.of() - private var vertexCredentials: JsonField = JsonMissing.of() - private var vertexLocation: JsonField = JsonMissing.of() - private var vertexProject: JsonField = JsonMissing.of() - private var watsonxRegionName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerSecond(): Optional = + outputCostPerSecond.getOptional("output_cost_per_second") - @JvmSynthetic - internal fun from(llmParams: LlmParams) = apply { - model = llmParams.model - apiBase = llmParams.apiBase - apiKey = llmParams.apiKey - apiVersion = llmParams.apiVersion - awsAccessKeyId = llmParams.awsAccessKeyId - awsRegionName = llmParams.awsRegionName - awsSecretAccessKey = llmParams.awsSecretAccessKey - budgetDuration = llmParams.budgetDuration - configurableClientsideAuthParams = - llmParams.configurableClientsideAuthParams.map { it.toMutableList() } - customLlmProvider = llmParams.customLlmProvider - inputCostPerSecond = llmParams.inputCostPerSecond - inputCostPerToken = llmParams.inputCostPerToken - llmTraceId = llmParams.llmTraceId - maxBudget = llmParams.maxBudget - maxFileSizeMb = llmParams.maxFileSizeMb - maxRetries = llmParams.maxRetries - mergeReasoningContentInChoices = llmParams.mergeReasoningContentInChoices - modelInfo = llmParams.modelInfo - organization = llmParams.organization - outputCostPerSecond = llmParams.outputCostPerSecond - outputCostPerToken = llmParams.outputCostPerToken - regionName = llmParams.regionName - rpm = llmParams.rpm - streamTimeout = llmParams.streamTimeout - timeout = llmParams.timeout - tpm = llmParams.tpm - useInPassThrough = llmParams.useInPassThrough - vertexCredentials = llmParams.vertexCredentials - vertexLocation = llmParams.vertexLocation - vertexProject = llmParams.vertexProject - watsonxRegionName = llmParams.watsonxRegionName - additionalProperties = llmParams.additionalProperties.toMutableMap() - } + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerToken(): Optional = + outputCostPerToken.getOptional("output_cost_per_token") - fun model(model: String) = model(JsonField.of(model)) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerTokenAbove128kTokens(): Optional = + outputCostPerTokenAbove128kTokens.getOptional("output_cost_per_token_above_128k_tokens") - /** - * Sets [Builder.model] to an arbitrary JSON value. - * - * You should usually call [Builder.model] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun model(model: JsonField) = apply { this.model = model } + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerTokenAbove200kTokens(): Optional = + outputCostPerTokenAbove200kTokens.getOptional("output_cost_per_token_above_200k_tokens") - fun apiBase(apiBase: String?) = apiBase(JsonField.ofNullable(apiBase)) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerTokenBatches(): Optional = + outputCostPerTokenBatches.getOptional("output_cost_per_token_batches") - /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ - fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerTokenFlex(): Optional = + outputCostPerTokenFlex.getOptional("output_cost_per_token_flex") - /** - * Sets [Builder.apiBase] to an arbitrary JSON value. - * - * You should usually call [Builder.apiBase] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerTokenPriority(): Optional = + outputCostPerTokenPriority.getOptional("output_cost_per_token_priority") - fun apiKey(apiKey: String?) = apiKey(JsonField.ofNullable(apiKey)) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputCostPerVideoPerSecond(): Optional = + outputCostPerVideoPerSecond.getOptional("output_cost_per_video_per_second") - /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ - fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun regionName(): Optional = regionName.getOptional("region_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rpm(): Optional = rpm.getOptional("rpm") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun s3BucketName(): Optional = s3BucketName.getOptional("s3_bucket_name") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun s3EncryptionKeyId(): Optional = + s3EncryptionKeyId.getOptional("s3_encryption_key_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun searchContextCostPerQuery(): Optional = + searchContextCostPerQuery.getOptional("search_context_cost_per_query") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamTimeout(): Optional = streamTimeout.getOptional("stream_timeout") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tieredPricing(): Optional> = + tieredPricing.getOptional("tiered_pricing") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tpm(): Optional = tpm.getOptional("tpm") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useInPassThrough(): Optional = + useInPassThrough.getOptional("use_in_pass_through") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useLitellmProxy(): Optional = useLitellmProxy.getOptional("use_litellm_proxy") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vectorStoreId(): Optional = vectorStoreId.getOptional("vector_store_id") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vertexCredentials(): Optional = + vertexCredentials.getOptional("vertex_credentials") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vertexLocation(): Optional = vertexLocation.getOptional("vertex_location") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vertexProject(): Optional = vertexProject.getOptional("vertex_project") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun watsonxRegionName(): Optional = + watsonxRegionName.getOptional("watsonx_region_name") + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_base") @ExcludeMissing fun _apiBase(): JsonField = apiBase + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [apiVersion]. + * + * Unlike [apiVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_version") + @ExcludeMissing + fun _apiVersion(): JsonField = apiVersion + + /** + * Returns the raw JSON value of [autoRouterConfig]. + * + * Unlike [autoRouterConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_router_config") + @ExcludeMissing + fun _autoRouterConfig(): JsonField = autoRouterConfig + + /** + * Returns the raw JSON value of [autoRouterConfigPath]. + * + * Unlike [autoRouterConfigPath], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auto_router_config_path") + @ExcludeMissing + fun _autoRouterConfigPath(): JsonField = autoRouterConfigPath + + /** + * Returns the raw JSON value of [autoRouterDefaultModel]. + * + * Unlike [autoRouterDefaultModel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auto_router_default_model") + @ExcludeMissing + fun _autoRouterDefaultModel(): JsonField = autoRouterDefaultModel + + /** + * Returns the raw JSON value of [autoRouterEmbeddingModel]. + * + * Unlike [autoRouterEmbeddingModel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auto_router_embedding_model") + @ExcludeMissing + fun _autoRouterEmbeddingModel(): JsonField = autoRouterEmbeddingModel + + /** + * Returns the raw JSON value of [awsAccessKeyId]. + * + * Unlike [awsAccessKeyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aws_access_key_id") + @ExcludeMissing + fun _awsAccessKeyId(): JsonField = awsAccessKeyId + + /** + * Returns the raw JSON value of [awsBedrockRuntimeEndpoint]. + * + * Unlike [awsBedrockRuntimeEndpoint], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aws_bedrock_runtime_endpoint") + @ExcludeMissing + fun _awsBedrockRuntimeEndpoint(): JsonField = awsBedrockRuntimeEndpoint + + /** + * Returns the raw JSON value of [awsRegionName]. + * + * Unlike [awsRegionName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aws_region_name") + @ExcludeMissing + fun _awsRegionName(): JsonField = awsRegionName + + /** + * Returns the raw JSON value of [awsSecretAccessKey]. + * + * Unlike [awsSecretAccessKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aws_secret_access_key") + @ExcludeMissing + fun _awsSecretAccessKey(): JsonField = awsSecretAccessKey + + /** + * Returns the raw JSON value of [budgetDuration]. + * + * Unlike [budgetDuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("budget_duration") + @ExcludeMissing + fun _budgetDuration(): JsonField = budgetDuration + + /** + * Returns the raw JSON value of [cacheCreationInputAudioTokenCost]. + * + * Unlike [cacheCreationInputAudioTokenCost], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cache_creation_input_audio_token_cost") + @ExcludeMissing + fun _cacheCreationInputAudioTokenCost(): JsonField = + cacheCreationInputAudioTokenCost + + /** + * Returns the raw JSON value of [cacheCreationInputTokenCost]. + * + * Unlike [cacheCreationInputTokenCost], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_creation_input_token_cost") + @ExcludeMissing + fun _cacheCreationInputTokenCost(): JsonField = cacheCreationInputTokenCost + + /** + * Returns the raw JSON value of [cacheCreationInputTokenCostAbove1hr]. + * + * Unlike [cacheCreationInputTokenCostAbove1hr], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cache_creation_input_token_cost_above_1hr") + @ExcludeMissing + fun _cacheCreationInputTokenCostAbove1hr(): JsonField = + cacheCreationInputTokenCostAbove1hr + + /** + * Returns the raw JSON value of [cacheCreationInputTokenCostAbove200kTokens]. + * + * Unlike [cacheCreationInputTokenCostAbove200kTokens], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("cache_creation_input_token_cost_above_200k_tokens") + @ExcludeMissing + fun _cacheCreationInputTokenCostAbove200kTokens(): JsonField = + cacheCreationInputTokenCostAbove200kTokens + + /** + * Returns the raw JSON value of [cacheReadInputAudioTokenCost]. + * + * Unlike [cacheReadInputAudioTokenCost], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_read_input_audio_token_cost") + @ExcludeMissing + fun _cacheReadInputAudioTokenCost(): JsonField = cacheReadInputAudioTokenCost + + /** + * Returns the raw JSON value of [cacheReadInputTokenCost]. + * + * Unlike [cacheReadInputTokenCost], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_read_input_token_cost") + @ExcludeMissing + fun _cacheReadInputTokenCost(): JsonField = cacheReadInputTokenCost + + /** + * Returns the raw JSON value of [cacheReadInputTokenCostAbove200kTokens]. + * + * Unlike [cacheReadInputTokenCostAbove200kTokens], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cache_read_input_token_cost_above_200k_tokens") + @ExcludeMissing + fun _cacheReadInputTokenCostAbove200kTokens(): JsonField = + cacheReadInputTokenCostAbove200kTokens + + /** + * Returns the raw JSON value of [cacheReadInputTokenCostFlex]. + * + * Unlike [cacheReadInputTokenCostFlex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cache_read_input_token_cost_flex") + @ExcludeMissing + fun _cacheReadInputTokenCostFlex(): JsonField = cacheReadInputTokenCostFlex + + /** + * Returns the raw JSON value of [cacheReadInputTokenCostPriority]. + * + * Unlike [cacheReadInputTokenCostPriority], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cache_read_input_token_cost_priority") + @ExcludeMissing + fun _cacheReadInputTokenCostPriority(): JsonField = cacheReadInputTokenCostPriority + + /** + * Returns the raw JSON value of [citationCostPerToken]. + * + * Unlike [citationCostPerToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("citation_cost_per_token") + @ExcludeMissing + fun _citationCostPerToken(): JsonField = citationCostPerToken + + /** + * Returns the raw JSON value of [configurableClientsideAuthParams]. + * + * Unlike [configurableClientsideAuthParams], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("configurable_clientside_auth_params") + @ExcludeMissing + fun _configurableClientsideAuthParams(): JsonField> = + configurableClientsideAuthParams + + /** + * Returns the raw JSON value of [customLlmProvider]. + * + * Unlike [customLlmProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_llm_provider") + @ExcludeMissing + fun _customLlmProvider(): JsonField = customLlmProvider + + /** + * Returns the raw JSON value of [gcsBucketName]. + * + * Unlike [gcsBucketName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gcs_bucket_name") + @ExcludeMissing + fun _gcsBucketName(): JsonField = gcsBucketName + + /** + * Returns the raw JSON value of [inputCostPerAudioPerSecond]. + * + * Unlike [inputCostPerAudioPerSecond], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_audio_per_second") + @ExcludeMissing + fun _inputCostPerAudioPerSecond(): JsonField = inputCostPerAudioPerSecond + + /** + * Returns the raw JSON value of [inputCostPerAudioPerSecondAbove128kTokens]. + * + * Unlike [inputCostPerAudioPerSecondAbove128kTokens], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("input_cost_per_audio_per_second_above_128k_tokens") + @ExcludeMissing + fun _inputCostPerAudioPerSecondAbove128kTokens(): JsonField = + inputCostPerAudioPerSecondAbove128kTokens + + /** + * Returns the raw JSON value of [inputCostPerAudioToken]. + * + * Unlike [inputCostPerAudioToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_audio_token") + @ExcludeMissing + fun _inputCostPerAudioToken(): JsonField = inputCostPerAudioToken + + /** + * Returns the raw JSON value of [inputCostPerCharacter]. + * + * Unlike [inputCostPerCharacter], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_character") + @ExcludeMissing + fun _inputCostPerCharacter(): JsonField = inputCostPerCharacter + + /** + * Returns the raw JSON value of [inputCostPerCharacterAbove128kTokens]. + * + * Unlike [inputCostPerCharacterAbove128kTokens], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("input_cost_per_character_above_128k_tokens") + @ExcludeMissing + fun _inputCostPerCharacterAbove128kTokens(): JsonField = + inputCostPerCharacterAbove128kTokens + + /** + * Returns the raw JSON value of [inputCostPerImage]. + * + * Unlike [inputCostPerImage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("input_cost_per_image") + @ExcludeMissing + fun _inputCostPerImage(): JsonField = inputCostPerImage + + /** + * Returns the raw JSON value of [inputCostPerImageAbove128kTokens]. + * + * Unlike [inputCostPerImageAbove128kTokens], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("input_cost_per_image_above_128k_tokens") + @ExcludeMissing + fun _inputCostPerImageAbove128kTokens(): JsonField = + inputCostPerImageAbove128kTokens + + /** + * Returns the raw JSON value of [inputCostPerPixel]. + * + * Unlike [inputCostPerPixel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("input_cost_per_pixel") + @ExcludeMissing + fun _inputCostPerPixel(): JsonField = inputCostPerPixel + + /** + * Returns the raw JSON value of [inputCostPerQuery]. + * + * Unlike [inputCostPerQuery], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("input_cost_per_query") + @ExcludeMissing + fun _inputCostPerQuery(): JsonField = inputCostPerQuery + + /** + * Returns the raw JSON value of [inputCostPerSecond]. + * + * Unlike [inputCostPerSecond], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_second") + @ExcludeMissing + fun _inputCostPerSecond(): JsonField = inputCostPerSecond + + /** + * Returns the raw JSON value of [inputCostPerToken]. + * + * Unlike [inputCostPerToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("input_cost_per_token") + @ExcludeMissing + fun _inputCostPerToken(): JsonField = inputCostPerToken + + /** + * Returns the raw JSON value of [inputCostPerTokenAbove128kTokens]. + * + * Unlike [inputCostPerTokenAbove128kTokens], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("input_cost_per_token_above_128k_tokens") + @ExcludeMissing + fun _inputCostPerTokenAbove128kTokens(): JsonField = + inputCostPerTokenAbove128kTokens + + /** + * Returns the raw JSON value of [inputCostPerTokenAbove200kTokens]. + * + * Unlike [inputCostPerTokenAbove200kTokens], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("input_cost_per_token_above_200k_tokens") + @ExcludeMissing + fun _inputCostPerTokenAbove200kTokens(): JsonField = + inputCostPerTokenAbove200kTokens + + /** + * Returns the raw JSON value of [inputCostPerTokenBatches]. + * + * Unlike [inputCostPerTokenBatches], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_token_batches") + @ExcludeMissing + fun _inputCostPerTokenBatches(): JsonField = inputCostPerTokenBatches + + /** + * Returns the raw JSON value of [inputCostPerTokenCacheHit]. + * + * Unlike [inputCostPerTokenCacheHit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_token_cache_hit") + @ExcludeMissing + fun _inputCostPerTokenCacheHit(): JsonField = inputCostPerTokenCacheHit + + /** + * Returns the raw JSON value of [inputCostPerTokenFlex]. + * + * Unlike [inputCostPerTokenFlex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_token_flex") + @ExcludeMissing + fun _inputCostPerTokenFlex(): JsonField = inputCostPerTokenFlex + + /** + * Returns the raw JSON value of [inputCostPerTokenPriority]. + * + * Unlike [inputCostPerTokenPriority], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_token_priority") + @ExcludeMissing + fun _inputCostPerTokenPriority(): JsonField = inputCostPerTokenPriority + + /** + * Returns the raw JSON value of [inputCostPerVideoPerSecond]. + * + * Unlike [inputCostPerVideoPerSecond], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("input_cost_per_video_per_second") + @ExcludeMissing + fun _inputCostPerVideoPerSecond(): JsonField = inputCostPerVideoPerSecond + + /** + * Returns the raw JSON value of [inputCostPerVideoPerSecondAbove128kTokens]. + * + * Unlike [inputCostPerVideoPerSecondAbove128kTokens], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("input_cost_per_video_per_second_above_128k_tokens") + @ExcludeMissing + fun _inputCostPerVideoPerSecondAbove128kTokens(): JsonField = + inputCostPerVideoPerSecondAbove128kTokens + + /** + * Returns the raw JSON value of [inputCostPerVideoPerSecondAbove15sInterval]. + * + * Unlike [inputCostPerVideoPerSecondAbove15sInterval], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("input_cost_per_video_per_second_above_15s_interval") + @ExcludeMissing + fun _inputCostPerVideoPerSecondAbove15sInterval(): JsonField = + inputCostPerVideoPerSecondAbove15sInterval + + /** + * Returns the raw JSON value of [inputCostPerVideoPerSecondAbove8sInterval]. + * + * Unlike [inputCostPerVideoPerSecondAbove8sInterval], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("input_cost_per_video_per_second_above_8s_interval") + @ExcludeMissing + fun _inputCostPerVideoPerSecondAbove8sInterval(): JsonField = + inputCostPerVideoPerSecondAbove8sInterval + + /** + * Returns the raw JSON value of [litellmCredentialName]. + * + * Unlike [litellmCredentialName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("litellm_credential_name") + @ExcludeMissing + fun _litellmCredentialName(): JsonField = litellmCredentialName + + /** + * Returns the raw JSON value of [litellmTraceId]. + * + * Unlike [litellmTraceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("litellm_trace_id") + @ExcludeMissing + fun _litellmTraceId(): JsonField = litellmTraceId + + /** + * Returns the raw JSON value of [maxBudget]. + * + * Unlike [maxBudget], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_budget") @ExcludeMissing fun _maxBudget(): JsonField = maxBudget + + /** + * Returns the raw JSON value of [maxFileSizeMb]. + * + * Unlike [maxFileSizeMb], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("max_file_size_mb") + @ExcludeMissing + fun _maxFileSizeMb(): JsonField = maxFileSizeMb + + /** + * Returns the raw JSON value of [maxRetries]. + * + * Unlike [maxRetries], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_retries") @ExcludeMissing fun _maxRetries(): JsonField = maxRetries + + /** + * Returns the raw JSON value of [mergeReasoningContentInChoices]. + * + * Unlike [mergeReasoningContentInChoices], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merge_reasoning_content_in_choices") + @ExcludeMissing + fun _mergeReasoningContentInChoices(): JsonField = mergeReasoningContentInChoices + + /** + * Returns the raw JSON value of [milvusTextField]. + * + * Unlike [milvusTextField], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("milvus_text_field") + @ExcludeMissing + fun _milvusTextField(): JsonField = milvusTextField + + /** + * Returns the raw JSON value of [mockResponse]. + * + * Unlike [mockResponse], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mock_response") + @ExcludeMissing + fun _mockResponse(): JsonField = mockResponse + + /** + * Returns the raw JSON value of [modelInfo]. + * + * Unlike [modelInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_info") + @ExcludeMissing + fun _modelInfo(): JsonField = modelInfo + + /** + * Returns the raw JSON value of [organization]. + * + * Unlike [organization], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("organization") + @ExcludeMissing + fun _organization(): JsonField = organization + + /** + * Returns the raw JSON value of [outputCostPerAudioPerSecond]. + * + * Unlike [outputCostPerAudioPerSecond], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_audio_per_second") + @ExcludeMissing + fun _outputCostPerAudioPerSecond(): JsonField = outputCostPerAudioPerSecond + + /** + * Returns the raw JSON value of [outputCostPerAudioToken]. + * + * Unlike [outputCostPerAudioToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_audio_token") + @ExcludeMissing + fun _outputCostPerAudioToken(): JsonField = outputCostPerAudioToken + + /** + * Returns the raw JSON value of [outputCostPerCharacter]. + * + * Unlike [outputCostPerCharacter], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_character") + @ExcludeMissing + fun _outputCostPerCharacter(): JsonField = outputCostPerCharacter + + /** + * Returns the raw JSON value of [outputCostPerCharacterAbove128kTokens]. + * + * Unlike [outputCostPerCharacterAbove128kTokens], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("output_cost_per_character_above_128k_tokens") + @ExcludeMissing + fun _outputCostPerCharacterAbove128kTokens(): JsonField = + outputCostPerCharacterAbove128kTokens + + /** + * Returns the raw JSON value of [outputCostPerImage]. + * + * Unlike [outputCostPerImage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_image") + @ExcludeMissing + fun _outputCostPerImage(): JsonField = outputCostPerImage + + /** + * Returns the raw JSON value of [outputCostPerImageToken]. + * + * Unlike [outputCostPerImageToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_image_token") + @ExcludeMissing + fun _outputCostPerImageToken(): JsonField = outputCostPerImageToken + + /** + * Returns the raw JSON value of [outputCostPerPixel]. + * + * Unlike [outputCostPerPixel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_pixel") + @ExcludeMissing + fun _outputCostPerPixel(): JsonField = outputCostPerPixel + + /** + * Returns the raw JSON value of [outputCostPerReasoningToken]. + * + * Unlike [outputCostPerReasoningToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_reasoning_token") + @ExcludeMissing + fun _outputCostPerReasoningToken(): JsonField = outputCostPerReasoningToken + + /** + * Returns the raw JSON value of [outputCostPerSecond]. + * + * Unlike [outputCostPerSecond], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_second") + @ExcludeMissing + fun _outputCostPerSecond(): JsonField = outputCostPerSecond + + /** + * Returns the raw JSON value of [outputCostPerToken]. + * + * Unlike [outputCostPerToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_token") + @ExcludeMissing + fun _outputCostPerToken(): JsonField = outputCostPerToken + + /** + * Returns the raw JSON value of [outputCostPerTokenAbove128kTokens]. + * + * Unlike [outputCostPerTokenAbove128kTokens], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("output_cost_per_token_above_128k_tokens") + @ExcludeMissing + fun _outputCostPerTokenAbove128kTokens(): JsonField = + outputCostPerTokenAbove128kTokens + + /** + * Returns the raw JSON value of [outputCostPerTokenAbove200kTokens]. + * + * Unlike [outputCostPerTokenAbove200kTokens], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("output_cost_per_token_above_200k_tokens") + @ExcludeMissing + fun _outputCostPerTokenAbove200kTokens(): JsonField = + outputCostPerTokenAbove200kTokens + + /** + * Returns the raw JSON value of [outputCostPerTokenBatches]. + * + * Unlike [outputCostPerTokenBatches], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_token_batches") + @ExcludeMissing + fun _outputCostPerTokenBatches(): JsonField = outputCostPerTokenBatches + + /** + * Returns the raw JSON value of [outputCostPerTokenFlex]. + * + * Unlike [outputCostPerTokenFlex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_token_flex") + @ExcludeMissing + fun _outputCostPerTokenFlex(): JsonField = outputCostPerTokenFlex + + /** + * Returns the raw JSON value of [outputCostPerTokenPriority]. + * + * Unlike [outputCostPerTokenPriority], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_token_priority") + @ExcludeMissing + fun _outputCostPerTokenPriority(): JsonField = outputCostPerTokenPriority + + /** + * Returns the raw JSON value of [outputCostPerVideoPerSecond]. + * + * Unlike [outputCostPerVideoPerSecond], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("output_cost_per_video_per_second") + @ExcludeMissing + fun _outputCostPerVideoPerSecond(): JsonField = outputCostPerVideoPerSecond + + /** + * Returns the raw JSON value of [regionName]. + * + * Unlike [regionName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region_name") + @ExcludeMissing + fun _regionName(): JsonField = regionName + + /** + * Returns the raw JSON value of [rpm]. + * + * Unlike [rpm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rpm") @ExcludeMissing fun _rpm(): JsonField = rpm + + /** + * Returns the raw JSON value of [s3BucketName]. + * + * Unlike [s3BucketName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("s3_bucket_name") + @ExcludeMissing + fun _s3BucketName(): JsonField = s3BucketName + + /** + * Returns the raw JSON value of [s3EncryptionKeyId]. + * + * Unlike [s3EncryptionKeyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("s3_encryption_key_id") + @ExcludeMissing + fun _s3EncryptionKeyId(): JsonField = s3EncryptionKeyId + + /** + * Returns the raw JSON value of [searchContextCostPerQuery]. + * + * Unlike [searchContextCostPerQuery], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("search_context_cost_per_query") + @ExcludeMissing + fun _searchContextCostPerQuery(): JsonField = + searchContextCostPerQuery + + /** + * Returns the raw JSON value of [streamTimeout]. + * + * Unlike [streamTimeout], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stream_timeout") + @ExcludeMissing + fun _streamTimeout(): JsonField = streamTimeout + + /** + * Returns the raw JSON value of [tieredPricing]. + * + * Unlike [tieredPricing], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiered_pricing") + @ExcludeMissing + fun _tieredPricing(): JsonField> = tieredPricing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [tpm]. + * + * Unlike [tpm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tpm") @ExcludeMissing fun _tpm(): JsonField = tpm + + /** + * Returns the raw JSON value of [useInPassThrough]. + * + * Unlike [useInPassThrough], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_in_pass_through") + @ExcludeMissing + fun _useInPassThrough(): JsonField = useInPassThrough + + /** + * Returns the raw JSON value of [useLitellmProxy]. + * + * Unlike [useLitellmProxy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_litellm_proxy") + @ExcludeMissing + fun _useLitellmProxy(): JsonField = useLitellmProxy + + /** + * Returns the raw JSON value of [vectorStoreId]. + * + * Unlike [vectorStoreId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vector_store_id") + @ExcludeMissing + fun _vectorStoreId(): JsonField = vectorStoreId + + /** + * Returns the raw JSON value of [vertexCredentials]. + * + * Unlike [vertexCredentials], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vertex_credentials") + @ExcludeMissing + fun _vertexCredentials(): JsonField = vertexCredentials + + /** + * Returns the raw JSON value of [vertexLocation]. + * + * Unlike [vertexLocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vertex_location") + @ExcludeMissing + fun _vertexLocation(): JsonField = vertexLocation + + /** + * Returns the raw JSON value of [vertexProject]. + * + * Unlike [vertexProject], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vertex_project") + @ExcludeMissing + fun _vertexProject(): JsonField = vertexProject + + /** + * Returns the raw JSON value of [watsonxRegionName]. + * + * Unlike [watsonxRegionName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("watsonx_region_name") + @ExcludeMissing + fun _watsonxRegionName(): JsonField = watsonxRegionName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LitellmParams]. + * + * The following fields are required: + * ```java + * .model() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LitellmParams]. */ + class Builder internal constructor() { + + private var model: JsonField? = null + private var apiBase: JsonField = JsonMissing.of() + private var apiKey: JsonField = JsonMissing.of() + private var apiVersion: JsonField = JsonMissing.of() + private var autoRouterConfig: JsonField = JsonMissing.of() + private var autoRouterConfigPath: JsonField = JsonMissing.of() + private var autoRouterDefaultModel: JsonField = JsonMissing.of() + private var autoRouterEmbeddingModel: JsonField = JsonMissing.of() + private var awsAccessKeyId: JsonField = JsonMissing.of() + private var awsBedrockRuntimeEndpoint: JsonField = JsonMissing.of() + private var awsRegionName: JsonField = JsonMissing.of() + private var awsSecretAccessKey: JsonField = JsonMissing.of() + private var budgetDuration: JsonField = JsonMissing.of() + private var cacheCreationInputAudioTokenCost: JsonField = JsonMissing.of() + private var cacheCreationInputTokenCost: JsonField = JsonMissing.of() + private var cacheCreationInputTokenCostAbove1hr: JsonField = JsonMissing.of() + private var cacheCreationInputTokenCostAbove200kTokens: JsonField = + JsonMissing.of() + private var cacheReadInputAudioTokenCost: JsonField = JsonMissing.of() + private var cacheReadInputTokenCost: JsonField = JsonMissing.of() + private var cacheReadInputTokenCostAbove200kTokens: JsonField = JsonMissing.of() + private var cacheReadInputTokenCostFlex: JsonField = JsonMissing.of() + private var cacheReadInputTokenCostPriority: JsonField = JsonMissing.of() + private var citationCostPerToken: JsonField = JsonMissing.of() + private var configurableClientsideAuthParams: + JsonField>? = + null + private var customLlmProvider: JsonField = JsonMissing.of() + private var gcsBucketName: JsonField = JsonMissing.of() + private var inputCostPerAudioPerSecond: JsonField = JsonMissing.of() + private var inputCostPerAudioPerSecondAbove128kTokens: JsonField = + JsonMissing.of() + private var inputCostPerAudioToken: JsonField = JsonMissing.of() + private var inputCostPerCharacter: JsonField = JsonMissing.of() + private var inputCostPerCharacterAbove128kTokens: JsonField = JsonMissing.of() + private var inputCostPerImage: JsonField = JsonMissing.of() + private var inputCostPerImageAbove128kTokens: JsonField = JsonMissing.of() + private var inputCostPerPixel: JsonField = JsonMissing.of() + private var inputCostPerQuery: JsonField = JsonMissing.of() + private var inputCostPerSecond: JsonField = JsonMissing.of() + private var inputCostPerToken: JsonField = JsonMissing.of() + private var inputCostPerTokenAbove128kTokens: JsonField = JsonMissing.of() + private var inputCostPerTokenAbove200kTokens: JsonField = JsonMissing.of() + private var inputCostPerTokenBatches: JsonField = JsonMissing.of() + private var inputCostPerTokenCacheHit: JsonField = JsonMissing.of() + private var inputCostPerTokenFlex: JsonField = JsonMissing.of() + private var inputCostPerTokenPriority: JsonField = JsonMissing.of() + private var inputCostPerVideoPerSecond: JsonField = JsonMissing.of() + private var inputCostPerVideoPerSecondAbove128kTokens: JsonField = + JsonMissing.of() + private var inputCostPerVideoPerSecondAbove15sInterval: JsonField = + JsonMissing.of() + private var inputCostPerVideoPerSecondAbove8sInterval: JsonField = + JsonMissing.of() + private var litellmCredentialName: JsonField = JsonMissing.of() + private var litellmTraceId: JsonField = JsonMissing.of() + private var maxBudget: JsonField = JsonMissing.of() + private var maxFileSizeMb: JsonField = JsonMissing.of() + private var maxRetries: JsonField = JsonMissing.of() + private var mergeReasoningContentInChoices: JsonField = JsonMissing.of() + private var milvusTextField: JsonField = JsonMissing.of() + private var mockResponse: JsonField = JsonMissing.of() + private var modelInfo: JsonField = JsonMissing.of() + private var organization: JsonField = JsonMissing.of() + private var outputCostPerAudioPerSecond: JsonField = JsonMissing.of() + private var outputCostPerAudioToken: JsonField = JsonMissing.of() + private var outputCostPerCharacter: JsonField = JsonMissing.of() + private var outputCostPerCharacterAbove128kTokens: JsonField = JsonMissing.of() + private var outputCostPerImage: JsonField = JsonMissing.of() + private var outputCostPerImageToken: JsonField = JsonMissing.of() + private var outputCostPerPixel: JsonField = JsonMissing.of() + private var outputCostPerReasoningToken: JsonField = JsonMissing.of() + private var outputCostPerSecond: JsonField = JsonMissing.of() + private var outputCostPerToken: JsonField = JsonMissing.of() + private var outputCostPerTokenAbove128kTokens: JsonField = JsonMissing.of() + private var outputCostPerTokenAbove200kTokens: JsonField = JsonMissing.of() + private var outputCostPerTokenBatches: JsonField = JsonMissing.of() + private var outputCostPerTokenFlex: JsonField = JsonMissing.of() + private var outputCostPerTokenPriority: JsonField = JsonMissing.of() + private var outputCostPerVideoPerSecond: JsonField = JsonMissing.of() + private var regionName: JsonField = JsonMissing.of() + private var rpm: JsonField = JsonMissing.of() + private var s3BucketName: JsonField = JsonMissing.of() + private var s3EncryptionKeyId: JsonField = JsonMissing.of() + private var searchContextCostPerQuery: JsonField = + JsonMissing.of() + private var streamTimeout: JsonField = JsonMissing.of() + private var tieredPricing: JsonField>? = null + private var timeout: JsonField = JsonMissing.of() + private var tpm: JsonField = JsonMissing.of() + private var useInPassThrough: JsonField = JsonMissing.of() + private var useLitellmProxy: JsonField = JsonMissing.of() + private var vectorStoreId: JsonField = JsonMissing.of() + private var vertexCredentials: JsonField = JsonMissing.of() + private var vertexLocation: JsonField = JsonMissing.of() + private var vertexProject: JsonField = JsonMissing.of() + private var watsonxRegionName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(litellmParams: LitellmParams) = apply { + model = litellmParams.model + apiBase = litellmParams.apiBase + apiKey = litellmParams.apiKey + apiVersion = litellmParams.apiVersion + autoRouterConfig = litellmParams.autoRouterConfig + autoRouterConfigPath = litellmParams.autoRouterConfigPath + autoRouterDefaultModel = litellmParams.autoRouterDefaultModel + autoRouterEmbeddingModel = litellmParams.autoRouterEmbeddingModel + awsAccessKeyId = litellmParams.awsAccessKeyId + awsBedrockRuntimeEndpoint = litellmParams.awsBedrockRuntimeEndpoint + awsRegionName = litellmParams.awsRegionName + awsSecretAccessKey = litellmParams.awsSecretAccessKey + budgetDuration = litellmParams.budgetDuration + cacheCreationInputAudioTokenCost = litellmParams.cacheCreationInputAudioTokenCost + cacheCreationInputTokenCost = litellmParams.cacheCreationInputTokenCost + cacheCreationInputTokenCostAbove1hr = + litellmParams.cacheCreationInputTokenCostAbove1hr + cacheCreationInputTokenCostAbove200kTokens = + litellmParams.cacheCreationInputTokenCostAbove200kTokens + cacheReadInputAudioTokenCost = litellmParams.cacheReadInputAudioTokenCost + cacheReadInputTokenCost = litellmParams.cacheReadInputTokenCost + cacheReadInputTokenCostAbove200kTokens = + litellmParams.cacheReadInputTokenCostAbove200kTokens + cacheReadInputTokenCostFlex = litellmParams.cacheReadInputTokenCostFlex + cacheReadInputTokenCostPriority = litellmParams.cacheReadInputTokenCostPriority + citationCostPerToken = litellmParams.citationCostPerToken + configurableClientsideAuthParams = + litellmParams.configurableClientsideAuthParams.map { it.toMutableList() } + customLlmProvider = litellmParams.customLlmProvider + gcsBucketName = litellmParams.gcsBucketName + inputCostPerAudioPerSecond = litellmParams.inputCostPerAudioPerSecond + inputCostPerAudioPerSecondAbove128kTokens = + litellmParams.inputCostPerAudioPerSecondAbove128kTokens + inputCostPerAudioToken = litellmParams.inputCostPerAudioToken + inputCostPerCharacter = litellmParams.inputCostPerCharacter + inputCostPerCharacterAbove128kTokens = + litellmParams.inputCostPerCharacterAbove128kTokens + inputCostPerImage = litellmParams.inputCostPerImage + inputCostPerImageAbove128kTokens = litellmParams.inputCostPerImageAbove128kTokens + inputCostPerPixel = litellmParams.inputCostPerPixel + inputCostPerQuery = litellmParams.inputCostPerQuery + inputCostPerSecond = litellmParams.inputCostPerSecond + inputCostPerToken = litellmParams.inputCostPerToken + inputCostPerTokenAbove128kTokens = litellmParams.inputCostPerTokenAbove128kTokens + inputCostPerTokenAbove200kTokens = litellmParams.inputCostPerTokenAbove200kTokens + inputCostPerTokenBatches = litellmParams.inputCostPerTokenBatches + inputCostPerTokenCacheHit = litellmParams.inputCostPerTokenCacheHit + inputCostPerTokenFlex = litellmParams.inputCostPerTokenFlex + inputCostPerTokenPriority = litellmParams.inputCostPerTokenPriority + inputCostPerVideoPerSecond = litellmParams.inputCostPerVideoPerSecond + inputCostPerVideoPerSecondAbove128kTokens = + litellmParams.inputCostPerVideoPerSecondAbove128kTokens + inputCostPerVideoPerSecondAbove15sInterval = + litellmParams.inputCostPerVideoPerSecondAbove15sInterval + inputCostPerVideoPerSecondAbove8sInterval = + litellmParams.inputCostPerVideoPerSecondAbove8sInterval + litellmCredentialName = litellmParams.litellmCredentialName + litellmTraceId = litellmParams.litellmTraceId + maxBudget = litellmParams.maxBudget + maxFileSizeMb = litellmParams.maxFileSizeMb + maxRetries = litellmParams.maxRetries + mergeReasoningContentInChoices = litellmParams.mergeReasoningContentInChoices + milvusTextField = litellmParams.milvusTextField + mockResponse = litellmParams.mockResponse + modelInfo = litellmParams.modelInfo + organization = litellmParams.organization + outputCostPerAudioPerSecond = litellmParams.outputCostPerAudioPerSecond + outputCostPerAudioToken = litellmParams.outputCostPerAudioToken + outputCostPerCharacter = litellmParams.outputCostPerCharacter + outputCostPerCharacterAbove128kTokens = + litellmParams.outputCostPerCharacterAbove128kTokens + outputCostPerImage = litellmParams.outputCostPerImage + outputCostPerImageToken = litellmParams.outputCostPerImageToken + outputCostPerPixel = litellmParams.outputCostPerPixel + outputCostPerReasoningToken = litellmParams.outputCostPerReasoningToken + outputCostPerSecond = litellmParams.outputCostPerSecond + outputCostPerToken = litellmParams.outputCostPerToken + outputCostPerTokenAbove128kTokens = litellmParams.outputCostPerTokenAbove128kTokens + outputCostPerTokenAbove200kTokens = litellmParams.outputCostPerTokenAbove200kTokens + outputCostPerTokenBatches = litellmParams.outputCostPerTokenBatches + outputCostPerTokenFlex = litellmParams.outputCostPerTokenFlex + outputCostPerTokenPriority = litellmParams.outputCostPerTokenPriority + outputCostPerVideoPerSecond = litellmParams.outputCostPerVideoPerSecond + regionName = litellmParams.regionName + rpm = litellmParams.rpm + s3BucketName = litellmParams.s3BucketName + s3EncryptionKeyId = litellmParams.s3EncryptionKeyId + searchContextCostPerQuery = litellmParams.searchContextCostPerQuery + streamTimeout = litellmParams.streamTimeout + tieredPricing = litellmParams.tieredPricing.map { it.toMutableList() } + timeout = litellmParams.timeout + tpm = litellmParams.tpm + useInPassThrough = litellmParams.useInPassThrough + useLitellmProxy = litellmParams.useLitellmProxy + vectorStoreId = litellmParams.vectorStoreId + vertexCredentials = litellmParams.vertexCredentials + vertexLocation = litellmParams.vertexLocation + vertexProject = litellmParams.vertexProject + watsonxRegionName = litellmParams.watsonxRegionName + additionalProperties = litellmParams.additionalProperties.toMutableMap() + } + + fun model(model: String) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + fun apiBase(apiBase: String?) = apiBase(JsonField.ofNullable(apiBase)) + + /** Alias for calling [Builder.apiBase] with `apiBase.orElse(null)`. */ + fun apiBase(apiBase: Optional) = apiBase(apiBase.getOrNull()) + + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } + + fun apiKey(apiKey: String?) = apiKey(JsonField.ofNullable(apiKey)) + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + fun apiVersion(apiVersion: String?) = apiVersion(JsonField.ofNullable(apiVersion)) + + /** Alias for calling [Builder.apiVersion] with `apiVersion.orElse(null)`. */ + fun apiVersion(apiVersion: Optional) = apiVersion(apiVersion.getOrNull()) + + /** + * Sets [Builder.apiVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.apiVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiVersion(apiVersion: JsonField) = apply { this.apiVersion = apiVersion } + + fun autoRouterConfig(autoRouterConfig: String?) = + autoRouterConfig(JsonField.ofNullable(autoRouterConfig)) + + /** + * Alias for calling [Builder.autoRouterConfig] with `autoRouterConfig.orElse(null)`. + */ + fun autoRouterConfig(autoRouterConfig: Optional) = + autoRouterConfig(autoRouterConfig.getOrNull()) + + /** + * Sets [Builder.autoRouterConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRouterConfig] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoRouterConfig(autoRouterConfig: JsonField) = apply { + this.autoRouterConfig = autoRouterConfig + } + + fun autoRouterConfigPath(autoRouterConfigPath: String?) = + autoRouterConfigPath(JsonField.ofNullable(autoRouterConfigPath)) + + /** + * Alias for calling [Builder.autoRouterConfigPath] with + * `autoRouterConfigPath.orElse(null)`. + */ + fun autoRouterConfigPath(autoRouterConfigPath: Optional) = + autoRouterConfigPath(autoRouterConfigPath.getOrNull()) + + /** + * Sets [Builder.autoRouterConfigPath] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRouterConfigPath] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun autoRouterConfigPath(autoRouterConfigPath: JsonField) = apply { + this.autoRouterConfigPath = autoRouterConfigPath + } + + fun autoRouterDefaultModel(autoRouterDefaultModel: String?) = + autoRouterDefaultModel(JsonField.ofNullable(autoRouterDefaultModel)) + + /** + * Alias for calling [Builder.autoRouterDefaultModel] with + * `autoRouterDefaultModel.orElse(null)`. + */ + fun autoRouterDefaultModel(autoRouterDefaultModel: Optional) = + autoRouterDefaultModel(autoRouterDefaultModel.getOrNull()) + + /** + * Sets [Builder.autoRouterDefaultModel] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRouterDefaultModel] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun autoRouterDefaultModel(autoRouterDefaultModel: JsonField) = apply { + this.autoRouterDefaultModel = autoRouterDefaultModel + } + + fun autoRouterEmbeddingModel(autoRouterEmbeddingModel: String?) = + autoRouterEmbeddingModel(JsonField.ofNullable(autoRouterEmbeddingModel)) + + /** + * Alias for calling [Builder.autoRouterEmbeddingModel] with + * `autoRouterEmbeddingModel.orElse(null)`. + */ + fun autoRouterEmbeddingModel(autoRouterEmbeddingModel: Optional) = + autoRouterEmbeddingModel(autoRouterEmbeddingModel.getOrNull()) + + /** + * Sets [Builder.autoRouterEmbeddingModel] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRouterEmbeddingModel] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun autoRouterEmbeddingModel(autoRouterEmbeddingModel: JsonField) = apply { + this.autoRouterEmbeddingModel = autoRouterEmbeddingModel + } + + fun awsAccessKeyId(awsAccessKeyId: String?) = + awsAccessKeyId(JsonField.ofNullable(awsAccessKeyId)) + + /** Alias for calling [Builder.awsAccessKeyId] with `awsAccessKeyId.orElse(null)`. */ + fun awsAccessKeyId(awsAccessKeyId: Optional) = + awsAccessKeyId(awsAccessKeyId.getOrNull()) + + /** + * Sets [Builder.awsAccessKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.awsAccessKeyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun awsAccessKeyId(awsAccessKeyId: JsonField) = apply { + this.awsAccessKeyId = awsAccessKeyId + } + + fun awsBedrockRuntimeEndpoint(awsBedrockRuntimeEndpoint: String?) = + awsBedrockRuntimeEndpoint(JsonField.ofNullable(awsBedrockRuntimeEndpoint)) + + /** + * Alias for calling [Builder.awsBedrockRuntimeEndpoint] with + * `awsBedrockRuntimeEndpoint.orElse(null)`. + */ + fun awsBedrockRuntimeEndpoint(awsBedrockRuntimeEndpoint: Optional) = + awsBedrockRuntimeEndpoint(awsBedrockRuntimeEndpoint.getOrNull()) + + /** + * Sets [Builder.awsBedrockRuntimeEndpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.awsBedrockRuntimeEndpoint] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun awsBedrockRuntimeEndpoint(awsBedrockRuntimeEndpoint: JsonField) = apply { + this.awsBedrockRuntimeEndpoint = awsBedrockRuntimeEndpoint + } + + fun awsRegionName(awsRegionName: String?) = + awsRegionName(JsonField.ofNullable(awsRegionName)) + + /** Alias for calling [Builder.awsRegionName] with `awsRegionName.orElse(null)`. */ + fun awsRegionName(awsRegionName: Optional) = + awsRegionName(awsRegionName.getOrNull()) + + /** + * Sets [Builder.awsRegionName] to an arbitrary JSON value. + * + * You should usually call [Builder.awsRegionName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun awsRegionName(awsRegionName: JsonField) = apply { + this.awsRegionName = awsRegionName + } + + fun awsSecretAccessKey(awsSecretAccessKey: String?) = + awsSecretAccessKey(JsonField.ofNullable(awsSecretAccessKey)) + + /** + * Alias for calling [Builder.awsSecretAccessKey] with + * `awsSecretAccessKey.orElse(null)`. + */ + fun awsSecretAccessKey(awsSecretAccessKey: Optional) = + awsSecretAccessKey(awsSecretAccessKey.getOrNull()) + + /** + * Sets [Builder.awsSecretAccessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.awsSecretAccessKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun awsSecretAccessKey(awsSecretAccessKey: JsonField) = apply { + this.awsSecretAccessKey = awsSecretAccessKey + } + + fun budgetDuration(budgetDuration: String?) = + budgetDuration(JsonField.ofNullable(budgetDuration)) + + /** Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. */ + fun budgetDuration(budgetDuration: Optional) = + budgetDuration(budgetDuration.getOrNull()) + + /** + * Sets [Builder.budgetDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.budgetDuration] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun budgetDuration(budgetDuration: JsonField) = apply { + this.budgetDuration = budgetDuration + } + + fun cacheCreationInputAudioTokenCost(cacheCreationInputAudioTokenCost: Double?) = + cacheCreationInputAudioTokenCost( + JsonField.ofNullable(cacheCreationInputAudioTokenCost) + ) + + /** + * Alias for [Builder.cacheCreationInputAudioTokenCost]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheCreationInputAudioTokenCost(cacheCreationInputAudioTokenCost: Double) = + cacheCreationInputAudioTokenCost(cacheCreationInputAudioTokenCost as Double?) + + /** + * Alias for calling [Builder.cacheCreationInputAudioTokenCost] with + * `cacheCreationInputAudioTokenCost.orElse(null)`. + */ + fun cacheCreationInputAudioTokenCost( + cacheCreationInputAudioTokenCost: Optional + ) = cacheCreationInputAudioTokenCost(cacheCreationInputAudioTokenCost.getOrNull()) + + /** + * Sets [Builder.cacheCreationInputAudioTokenCost] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheCreationInputAudioTokenCost] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cacheCreationInputAudioTokenCost( + cacheCreationInputAudioTokenCost: JsonField + ) = apply { this.cacheCreationInputAudioTokenCost = cacheCreationInputAudioTokenCost } + + fun cacheCreationInputTokenCost(cacheCreationInputTokenCost: Double?) = + cacheCreationInputTokenCost(JsonField.ofNullable(cacheCreationInputTokenCost)) + + /** + * Alias for [Builder.cacheCreationInputTokenCost]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheCreationInputTokenCost(cacheCreationInputTokenCost: Double) = + cacheCreationInputTokenCost(cacheCreationInputTokenCost as Double?) + + /** + * Alias for calling [Builder.cacheCreationInputTokenCost] with + * `cacheCreationInputTokenCost.orElse(null)`. + */ + fun cacheCreationInputTokenCost(cacheCreationInputTokenCost: Optional) = + cacheCreationInputTokenCost(cacheCreationInputTokenCost.getOrNull()) + + /** + * Sets [Builder.cacheCreationInputTokenCost] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheCreationInputTokenCost] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cacheCreationInputTokenCost(cacheCreationInputTokenCost: JsonField) = + apply { + this.cacheCreationInputTokenCost = cacheCreationInputTokenCost + } + + fun cacheCreationInputTokenCostAbove1hr(cacheCreationInputTokenCostAbove1hr: Double?) = + cacheCreationInputTokenCostAbove1hr( + JsonField.ofNullable(cacheCreationInputTokenCostAbove1hr) + ) + + /** + * Alias for [Builder.cacheCreationInputTokenCostAbove1hr]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheCreationInputTokenCostAbove1hr(cacheCreationInputTokenCostAbove1hr: Double) = + cacheCreationInputTokenCostAbove1hr(cacheCreationInputTokenCostAbove1hr as Double?) + + /** + * Alias for calling [Builder.cacheCreationInputTokenCostAbove1hr] with + * `cacheCreationInputTokenCostAbove1hr.orElse(null)`. + */ + fun cacheCreationInputTokenCostAbove1hr( + cacheCreationInputTokenCostAbove1hr: Optional + ) = cacheCreationInputTokenCostAbove1hr(cacheCreationInputTokenCostAbove1hr.getOrNull()) + + /** + * Sets [Builder.cacheCreationInputTokenCostAbove1hr] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheCreationInputTokenCostAbove1hr] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cacheCreationInputTokenCostAbove1hr( + cacheCreationInputTokenCostAbove1hr: JsonField + ) = apply { + this.cacheCreationInputTokenCostAbove1hr = cacheCreationInputTokenCostAbove1hr + } + + fun cacheCreationInputTokenCostAbove200kTokens( + cacheCreationInputTokenCostAbove200kTokens: Double? + ) = + cacheCreationInputTokenCostAbove200kTokens( + JsonField.ofNullable(cacheCreationInputTokenCostAbove200kTokens) + ) + + /** + * Alias for [Builder.cacheCreationInputTokenCostAbove200kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheCreationInputTokenCostAbove200kTokens( + cacheCreationInputTokenCostAbove200kTokens: Double + ) = + cacheCreationInputTokenCostAbove200kTokens( + cacheCreationInputTokenCostAbove200kTokens as Double? + ) + + /** + * Alias for calling [Builder.cacheCreationInputTokenCostAbove200kTokens] with + * `cacheCreationInputTokenCostAbove200kTokens.orElse(null)`. + */ + fun cacheCreationInputTokenCostAbove200kTokens( + cacheCreationInputTokenCostAbove200kTokens: Optional + ) = + cacheCreationInputTokenCostAbove200kTokens( + cacheCreationInputTokenCostAbove200kTokens.getOrNull() + ) + + /** + * Sets [Builder.cacheCreationInputTokenCostAbove200kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheCreationInputTokenCostAbove200kTokens] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cacheCreationInputTokenCostAbove200kTokens( + cacheCreationInputTokenCostAbove200kTokens: JsonField + ) = apply { + this.cacheCreationInputTokenCostAbove200kTokens = + cacheCreationInputTokenCostAbove200kTokens + } + + fun cacheReadInputAudioTokenCost(cacheReadInputAudioTokenCost: Double?) = + cacheReadInputAudioTokenCost(JsonField.ofNullable(cacheReadInputAudioTokenCost)) + + /** + * Alias for [Builder.cacheReadInputAudioTokenCost]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheReadInputAudioTokenCost(cacheReadInputAudioTokenCost: Double) = + cacheReadInputAudioTokenCost(cacheReadInputAudioTokenCost as Double?) + + /** + * Alias for calling [Builder.cacheReadInputAudioTokenCost] with + * `cacheReadInputAudioTokenCost.orElse(null)`. + */ + fun cacheReadInputAudioTokenCost(cacheReadInputAudioTokenCost: Optional) = + cacheReadInputAudioTokenCost(cacheReadInputAudioTokenCost.getOrNull()) + + /** + * Sets [Builder.cacheReadInputAudioTokenCost] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheReadInputAudioTokenCost] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cacheReadInputAudioTokenCost(cacheReadInputAudioTokenCost: JsonField) = + apply { + this.cacheReadInputAudioTokenCost = cacheReadInputAudioTokenCost + } + + fun cacheReadInputTokenCost(cacheReadInputTokenCost: Double?) = + cacheReadInputTokenCost(JsonField.ofNullable(cacheReadInputTokenCost)) + + /** + * Alias for [Builder.cacheReadInputTokenCost]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheReadInputTokenCost(cacheReadInputTokenCost: Double) = + cacheReadInputTokenCost(cacheReadInputTokenCost as Double?) + + /** + * Alias for calling [Builder.cacheReadInputTokenCost] with + * `cacheReadInputTokenCost.orElse(null)`. + */ + fun cacheReadInputTokenCost(cacheReadInputTokenCost: Optional) = + cacheReadInputTokenCost(cacheReadInputTokenCost.getOrNull()) + + /** + * Sets [Builder.cacheReadInputTokenCost] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheReadInputTokenCost] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cacheReadInputTokenCost(cacheReadInputTokenCost: JsonField) = apply { + this.cacheReadInputTokenCost = cacheReadInputTokenCost + } + + fun cacheReadInputTokenCostAbove200kTokens( + cacheReadInputTokenCostAbove200kTokens: Double? + ) = + cacheReadInputTokenCostAbove200kTokens( + JsonField.ofNullable(cacheReadInputTokenCostAbove200kTokens) + ) + + /** + * Alias for [Builder.cacheReadInputTokenCostAbove200kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheReadInputTokenCostAbove200kTokens( + cacheReadInputTokenCostAbove200kTokens: Double + ) = + cacheReadInputTokenCostAbove200kTokens( + cacheReadInputTokenCostAbove200kTokens as Double? + ) + + /** + * Alias for calling [Builder.cacheReadInputTokenCostAbove200kTokens] with + * `cacheReadInputTokenCostAbove200kTokens.orElse(null)`. + */ + fun cacheReadInputTokenCostAbove200kTokens( + cacheReadInputTokenCostAbove200kTokens: Optional + ) = + cacheReadInputTokenCostAbove200kTokens( + cacheReadInputTokenCostAbove200kTokens.getOrNull() + ) + + /** + * Sets [Builder.cacheReadInputTokenCostAbove200kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheReadInputTokenCostAbove200kTokens] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cacheReadInputTokenCostAbove200kTokens( + cacheReadInputTokenCostAbove200kTokens: JsonField + ) = apply { + this.cacheReadInputTokenCostAbove200kTokens = cacheReadInputTokenCostAbove200kTokens + } + + fun cacheReadInputTokenCostFlex(cacheReadInputTokenCostFlex: Double?) = + cacheReadInputTokenCostFlex(JsonField.ofNullable(cacheReadInputTokenCostFlex)) + + /** + * Alias for [Builder.cacheReadInputTokenCostFlex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheReadInputTokenCostFlex(cacheReadInputTokenCostFlex: Double) = + cacheReadInputTokenCostFlex(cacheReadInputTokenCostFlex as Double?) + + /** + * Alias for calling [Builder.cacheReadInputTokenCostFlex] with + * `cacheReadInputTokenCostFlex.orElse(null)`. + */ + fun cacheReadInputTokenCostFlex(cacheReadInputTokenCostFlex: Optional) = + cacheReadInputTokenCostFlex(cacheReadInputTokenCostFlex.getOrNull()) + + /** + * Sets [Builder.cacheReadInputTokenCostFlex] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheReadInputTokenCostFlex] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cacheReadInputTokenCostFlex(cacheReadInputTokenCostFlex: JsonField) = + apply { + this.cacheReadInputTokenCostFlex = cacheReadInputTokenCostFlex + } + + fun cacheReadInputTokenCostPriority(cacheReadInputTokenCostPriority: Double?) = + cacheReadInputTokenCostPriority( + JsonField.ofNullable(cacheReadInputTokenCostPriority) + ) + + /** + * Alias for [Builder.cacheReadInputTokenCostPriority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun cacheReadInputTokenCostPriority(cacheReadInputTokenCostPriority: Double) = + cacheReadInputTokenCostPriority(cacheReadInputTokenCostPriority as Double?) + + /** + * Alias for calling [Builder.cacheReadInputTokenCostPriority] with + * `cacheReadInputTokenCostPriority.orElse(null)`. + */ + fun cacheReadInputTokenCostPriority(cacheReadInputTokenCostPriority: Optional) = + cacheReadInputTokenCostPriority(cacheReadInputTokenCostPriority.getOrNull()) + + /** + * Sets [Builder.cacheReadInputTokenCostPriority] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheReadInputTokenCostPriority] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cacheReadInputTokenCostPriority( + cacheReadInputTokenCostPriority: JsonField + ) = apply { this.cacheReadInputTokenCostPriority = cacheReadInputTokenCostPriority } + + fun citationCostPerToken(citationCostPerToken: Double?) = + citationCostPerToken(JsonField.ofNullable(citationCostPerToken)) + + /** + * Alias for [Builder.citationCostPerToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun citationCostPerToken(citationCostPerToken: Double) = + citationCostPerToken(citationCostPerToken as Double?) + + /** + * Alias for calling [Builder.citationCostPerToken] with + * `citationCostPerToken.orElse(null)`. + */ + fun citationCostPerToken(citationCostPerToken: Optional) = + citationCostPerToken(citationCostPerToken.getOrNull()) + + /** + * Sets [Builder.citationCostPerToken] to an arbitrary JSON value. + * + * You should usually call [Builder.citationCostPerToken] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun citationCostPerToken(citationCostPerToken: JsonField) = apply { + this.citationCostPerToken = citationCostPerToken + } + + fun configurableClientsideAuthParams( + configurableClientsideAuthParams: List? + ) = + configurableClientsideAuthParams( + JsonField.ofNullable(configurableClientsideAuthParams) + ) + + /** + * Alias for calling [Builder.configurableClientsideAuthParams] with + * `configurableClientsideAuthParams.orElse(null)`. + */ + fun configurableClientsideAuthParams( + configurableClientsideAuthParams: Optional> + ) = configurableClientsideAuthParams(configurableClientsideAuthParams.getOrNull()) + + /** + * Sets [Builder.configurableClientsideAuthParams] to an arbitrary JSON value. + * + * You should usually call [Builder.configurableClientsideAuthParams] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun configurableClientsideAuthParams( + configurableClientsideAuthParams: JsonField> + ) = apply { + this.configurableClientsideAuthParams = + configurableClientsideAuthParams.map { it.toMutableList() } + } + + /** + * Adds a single [ConfigurableClientsideAuthParam] to + * [configurableClientsideAuthParams]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConfigurableClientsideAuthParam( + configurableClientsideAuthParam: ConfigurableClientsideAuthParam + ) = apply { + configurableClientsideAuthParams = + (configurableClientsideAuthParams ?: JsonField.of(mutableListOf())).also { + checkKnown("configurableClientsideAuthParams", it) + .add(configurableClientsideAuthParam) + } + } + + /** + * Alias for calling [addConfigurableClientsideAuthParam] with + * `ConfigurableClientsideAuthParam.ofString(string)`. + */ + fun addConfigurableClientsideAuthParam(string: String) = + addConfigurableClientsideAuthParam(ConfigurableClientsideAuthParam.ofString(string)) + + /** + * Alias for calling [addConfigurableClientsideAuthParam] with + * `ConfigurableClientsideAuthParam.ofParamsCustomAuthInput(paramsCustomAuthInput)`. + */ + fun addConfigurableClientsideAuthParam( + paramsCustomAuthInput: + ConfigurableClientsideAuthParam.ConfigurableClientsideParamsCustomAuthInput + ) = + addConfigurableClientsideAuthParam( + ConfigurableClientsideAuthParam.ofParamsCustomAuthInput(paramsCustomAuthInput) + ) + + fun customLlmProvider(customLlmProvider: String?) = + customLlmProvider(JsonField.ofNullable(customLlmProvider)) + + /** + * Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. + */ + fun customLlmProvider(customLlmProvider: Optional) = + customLlmProvider(customLlmProvider.getOrNull()) + + /** + * Sets [Builder.customLlmProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.customLlmProvider] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customLlmProvider(customLlmProvider: JsonField) = apply { + this.customLlmProvider = customLlmProvider + } + + fun gcsBucketName(gcsBucketName: String?) = + gcsBucketName(JsonField.ofNullable(gcsBucketName)) + + /** Alias for calling [Builder.gcsBucketName] with `gcsBucketName.orElse(null)`. */ + fun gcsBucketName(gcsBucketName: Optional) = + gcsBucketName(gcsBucketName.getOrNull()) + + /** + * Sets [Builder.gcsBucketName] to an arbitrary JSON value. + * + * You should usually call [Builder.gcsBucketName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gcsBucketName(gcsBucketName: JsonField) = apply { + this.gcsBucketName = gcsBucketName + } + + fun inputCostPerAudioPerSecond(inputCostPerAudioPerSecond: Double?) = + inputCostPerAudioPerSecond(JsonField.ofNullable(inputCostPerAudioPerSecond)) + + /** + * Alias for [Builder.inputCostPerAudioPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerAudioPerSecond(inputCostPerAudioPerSecond: Double) = + inputCostPerAudioPerSecond(inputCostPerAudioPerSecond as Double?) + + /** + * Alias for calling [Builder.inputCostPerAudioPerSecond] with + * `inputCostPerAudioPerSecond.orElse(null)`. + */ + fun inputCostPerAudioPerSecond(inputCostPerAudioPerSecond: Optional) = + inputCostPerAudioPerSecond(inputCostPerAudioPerSecond.getOrNull()) + + /** + * Sets [Builder.inputCostPerAudioPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerAudioPerSecond] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerAudioPerSecond(inputCostPerAudioPerSecond: JsonField) = apply { + this.inputCostPerAudioPerSecond = inputCostPerAudioPerSecond + } + + fun inputCostPerAudioPerSecondAbove128kTokens( + inputCostPerAudioPerSecondAbove128kTokens: Double? + ) = + inputCostPerAudioPerSecondAbove128kTokens( + JsonField.ofNullable(inputCostPerAudioPerSecondAbove128kTokens) + ) + + /** + * Alias for [Builder.inputCostPerAudioPerSecondAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerAudioPerSecondAbove128kTokens( + inputCostPerAudioPerSecondAbove128kTokens: Double + ) = + inputCostPerAudioPerSecondAbove128kTokens( + inputCostPerAudioPerSecondAbove128kTokens as Double? + ) + + /** + * Alias for calling [Builder.inputCostPerAudioPerSecondAbove128kTokens] with + * `inputCostPerAudioPerSecondAbove128kTokens.orElse(null)`. + */ + fun inputCostPerAudioPerSecondAbove128kTokens( + inputCostPerAudioPerSecondAbove128kTokens: Optional + ) = + inputCostPerAudioPerSecondAbove128kTokens( + inputCostPerAudioPerSecondAbove128kTokens.getOrNull() + ) + + /** + * Sets [Builder.inputCostPerAudioPerSecondAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerAudioPerSecondAbove128kTokens] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputCostPerAudioPerSecondAbove128kTokens( + inputCostPerAudioPerSecondAbove128kTokens: JsonField + ) = apply { + this.inputCostPerAudioPerSecondAbove128kTokens = + inputCostPerAudioPerSecondAbove128kTokens + } + + fun inputCostPerAudioToken(inputCostPerAudioToken: Double?) = + inputCostPerAudioToken(JsonField.ofNullable(inputCostPerAudioToken)) + + /** + * Alias for [Builder.inputCostPerAudioToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerAudioToken(inputCostPerAudioToken: Double) = + inputCostPerAudioToken(inputCostPerAudioToken as Double?) + + /** + * Alias for calling [Builder.inputCostPerAudioToken] with + * `inputCostPerAudioToken.orElse(null)`. + */ + fun inputCostPerAudioToken(inputCostPerAudioToken: Optional) = + inputCostPerAudioToken(inputCostPerAudioToken.getOrNull()) + + /** + * Sets [Builder.inputCostPerAudioToken] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerAudioToken] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inputCostPerAudioToken(inputCostPerAudioToken: JsonField) = apply { + this.inputCostPerAudioToken = inputCostPerAudioToken + } + + fun inputCostPerCharacter(inputCostPerCharacter: Double?) = + inputCostPerCharacter(JsonField.ofNullable(inputCostPerCharacter)) + + /** + * Alias for [Builder.inputCostPerCharacter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerCharacter(inputCostPerCharacter: Double) = + inputCostPerCharacter(inputCostPerCharacter as Double?) + + /** + * Alias for calling [Builder.inputCostPerCharacter] with + * `inputCostPerCharacter.orElse(null)`. + */ + fun inputCostPerCharacter(inputCostPerCharacter: Optional) = + inputCostPerCharacter(inputCostPerCharacter.getOrNull()) + + /** + * Sets [Builder.inputCostPerCharacter] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerCharacter] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inputCostPerCharacter(inputCostPerCharacter: JsonField) = apply { + this.inputCostPerCharacter = inputCostPerCharacter + } + + fun inputCostPerCharacterAbove128kTokens( + inputCostPerCharacterAbove128kTokens: Double? + ) = + inputCostPerCharacterAbove128kTokens( + JsonField.ofNullable(inputCostPerCharacterAbove128kTokens) + ) + + /** + * Alias for [Builder.inputCostPerCharacterAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerCharacterAbove128kTokens(inputCostPerCharacterAbove128kTokens: Double) = + inputCostPerCharacterAbove128kTokens( + inputCostPerCharacterAbove128kTokens as Double? + ) + + /** + * Alias for calling [Builder.inputCostPerCharacterAbove128kTokens] with + * `inputCostPerCharacterAbove128kTokens.orElse(null)`. + */ + fun inputCostPerCharacterAbove128kTokens( + inputCostPerCharacterAbove128kTokens: Optional + ) = + inputCostPerCharacterAbove128kTokens( + inputCostPerCharacterAbove128kTokens.getOrNull() + ) + + /** + * Sets [Builder.inputCostPerCharacterAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerCharacterAbove128kTokens] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputCostPerCharacterAbove128kTokens( + inputCostPerCharacterAbove128kTokens: JsonField + ) = apply { + this.inputCostPerCharacterAbove128kTokens = inputCostPerCharacterAbove128kTokens + } + + fun inputCostPerImage(inputCostPerImage: Double?) = + inputCostPerImage(JsonField.ofNullable(inputCostPerImage)) + + /** + * Alias for [Builder.inputCostPerImage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerImage(inputCostPerImage: Double) = + inputCostPerImage(inputCostPerImage as Double?) + + /** + * Alias for calling [Builder.inputCostPerImage] with `inputCostPerImage.orElse(null)`. + */ + fun inputCostPerImage(inputCostPerImage: Optional) = + inputCostPerImage(inputCostPerImage.getOrNull()) + + /** + * Sets [Builder.inputCostPerImage] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerImage] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputCostPerImage(inputCostPerImage: JsonField) = apply { + this.inputCostPerImage = inputCostPerImage + } + + fun inputCostPerImageAbove128kTokens(inputCostPerImageAbove128kTokens: Double?) = + inputCostPerImageAbove128kTokens( + JsonField.ofNullable(inputCostPerImageAbove128kTokens) + ) + + /** + * Alias for [Builder.inputCostPerImageAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerImageAbove128kTokens(inputCostPerImageAbove128kTokens: Double) = + inputCostPerImageAbove128kTokens(inputCostPerImageAbove128kTokens as Double?) + + /** + * Alias for calling [Builder.inputCostPerImageAbove128kTokens] with + * `inputCostPerImageAbove128kTokens.orElse(null)`. + */ + fun inputCostPerImageAbove128kTokens( + inputCostPerImageAbove128kTokens: Optional + ) = inputCostPerImageAbove128kTokens(inputCostPerImageAbove128kTokens.getOrNull()) + + /** + * Sets [Builder.inputCostPerImageAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerImageAbove128kTokens] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerImageAbove128kTokens( + inputCostPerImageAbove128kTokens: JsonField + ) = apply { this.inputCostPerImageAbove128kTokens = inputCostPerImageAbove128kTokens } + + fun inputCostPerPixel(inputCostPerPixel: Double?) = + inputCostPerPixel(JsonField.ofNullable(inputCostPerPixel)) + + /** + * Alias for [Builder.inputCostPerPixel]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerPixel(inputCostPerPixel: Double) = + inputCostPerPixel(inputCostPerPixel as Double?) + + /** + * Alias for calling [Builder.inputCostPerPixel] with `inputCostPerPixel.orElse(null)`. + */ + fun inputCostPerPixel(inputCostPerPixel: Optional) = + inputCostPerPixel(inputCostPerPixel.getOrNull()) + + /** + * Sets [Builder.inputCostPerPixel] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerPixel] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputCostPerPixel(inputCostPerPixel: JsonField) = apply { + this.inputCostPerPixel = inputCostPerPixel + } + + fun inputCostPerQuery(inputCostPerQuery: Double?) = + inputCostPerQuery(JsonField.ofNullable(inputCostPerQuery)) + + /** + * Alias for [Builder.inputCostPerQuery]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerQuery(inputCostPerQuery: Double) = + inputCostPerQuery(inputCostPerQuery as Double?) + + /** + * Alias for calling [Builder.inputCostPerQuery] with `inputCostPerQuery.orElse(null)`. + */ + fun inputCostPerQuery(inputCostPerQuery: Optional) = + inputCostPerQuery(inputCostPerQuery.getOrNull()) + + /** + * Sets [Builder.inputCostPerQuery] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerQuery] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputCostPerQuery(inputCostPerQuery: JsonField) = apply { + this.inputCostPerQuery = inputCostPerQuery + } + + fun inputCostPerSecond(inputCostPerSecond: Double?) = + inputCostPerSecond(JsonField.ofNullable(inputCostPerSecond)) + + /** + * Alias for [Builder.inputCostPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerSecond(inputCostPerSecond: Double) = + inputCostPerSecond(inputCostPerSecond as Double?) + + /** + * Alias for calling [Builder.inputCostPerSecond] with + * `inputCostPerSecond.orElse(null)`. + */ + fun inputCostPerSecond(inputCostPerSecond: Optional) = + inputCostPerSecond(inputCostPerSecond.getOrNull()) + + /** + * Sets [Builder.inputCostPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerSecond] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputCostPerSecond(inputCostPerSecond: JsonField) = apply { + this.inputCostPerSecond = inputCostPerSecond + } + + fun inputCostPerToken(inputCostPerToken: Double?) = + inputCostPerToken(JsonField.ofNullable(inputCostPerToken)) + + /** + * Alias for [Builder.inputCostPerToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerToken(inputCostPerToken: Double) = + inputCostPerToken(inputCostPerToken as Double?) + + /** + * Alias for calling [Builder.inputCostPerToken] with `inputCostPerToken.orElse(null)`. + */ + fun inputCostPerToken(inputCostPerToken: Optional) = + inputCostPerToken(inputCostPerToken.getOrNull()) + + /** + * Sets [Builder.inputCostPerToken] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerToken] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputCostPerToken(inputCostPerToken: JsonField) = apply { + this.inputCostPerToken = inputCostPerToken + } + + fun inputCostPerTokenAbove128kTokens(inputCostPerTokenAbove128kTokens: Double?) = + inputCostPerTokenAbove128kTokens( + JsonField.ofNullable(inputCostPerTokenAbove128kTokens) + ) + + /** + * Alias for [Builder.inputCostPerTokenAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerTokenAbove128kTokens(inputCostPerTokenAbove128kTokens: Double) = + inputCostPerTokenAbove128kTokens(inputCostPerTokenAbove128kTokens as Double?) + + /** + * Alias for calling [Builder.inputCostPerTokenAbove128kTokens] with + * `inputCostPerTokenAbove128kTokens.orElse(null)`. + */ + fun inputCostPerTokenAbove128kTokens( + inputCostPerTokenAbove128kTokens: Optional + ) = inputCostPerTokenAbove128kTokens(inputCostPerTokenAbove128kTokens.getOrNull()) + + /** + * Sets [Builder.inputCostPerTokenAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerTokenAbove128kTokens] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerTokenAbove128kTokens( + inputCostPerTokenAbove128kTokens: JsonField + ) = apply { this.inputCostPerTokenAbove128kTokens = inputCostPerTokenAbove128kTokens } + + fun inputCostPerTokenAbove200kTokens(inputCostPerTokenAbove200kTokens: Double?) = + inputCostPerTokenAbove200kTokens( + JsonField.ofNullable(inputCostPerTokenAbove200kTokens) + ) + + /** + * Alias for [Builder.inputCostPerTokenAbove200kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerTokenAbove200kTokens(inputCostPerTokenAbove200kTokens: Double) = + inputCostPerTokenAbove200kTokens(inputCostPerTokenAbove200kTokens as Double?) + + /** + * Alias for calling [Builder.inputCostPerTokenAbove200kTokens] with + * `inputCostPerTokenAbove200kTokens.orElse(null)`. + */ + fun inputCostPerTokenAbove200kTokens( + inputCostPerTokenAbove200kTokens: Optional + ) = inputCostPerTokenAbove200kTokens(inputCostPerTokenAbove200kTokens.getOrNull()) + + /** + * Sets [Builder.inputCostPerTokenAbove200kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerTokenAbove200kTokens] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerTokenAbove200kTokens( + inputCostPerTokenAbove200kTokens: JsonField + ) = apply { this.inputCostPerTokenAbove200kTokens = inputCostPerTokenAbove200kTokens } + + fun inputCostPerTokenBatches(inputCostPerTokenBatches: Double?) = + inputCostPerTokenBatches(JsonField.ofNullable(inputCostPerTokenBatches)) + + /** + * Alias for [Builder.inputCostPerTokenBatches]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerTokenBatches(inputCostPerTokenBatches: Double) = + inputCostPerTokenBatches(inputCostPerTokenBatches as Double?) + + /** + * Alias for calling [Builder.inputCostPerTokenBatches] with + * `inputCostPerTokenBatches.orElse(null)`. + */ + fun inputCostPerTokenBatches(inputCostPerTokenBatches: Optional) = + inputCostPerTokenBatches(inputCostPerTokenBatches.getOrNull()) + + /** + * Sets [Builder.inputCostPerTokenBatches] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerTokenBatches] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inputCostPerTokenBatches(inputCostPerTokenBatches: JsonField) = apply { + this.inputCostPerTokenBatches = inputCostPerTokenBatches + } + + fun inputCostPerTokenCacheHit(inputCostPerTokenCacheHit: Double?) = + inputCostPerTokenCacheHit(JsonField.ofNullable(inputCostPerTokenCacheHit)) + + /** + * Alias for [Builder.inputCostPerTokenCacheHit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerTokenCacheHit(inputCostPerTokenCacheHit: Double) = + inputCostPerTokenCacheHit(inputCostPerTokenCacheHit as Double?) + + /** + * Alias for calling [Builder.inputCostPerTokenCacheHit] with + * `inputCostPerTokenCacheHit.orElse(null)`. + */ + fun inputCostPerTokenCacheHit(inputCostPerTokenCacheHit: Optional) = + inputCostPerTokenCacheHit(inputCostPerTokenCacheHit.getOrNull()) + + /** + * Sets [Builder.inputCostPerTokenCacheHit] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerTokenCacheHit] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerTokenCacheHit(inputCostPerTokenCacheHit: JsonField) = apply { + this.inputCostPerTokenCacheHit = inputCostPerTokenCacheHit + } + + fun inputCostPerTokenFlex(inputCostPerTokenFlex: Double?) = + inputCostPerTokenFlex(JsonField.ofNullable(inputCostPerTokenFlex)) + + /** + * Alias for [Builder.inputCostPerTokenFlex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerTokenFlex(inputCostPerTokenFlex: Double) = + inputCostPerTokenFlex(inputCostPerTokenFlex as Double?) + + /** + * Alias for calling [Builder.inputCostPerTokenFlex] with + * `inputCostPerTokenFlex.orElse(null)`. + */ + fun inputCostPerTokenFlex(inputCostPerTokenFlex: Optional) = + inputCostPerTokenFlex(inputCostPerTokenFlex.getOrNull()) + + /** + * Sets [Builder.inputCostPerTokenFlex] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerTokenFlex] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inputCostPerTokenFlex(inputCostPerTokenFlex: JsonField) = apply { + this.inputCostPerTokenFlex = inputCostPerTokenFlex + } + + fun inputCostPerTokenPriority(inputCostPerTokenPriority: Double?) = + inputCostPerTokenPriority(JsonField.ofNullable(inputCostPerTokenPriority)) + + /** + * Alias for [Builder.inputCostPerTokenPriority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerTokenPriority(inputCostPerTokenPriority: Double) = + inputCostPerTokenPriority(inputCostPerTokenPriority as Double?) + + /** + * Alias for calling [Builder.inputCostPerTokenPriority] with + * `inputCostPerTokenPriority.orElse(null)`. + */ + fun inputCostPerTokenPriority(inputCostPerTokenPriority: Optional) = + inputCostPerTokenPriority(inputCostPerTokenPriority.getOrNull()) + + /** + * Sets [Builder.inputCostPerTokenPriority] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerTokenPriority] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerTokenPriority(inputCostPerTokenPriority: JsonField) = apply { + this.inputCostPerTokenPriority = inputCostPerTokenPriority + } + + fun inputCostPerVideoPerSecond(inputCostPerVideoPerSecond: Double?) = + inputCostPerVideoPerSecond(JsonField.ofNullable(inputCostPerVideoPerSecond)) + + /** + * Alias for [Builder.inputCostPerVideoPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerVideoPerSecond(inputCostPerVideoPerSecond: Double) = + inputCostPerVideoPerSecond(inputCostPerVideoPerSecond as Double?) + + /** + * Alias for calling [Builder.inputCostPerVideoPerSecond] with + * `inputCostPerVideoPerSecond.orElse(null)`. + */ + fun inputCostPerVideoPerSecond(inputCostPerVideoPerSecond: Optional) = + inputCostPerVideoPerSecond(inputCostPerVideoPerSecond.getOrNull()) + + /** + * Sets [Builder.inputCostPerVideoPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerVideoPerSecond] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inputCostPerVideoPerSecond(inputCostPerVideoPerSecond: JsonField) = apply { + this.inputCostPerVideoPerSecond = inputCostPerVideoPerSecond + } + + fun inputCostPerVideoPerSecondAbove128kTokens( + inputCostPerVideoPerSecondAbove128kTokens: Double? + ) = + inputCostPerVideoPerSecondAbove128kTokens( + JsonField.ofNullable(inputCostPerVideoPerSecondAbove128kTokens) + ) + + /** + * Alias for [Builder.inputCostPerVideoPerSecondAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerVideoPerSecondAbove128kTokens( + inputCostPerVideoPerSecondAbove128kTokens: Double + ) = + inputCostPerVideoPerSecondAbove128kTokens( + inputCostPerVideoPerSecondAbove128kTokens as Double? + ) + + /** + * Alias for calling [Builder.inputCostPerVideoPerSecondAbove128kTokens] with + * `inputCostPerVideoPerSecondAbove128kTokens.orElse(null)`. + */ + fun inputCostPerVideoPerSecondAbove128kTokens( + inputCostPerVideoPerSecondAbove128kTokens: Optional + ) = + inputCostPerVideoPerSecondAbove128kTokens( + inputCostPerVideoPerSecondAbove128kTokens.getOrNull() + ) + + /** + * Sets [Builder.inputCostPerVideoPerSecondAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerVideoPerSecondAbove128kTokens] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputCostPerVideoPerSecondAbove128kTokens( + inputCostPerVideoPerSecondAbove128kTokens: JsonField + ) = apply { + this.inputCostPerVideoPerSecondAbove128kTokens = + inputCostPerVideoPerSecondAbove128kTokens + } + + fun inputCostPerVideoPerSecondAbove15sInterval( + inputCostPerVideoPerSecondAbove15sInterval: Double? + ) = + inputCostPerVideoPerSecondAbove15sInterval( + JsonField.ofNullable(inputCostPerVideoPerSecondAbove15sInterval) + ) + + /** + * Alias for [Builder.inputCostPerVideoPerSecondAbove15sInterval]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerVideoPerSecondAbove15sInterval( + inputCostPerVideoPerSecondAbove15sInterval: Double + ) = + inputCostPerVideoPerSecondAbove15sInterval( + inputCostPerVideoPerSecondAbove15sInterval as Double? + ) + + /** + * Alias for calling [Builder.inputCostPerVideoPerSecondAbove15sInterval] with + * `inputCostPerVideoPerSecondAbove15sInterval.orElse(null)`. + */ + fun inputCostPerVideoPerSecondAbove15sInterval( + inputCostPerVideoPerSecondAbove15sInterval: Optional + ) = + inputCostPerVideoPerSecondAbove15sInterval( + inputCostPerVideoPerSecondAbove15sInterval.getOrNull() + ) + + /** + * Sets [Builder.inputCostPerVideoPerSecondAbove15sInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerVideoPerSecondAbove15sInterval] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputCostPerVideoPerSecondAbove15sInterval( + inputCostPerVideoPerSecondAbove15sInterval: JsonField + ) = apply { + this.inputCostPerVideoPerSecondAbove15sInterval = + inputCostPerVideoPerSecondAbove15sInterval + } + + fun inputCostPerVideoPerSecondAbove8sInterval( + inputCostPerVideoPerSecondAbove8sInterval: Double? + ) = + inputCostPerVideoPerSecondAbove8sInterval( + JsonField.ofNullable(inputCostPerVideoPerSecondAbove8sInterval) + ) + + /** + * Alias for [Builder.inputCostPerVideoPerSecondAbove8sInterval]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inputCostPerVideoPerSecondAbove8sInterval( + inputCostPerVideoPerSecondAbove8sInterval: Double + ) = + inputCostPerVideoPerSecondAbove8sInterval( + inputCostPerVideoPerSecondAbove8sInterval as Double? + ) + + /** + * Alias for calling [Builder.inputCostPerVideoPerSecondAbove8sInterval] with + * `inputCostPerVideoPerSecondAbove8sInterval.orElse(null)`. + */ + fun inputCostPerVideoPerSecondAbove8sInterval( + inputCostPerVideoPerSecondAbove8sInterval: Optional + ) = + inputCostPerVideoPerSecondAbove8sInterval( + inputCostPerVideoPerSecondAbove8sInterval.getOrNull() + ) + + /** + * Sets [Builder.inputCostPerVideoPerSecondAbove8sInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.inputCostPerVideoPerSecondAbove8sInterval] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputCostPerVideoPerSecondAbove8sInterval( + inputCostPerVideoPerSecondAbove8sInterval: JsonField + ) = apply { + this.inputCostPerVideoPerSecondAbove8sInterval = + inputCostPerVideoPerSecondAbove8sInterval + } + + fun litellmCredentialName(litellmCredentialName: String?) = + litellmCredentialName(JsonField.ofNullable(litellmCredentialName)) + + /** + * Alias for calling [Builder.litellmCredentialName] with + * `litellmCredentialName.orElse(null)`. + */ + fun litellmCredentialName(litellmCredentialName: Optional) = + litellmCredentialName(litellmCredentialName.getOrNull()) + + /** + * Sets [Builder.litellmCredentialName] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmCredentialName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun litellmCredentialName(litellmCredentialName: JsonField) = apply { + this.litellmCredentialName = litellmCredentialName + } + + fun litellmTraceId(litellmTraceId: String?) = + litellmTraceId(JsonField.ofNullable(litellmTraceId)) + + /** Alias for calling [Builder.litellmTraceId] with `litellmTraceId.orElse(null)`. */ + fun litellmTraceId(litellmTraceId: Optional) = + litellmTraceId(litellmTraceId.getOrNull()) + + /** + * Sets [Builder.litellmTraceId] to an arbitrary JSON value. + * + * You should usually call [Builder.litellmTraceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun litellmTraceId(litellmTraceId: JsonField) = apply { + this.litellmTraceId = litellmTraceId + } + + fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) + + /** + * Alias for [Builder.maxBudget]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxBudget(maxBudget: Double) = maxBudget(maxBudget as Double?) + + /** Alias for calling [Builder.maxBudget] with `maxBudget.orElse(null)`. */ + fun maxBudget(maxBudget: Optional) = maxBudget(maxBudget.getOrNull()) + + /** + * Sets [Builder.maxBudget] to an arbitrary JSON value. + * + * You should usually call [Builder.maxBudget] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxBudget(maxBudget: JsonField) = apply { this.maxBudget = maxBudget } + + fun maxFileSizeMb(maxFileSizeMb: Double?) = + maxFileSizeMb(JsonField.ofNullable(maxFileSizeMb)) + + /** + * Alias for [Builder.maxFileSizeMb]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxFileSizeMb(maxFileSizeMb: Double) = maxFileSizeMb(maxFileSizeMb as Double?) + + /** Alias for calling [Builder.maxFileSizeMb] with `maxFileSizeMb.orElse(null)`. */ + fun maxFileSizeMb(maxFileSizeMb: Optional) = + maxFileSizeMb(maxFileSizeMb.getOrNull()) + + /** + * Sets [Builder.maxFileSizeMb] to an arbitrary JSON value. + * + * You should usually call [Builder.maxFileSizeMb] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxFileSizeMb(maxFileSizeMb: JsonField) = apply { + this.maxFileSizeMb = maxFileSizeMb + } + + fun maxRetries(maxRetries: Long?) = maxRetries(JsonField.ofNullable(maxRetries)) + + /** + * Alias for [Builder.maxRetries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxRetries(maxRetries: Long) = maxRetries(maxRetries as Long?) + + /** Alias for calling [Builder.maxRetries] with `maxRetries.orElse(null)`. */ + fun maxRetries(maxRetries: Optional) = maxRetries(maxRetries.getOrNull()) + + /** + * Sets [Builder.maxRetries] to an arbitrary JSON value. + * + * You should usually call [Builder.maxRetries] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxRetries(maxRetries: JsonField) = apply { this.maxRetries = maxRetries } + + fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: Boolean?) = + mergeReasoningContentInChoices(JsonField.ofNullable(mergeReasoningContentInChoices)) + + /** + * Alias for [Builder.mergeReasoningContentInChoices]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: Boolean) = + mergeReasoningContentInChoices(mergeReasoningContentInChoices as Boolean?) + + /** + * Alias for calling [Builder.mergeReasoningContentInChoices] with + * `mergeReasoningContentInChoices.orElse(null)`. + */ + fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: Optional) = + mergeReasoningContentInChoices(mergeReasoningContentInChoices.getOrNull()) + + /** + * Sets [Builder.mergeReasoningContentInChoices] to an arbitrary JSON value. + * + * You should usually call [Builder.mergeReasoningContentInChoices] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: JsonField) = + apply { + this.mergeReasoningContentInChoices = mergeReasoningContentInChoices + } + + fun milvusTextField(milvusTextField: String?) = + milvusTextField(JsonField.ofNullable(milvusTextField)) + + /** Alias for calling [Builder.milvusTextField] with `milvusTextField.orElse(null)`. */ + fun milvusTextField(milvusTextField: Optional) = + milvusTextField(milvusTextField.getOrNull()) + + /** + * Sets [Builder.milvusTextField] to an arbitrary JSON value. + * + * You should usually call [Builder.milvusTextField] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun milvusTextField(milvusTextField: JsonField) = apply { + this.milvusTextField = milvusTextField + } + + fun mockResponse(mockResponse: MockResponse?) = + mockResponse(JsonField.ofNullable(mockResponse)) + + /** Alias for calling [Builder.mockResponse] with `mockResponse.orElse(null)`. */ + fun mockResponse(mockResponse: Optional) = + mockResponse(mockResponse.getOrNull()) + + /** + * Sets [Builder.mockResponse] to an arbitrary JSON value. + * + * You should usually call [Builder.mockResponse] with a well-typed [MockResponse] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mockResponse(mockResponse: JsonField) = apply { + this.mockResponse = mockResponse + } + + /** Alias for calling [mockResponse] with `MockResponse.ofString(string)`. */ + fun mockResponse(string: String) = mockResponse(MockResponse.ofString(string)) + + /** Alias for calling [mockResponse] with `MockResponse.ofModel(model)`. */ + fun mockResponse(model: MockResponse.ModelResponse) = + mockResponse(MockResponse.ofModel(model)) + + /** Alias for calling [mockResponse] with `MockResponse.ofJsonValue(jsonValue)`. */ + fun mockResponse(jsonValue: JsonValue) = + mockResponse(MockResponse.ofJsonValue(jsonValue)) + + fun modelInfo(modelInfo: ModelInfo?) = modelInfo(JsonField.ofNullable(modelInfo)) + + /** Alias for calling [Builder.modelInfo] with `modelInfo.orElse(null)`. */ + fun modelInfo(modelInfo: Optional) = modelInfo(modelInfo.getOrNull()) + + /** + * Sets [Builder.modelInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.modelInfo] with a well-typed [ModelInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelInfo(modelInfo: JsonField) = apply { this.modelInfo = modelInfo } + + fun organization(organization: String?) = + organization(JsonField.ofNullable(organization)) + + /** Alias for calling [Builder.organization] with `organization.orElse(null)`. */ + fun organization(organization: Optional) = + organization(organization.getOrNull()) + + /** + * Sets [Builder.organization] to an arbitrary JSON value. + * + * You should usually call [Builder.organization] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organization(organization: JsonField) = apply { + this.organization = organization + } + + fun outputCostPerAudioPerSecond(outputCostPerAudioPerSecond: Double?) = + outputCostPerAudioPerSecond(JsonField.ofNullable(outputCostPerAudioPerSecond)) + + /** + * Alias for [Builder.outputCostPerAudioPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerAudioPerSecond(outputCostPerAudioPerSecond: Double) = + outputCostPerAudioPerSecond(outputCostPerAudioPerSecond as Double?) + + /** + * Alias for calling [Builder.outputCostPerAudioPerSecond] with + * `outputCostPerAudioPerSecond.orElse(null)`. + */ + fun outputCostPerAudioPerSecond(outputCostPerAudioPerSecond: Optional) = + outputCostPerAudioPerSecond(outputCostPerAudioPerSecond.getOrNull()) + + /** + * Sets [Builder.outputCostPerAudioPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerAudioPerSecond] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerAudioPerSecond(outputCostPerAudioPerSecond: JsonField) = + apply { + this.outputCostPerAudioPerSecond = outputCostPerAudioPerSecond + } + + fun outputCostPerAudioToken(outputCostPerAudioToken: Double?) = + outputCostPerAudioToken(JsonField.ofNullable(outputCostPerAudioToken)) + + /** + * Alias for [Builder.outputCostPerAudioToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerAudioToken(outputCostPerAudioToken: Double) = + outputCostPerAudioToken(outputCostPerAudioToken as Double?) + + /** + * Alias for calling [Builder.outputCostPerAudioToken] with + * `outputCostPerAudioToken.orElse(null)`. + */ + fun outputCostPerAudioToken(outputCostPerAudioToken: Optional) = + outputCostPerAudioToken(outputCostPerAudioToken.getOrNull()) + + /** + * Sets [Builder.outputCostPerAudioToken] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerAudioToken] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputCostPerAudioToken(outputCostPerAudioToken: JsonField) = apply { + this.outputCostPerAudioToken = outputCostPerAudioToken + } + + fun outputCostPerCharacter(outputCostPerCharacter: Double?) = + outputCostPerCharacter(JsonField.ofNullable(outputCostPerCharacter)) + + /** + * Alias for [Builder.outputCostPerCharacter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerCharacter(outputCostPerCharacter: Double) = + outputCostPerCharacter(outputCostPerCharacter as Double?) + + /** + * Alias for calling [Builder.outputCostPerCharacter] with + * `outputCostPerCharacter.orElse(null)`. + */ + fun outputCostPerCharacter(outputCostPerCharacter: Optional) = + outputCostPerCharacter(outputCostPerCharacter.getOrNull()) + + /** + * Sets [Builder.outputCostPerCharacter] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerCharacter] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputCostPerCharacter(outputCostPerCharacter: JsonField) = apply { + this.outputCostPerCharacter = outputCostPerCharacter + } + + fun outputCostPerCharacterAbove128kTokens( + outputCostPerCharacterAbove128kTokens: Double? + ) = + outputCostPerCharacterAbove128kTokens( + JsonField.ofNullable(outputCostPerCharacterAbove128kTokens) + ) + + /** + * Alias for [Builder.outputCostPerCharacterAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerCharacterAbove128kTokens( + outputCostPerCharacterAbove128kTokens: Double + ) = + outputCostPerCharacterAbove128kTokens( + outputCostPerCharacterAbove128kTokens as Double? + ) + + /** + * Alias for calling [Builder.outputCostPerCharacterAbove128kTokens] with + * `outputCostPerCharacterAbove128kTokens.orElse(null)`. + */ + fun outputCostPerCharacterAbove128kTokens( + outputCostPerCharacterAbove128kTokens: Optional + ) = + outputCostPerCharacterAbove128kTokens( + outputCostPerCharacterAbove128kTokens.getOrNull() + ) + + /** + * Sets [Builder.outputCostPerCharacterAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerCharacterAbove128kTokens] with a + * well-typed [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun outputCostPerCharacterAbove128kTokens( + outputCostPerCharacterAbove128kTokens: JsonField + ) = apply { + this.outputCostPerCharacterAbove128kTokens = outputCostPerCharacterAbove128kTokens + } + + fun outputCostPerImage(outputCostPerImage: Double?) = + outputCostPerImage(JsonField.ofNullable(outputCostPerImage)) + + /** + * Alias for [Builder.outputCostPerImage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerImage(outputCostPerImage: Double) = + outputCostPerImage(outputCostPerImage as Double?) + + /** + * Alias for calling [Builder.outputCostPerImage] with + * `outputCostPerImage.orElse(null)`. + */ + fun outputCostPerImage(outputCostPerImage: Optional) = + outputCostPerImage(outputCostPerImage.getOrNull()) + + /** + * Sets [Builder.outputCostPerImage] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerImage] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputCostPerImage(outputCostPerImage: JsonField) = apply { + this.outputCostPerImage = outputCostPerImage + } + + fun outputCostPerImageToken(outputCostPerImageToken: Double?) = + outputCostPerImageToken(JsonField.ofNullable(outputCostPerImageToken)) + + /** + * Alias for [Builder.outputCostPerImageToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerImageToken(outputCostPerImageToken: Double) = + outputCostPerImageToken(outputCostPerImageToken as Double?) + + /** + * Alias for calling [Builder.outputCostPerImageToken] with + * `outputCostPerImageToken.orElse(null)`. + */ + fun outputCostPerImageToken(outputCostPerImageToken: Optional) = + outputCostPerImageToken(outputCostPerImageToken.getOrNull()) + + /** + * Sets [Builder.outputCostPerImageToken] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerImageToken] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputCostPerImageToken(outputCostPerImageToken: JsonField) = apply { + this.outputCostPerImageToken = outputCostPerImageToken + } + + fun outputCostPerPixel(outputCostPerPixel: Double?) = + outputCostPerPixel(JsonField.ofNullable(outputCostPerPixel)) + + /** + * Alias for [Builder.outputCostPerPixel]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerPixel(outputCostPerPixel: Double) = + outputCostPerPixel(outputCostPerPixel as Double?) + + /** + * Alias for calling [Builder.outputCostPerPixel] with + * `outputCostPerPixel.orElse(null)`. + */ + fun outputCostPerPixel(outputCostPerPixel: Optional) = + outputCostPerPixel(outputCostPerPixel.getOrNull()) + + /** + * Sets [Builder.outputCostPerPixel] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerPixel] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputCostPerPixel(outputCostPerPixel: JsonField) = apply { + this.outputCostPerPixel = outputCostPerPixel + } + + fun outputCostPerReasoningToken(outputCostPerReasoningToken: Double?) = + outputCostPerReasoningToken(JsonField.ofNullable(outputCostPerReasoningToken)) + + /** + * Alias for [Builder.outputCostPerReasoningToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerReasoningToken(outputCostPerReasoningToken: Double) = + outputCostPerReasoningToken(outputCostPerReasoningToken as Double?) + + /** + * Alias for calling [Builder.outputCostPerReasoningToken] with + * `outputCostPerReasoningToken.orElse(null)`. + */ + fun outputCostPerReasoningToken(outputCostPerReasoningToken: Optional) = + outputCostPerReasoningToken(outputCostPerReasoningToken.getOrNull()) + + /** + * Sets [Builder.outputCostPerReasoningToken] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerReasoningToken] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerReasoningToken(outputCostPerReasoningToken: JsonField) = + apply { + this.outputCostPerReasoningToken = outputCostPerReasoningToken + } + + fun outputCostPerSecond(outputCostPerSecond: Double?) = + outputCostPerSecond(JsonField.ofNullable(outputCostPerSecond)) + + /** + * Alias for [Builder.outputCostPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerSecond(outputCostPerSecond: Double) = + outputCostPerSecond(outputCostPerSecond as Double?) + + /** + * Alias for calling [Builder.outputCostPerSecond] with + * `outputCostPerSecond.orElse(null)`. + */ + fun outputCostPerSecond(outputCostPerSecond: Optional) = + outputCostPerSecond(outputCostPerSecond.getOrNull()) + + /** + * Sets [Builder.outputCostPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerSecond] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputCostPerSecond(outputCostPerSecond: JsonField) = apply { + this.outputCostPerSecond = outputCostPerSecond + } + + fun outputCostPerToken(outputCostPerToken: Double?) = + outputCostPerToken(JsonField.ofNullable(outputCostPerToken)) + + /** + * Alias for [Builder.outputCostPerToken]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerToken(outputCostPerToken: Double) = + outputCostPerToken(outputCostPerToken as Double?) + + /** + * Alias for calling [Builder.outputCostPerToken] with + * `outputCostPerToken.orElse(null)`. + */ + fun outputCostPerToken(outputCostPerToken: Optional) = + outputCostPerToken(outputCostPerToken.getOrNull()) + + /** + * Sets [Builder.outputCostPerToken] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerToken] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputCostPerToken(outputCostPerToken: JsonField) = apply { + this.outputCostPerToken = outputCostPerToken + } + + fun outputCostPerTokenAbove128kTokens(outputCostPerTokenAbove128kTokens: Double?) = + outputCostPerTokenAbove128kTokens( + JsonField.ofNullable(outputCostPerTokenAbove128kTokens) + ) + + /** + * Alias for [Builder.outputCostPerTokenAbove128kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerTokenAbove128kTokens(outputCostPerTokenAbove128kTokens: Double) = + outputCostPerTokenAbove128kTokens(outputCostPerTokenAbove128kTokens as Double?) + + /** + * Alias for calling [Builder.outputCostPerTokenAbove128kTokens] with + * `outputCostPerTokenAbove128kTokens.orElse(null)`. + */ + fun outputCostPerTokenAbove128kTokens( + outputCostPerTokenAbove128kTokens: Optional + ) = outputCostPerTokenAbove128kTokens(outputCostPerTokenAbove128kTokens.getOrNull()) + + /** + * Sets [Builder.outputCostPerTokenAbove128kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerTokenAbove128kTokens] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerTokenAbove128kTokens( + outputCostPerTokenAbove128kTokens: JsonField + ) = apply { this.outputCostPerTokenAbove128kTokens = outputCostPerTokenAbove128kTokens } + + fun outputCostPerTokenAbove200kTokens(outputCostPerTokenAbove200kTokens: Double?) = + outputCostPerTokenAbove200kTokens( + JsonField.ofNullable(outputCostPerTokenAbove200kTokens) + ) + + /** + * Alias for [Builder.outputCostPerTokenAbove200kTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerTokenAbove200kTokens(outputCostPerTokenAbove200kTokens: Double) = + outputCostPerTokenAbove200kTokens(outputCostPerTokenAbove200kTokens as Double?) + + /** + * Alias for calling [Builder.outputCostPerTokenAbove200kTokens] with + * `outputCostPerTokenAbove200kTokens.orElse(null)`. + */ + fun outputCostPerTokenAbove200kTokens( + outputCostPerTokenAbove200kTokens: Optional + ) = outputCostPerTokenAbove200kTokens(outputCostPerTokenAbove200kTokens.getOrNull()) + + /** + * Sets [Builder.outputCostPerTokenAbove200kTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerTokenAbove200kTokens] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerTokenAbove200kTokens( + outputCostPerTokenAbove200kTokens: JsonField + ) = apply { this.outputCostPerTokenAbove200kTokens = outputCostPerTokenAbove200kTokens } + + fun outputCostPerTokenBatches(outputCostPerTokenBatches: Double?) = + outputCostPerTokenBatches(JsonField.ofNullable(outputCostPerTokenBatches)) + + /** + * Alias for [Builder.outputCostPerTokenBatches]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerTokenBatches(outputCostPerTokenBatches: Double) = + outputCostPerTokenBatches(outputCostPerTokenBatches as Double?) + + /** + * Alias for calling [Builder.outputCostPerTokenBatches] with + * `outputCostPerTokenBatches.orElse(null)`. + */ + fun outputCostPerTokenBatches(outputCostPerTokenBatches: Optional) = + outputCostPerTokenBatches(outputCostPerTokenBatches.getOrNull()) + + /** + * Sets [Builder.outputCostPerTokenBatches] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerTokenBatches] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerTokenBatches(outputCostPerTokenBatches: JsonField) = apply { + this.outputCostPerTokenBatches = outputCostPerTokenBatches + } + + fun outputCostPerTokenFlex(outputCostPerTokenFlex: Double?) = + outputCostPerTokenFlex(JsonField.ofNullable(outputCostPerTokenFlex)) + + /** + * Alias for [Builder.outputCostPerTokenFlex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerTokenFlex(outputCostPerTokenFlex: Double) = + outputCostPerTokenFlex(outputCostPerTokenFlex as Double?) + + /** + * Alias for calling [Builder.outputCostPerTokenFlex] with + * `outputCostPerTokenFlex.orElse(null)`. + */ + fun outputCostPerTokenFlex(outputCostPerTokenFlex: Optional) = + outputCostPerTokenFlex(outputCostPerTokenFlex.getOrNull()) + + /** + * Sets [Builder.outputCostPerTokenFlex] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerTokenFlex] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputCostPerTokenFlex(outputCostPerTokenFlex: JsonField) = apply { + this.outputCostPerTokenFlex = outputCostPerTokenFlex + } + + fun outputCostPerTokenPriority(outputCostPerTokenPriority: Double?) = + outputCostPerTokenPriority(JsonField.ofNullable(outputCostPerTokenPriority)) + + /** + * Alias for [Builder.outputCostPerTokenPriority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerTokenPriority(outputCostPerTokenPriority: Double) = + outputCostPerTokenPriority(outputCostPerTokenPriority as Double?) + + /** + * Alias for calling [Builder.outputCostPerTokenPriority] with + * `outputCostPerTokenPriority.orElse(null)`. + */ + fun outputCostPerTokenPriority(outputCostPerTokenPriority: Optional) = + outputCostPerTokenPriority(outputCostPerTokenPriority.getOrNull()) + + /** + * Sets [Builder.outputCostPerTokenPriority] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerTokenPriority] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerTokenPriority(outputCostPerTokenPriority: JsonField) = apply { + this.outputCostPerTokenPriority = outputCostPerTokenPriority + } + + fun outputCostPerVideoPerSecond(outputCostPerVideoPerSecond: Double?) = + outputCostPerVideoPerSecond(JsonField.ofNullable(outputCostPerVideoPerSecond)) + + /** + * Alias for [Builder.outputCostPerVideoPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun outputCostPerVideoPerSecond(outputCostPerVideoPerSecond: Double) = + outputCostPerVideoPerSecond(outputCostPerVideoPerSecond as Double?) + + /** + * Alias for calling [Builder.outputCostPerVideoPerSecond] with + * `outputCostPerVideoPerSecond.orElse(null)`. + */ + fun outputCostPerVideoPerSecond(outputCostPerVideoPerSecond: Optional) = + outputCostPerVideoPerSecond(outputCostPerVideoPerSecond.getOrNull()) + + /** + * Sets [Builder.outputCostPerVideoPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.outputCostPerVideoPerSecond] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputCostPerVideoPerSecond(outputCostPerVideoPerSecond: JsonField) = + apply { + this.outputCostPerVideoPerSecond = outputCostPerVideoPerSecond + } + + fun regionName(regionName: String?) = regionName(JsonField.ofNullable(regionName)) + + /** Alias for calling [Builder.regionName] with `regionName.orElse(null)`. */ + fun regionName(regionName: Optional) = regionName(regionName.getOrNull()) + + /** + * Sets [Builder.regionName] to an arbitrary JSON value. + * + * You should usually call [Builder.regionName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun regionName(regionName: JsonField) = apply { this.regionName = regionName } + + fun rpm(rpm: Long?) = rpm(JsonField.ofNullable(rpm)) + + /** + * Alias for [Builder.rpm]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rpm(rpm: Long) = rpm(rpm as Long?) + + /** Alias for calling [Builder.rpm] with `rpm.orElse(null)`. */ + fun rpm(rpm: Optional) = rpm(rpm.getOrNull()) + + /** + * Sets [Builder.rpm] to an arbitrary JSON value. + * + * You should usually call [Builder.rpm] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rpm(rpm: JsonField) = apply { this.rpm = rpm } + + fun s3BucketName(s3BucketName: String?) = + s3BucketName(JsonField.ofNullable(s3BucketName)) + + /** Alias for calling [Builder.s3BucketName] with `s3BucketName.orElse(null)`. */ + fun s3BucketName(s3BucketName: Optional) = + s3BucketName(s3BucketName.getOrNull()) + + /** + * Sets [Builder.s3BucketName] to an arbitrary JSON value. + * + * You should usually call [Builder.s3BucketName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3BucketName(s3BucketName: JsonField) = apply { + this.s3BucketName = s3BucketName + } + + fun s3EncryptionKeyId(s3EncryptionKeyId: String?) = + s3EncryptionKeyId(JsonField.ofNullable(s3EncryptionKeyId)) + + /** + * Alias for calling [Builder.s3EncryptionKeyId] with `s3EncryptionKeyId.orElse(null)`. + */ + fun s3EncryptionKeyId(s3EncryptionKeyId: Optional) = + s3EncryptionKeyId(s3EncryptionKeyId.getOrNull()) + + /** + * Sets [Builder.s3EncryptionKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.s3EncryptionKeyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3EncryptionKeyId(s3EncryptionKeyId: JsonField) = apply { + this.s3EncryptionKeyId = s3EncryptionKeyId + } + + fun searchContextCostPerQuery(searchContextCostPerQuery: SearchContextCostPerQuery?) = + searchContextCostPerQuery(JsonField.ofNullable(searchContextCostPerQuery)) + + /** + * Alias for calling [Builder.searchContextCostPerQuery] with + * `searchContextCostPerQuery.orElse(null)`. + */ + fun searchContextCostPerQuery( + searchContextCostPerQuery: Optional + ) = searchContextCostPerQuery(searchContextCostPerQuery.getOrNull()) + + /** + * Sets [Builder.searchContextCostPerQuery] to an arbitrary JSON value. + * + * You should usually call [Builder.searchContextCostPerQuery] with a well-typed + * [SearchContextCostPerQuery] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun searchContextCostPerQuery( + searchContextCostPerQuery: JsonField + ) = apply { this.searchContextCostPerQuery = searchContextCostPerQuery } + + fun streamTimeout(streamTimeout: StreamTimeout?) = + streamTimeout(JsonField.ofNullable(streamTimeout)) + + /** Alias for calling [Builder.streamTimeout] with `streamTimeout.orElse(null)`. */ + fun streamTimeout(streamTimeout: Optional) = + streamTimeout(streamTimeout.getOrNull()) + + /** + * Sets [Builder.streamTimeout] to an arbitrary JSON value. + * + * You should usually call [Builder.streamTimeout] with a well-typed [StreamTimeout] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun streamTimeout(streamTimeout: JsonField) = apply { + this.streamTimeout = streamTimeout + } + + /** Alias for calling [streamTimeout] with `StreamTimeout.ofNumber(number)`. */ + fun streamTimeout(number: Double) = streamTimeout(StreamTimeout.ofNumber(number)) + + /** Alias for calling [streamTimeout] with `StreamTimeout.ofString(string)`. */ + fun streamTimeout(string: String) = streamTimeout(StreamTimeout.ofString(string)) + + fun tieredPricing(tieredPricing: List?) = + tieredPricing(JsonField.ofNullable(tieredPricing)) + + /** Alias for calling [Builder.tieredPricing] with `tieredPricing.orElse(null)`. */ + fun tieredPricing(tieredPricing: Optional>) = + tieredPricing(tieredPricing.getOrNull()) + + /** + * Sets [Builder.tieredPricing] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPricing] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tieredPricing(tieredPricing: JsonField>) = apply { + this.tieredPricing = tieredPricing.map { it.toMutableList() } + } + + /** + * Adds a single [TieredPricing] to [Builder.tieredPricing]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTieredPricing(tieredPricing: TieredPricing) = apply { + this.tieredPricing = + (this.tieredPricing ?: JsonField.of(mutableListOf())).also { + checkKnown("tieredPricing", it).add(tieredPricing) + } + } + + fun timeout(timeout: Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Timeout] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + /** Alias for calling [timeout] with `Timeout.ofNumber(number)`. */ + fun timeout(number: Double) = timeout(Timeout.ofNumber(number)) + + /** Alias for calling [timeout] with `Timeout.ofString(string)`. */ + fun timeout(string: String) = timeout(Timeout.ofString(string)) + + fun tpm(tpm: Long?) = tpm(JsonField.ofNullable(tpm)) + + /** + * Alias for [Builder.tpm]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tpm(tpm: Long) = tpm(tpm as Long?) + + /** Alias for calling [Builder.tpm] with `tpm.orElse(null)`. */ + fun tpm(tpm: Optional) = tpm(tpm.getOrNull()) + + /** + * Sets [Builder.tpm] to an arbitrary JSON value. + * + * You should usually call [Builder.tpm] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tpm(tpm: JsonField) = apply { this.tpm = tpm } + + fun useInPassThrough(useInPassThrough: Boolean?) = + useInPassThrough(JsonField.ofNullable(useInPassThrough)) + + /** + * Alias for [Builder.useInPassThrough]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun useInPassThrough(useInPassThrough: Boolean) = + useInPassThrough(useInPassThrough as Boolean?) + + /** + * Alias for calling [Builder.useInPassThrough] with `useInPassThrough.orElse(null)`. + */ + fun useInPassThrough(useInPassThrough: Optional) = + useInPassThrough(useInPassThrough.getOrNull()) + + /** + * Sets [Builder.useInPassThrough] to an arbitrary JSON value. + * + * You should usually call [Builder.useInPassThrough] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useInPassThrough(useInPassThrough: JsonField) = apply { + this.useInPassThrough = useInPassThrough + } + + fun useLitellmProxy(useLitellmProxy: Boolean?) = + useLitellmProxy(JsonField.ofNullable(useLitellmProxy)) + + /** + * Alias for [Builder.useLitellmProxy]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun useLitellmProxy(useLitellmProxy: Boolean) = + useLitellmProxy(useLitellmProxy as Boolean?) + + /** Alias for calling [Builder.useLitellmProxy] with `useLitellmProxy.orElse(null)`. */ + fun useLitellmProxy(useLitellmProxy: Optional) = + useLitellmProxy(useLitellmProxy.getOrNull()) + + /** + * Sets [Builder.useLitellmProxy] to an arbitrary JSON value. + * + * You should usually call [Builder.useLitellmProxy] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useLitellmProxy(useLitellmProxy: JsonField) = apply { + this.useLitellmProxy = useLitellmProxy + } + + fun vectorStoreId(vectorStoreId: String?) = + vectorStoreId(JsonField.ofNullable(vectorStoreId)) + + /** Alias for calling [Builder.vectorStoreId] with `vectorStoreId.orElse(null)`. */ + fun vectorStoreId(vectorStoreId: Optional) = + vectorStoreId(vectorStoreId.getOrNull()) + + /** + * Sets [Builder.vectorStoreId] to an arbitrary JSON value. + * + * You should usually call [Builder.vectorStoreId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vectorStoreId(vectorStoreId: JsonField) = apply { + this.vectorStoreId = vectorStoreId + } + + fun vertexCredentials(vertexCredentials: VertexCredentials?) = + vertexCredentials(JsonField.ofNullable(vertexCredentials)) + + /** + * Alias for calling [Builder.vertexCredentials] with `vertexCredentials.orElse(null)`. + */ + fun vertexCredentials(vertexCredentials: Optional) = + vertexCredentials(vertexCredentials.getOrNull()) + + /** + * Sets [Builder.vertexCredentials] to an arbitrary JSON value. + * + * You should usually call [Builder.vertexCredentials] with a well-typed + * [VertexCredentials] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun vertexCredentials(vertexCredentials: JsonField) = apply { + this.vertexCredentials = vertexCredentials + } + + /** Alias for calling [vertexCredentials] with `VertexCredentials.ofString(string)`. */ + fun vertexCredentials(string: String) = + vertexCredentials(VertexCredentials.ofString(string)) + + /** + * Alias for calling [vertexCredentials] with + * `VertexCredentials.ofUnionMember1(unionMember1)`. + */ + fun vertexCredentials(unionMember1: VertexCredentials.UnionMember1) = + vertexCredentials(VertexCredentials.ofUnionMember1(unionMember1)) + + fun vertexLocation(vertexLocation: String?) = + vertexLocation(JsonField.ofNullable(vertexLocation)) + + /** Alias for calling [Builder.vertexLocation] with `vertexLocation.orElse(null)`. */ + fun vertexLocation(vertexLocation: Optional) = + vertexLocation(vertexLocation.getOrNull()) + + /** + * Sets [Builder.vertexLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.vertexLocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vertexLocation(vertexLocation: JsonField) = apply { + this.vertexLocation = vertexLocation + } + + fun vertexProject(vertexProject: String?) = + vertexProject(JsonField.ofNullable(vertexProject)) + + /** Alias for calling [Builder.vertexProject] with `vertexProject.orElse(null)`. */ + fun vertexProject(vertexProject: Optional) = + vertexProject(vertexProject.getOrNull()) + + /** + * Sets [Builder.vertexProject] to an arbitrary JSON value. + * + * You should usually call [Builder.vertexProject] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vertexProject(vertexProject: JsonField) = apply { + this.vertexProject = vertexProject + } + + fun watsonxRegionName(watsonxRegionName: String?) = + watsonxRegionName(JsonField.ofNullable(watsonxRegionName)) + + /** + * Alias for calling [Builder.watsonxRegionName] with `watsonxRegionName.orElse(null)`. + */ + fun watsonxRegionName(watsonxRegionName: Optional) = + watsonxRegionName(watsonxRegionName.getOrNull()) + + /** + * Sets [Builder.watsonxRegionName] to an arbitrary JSON value. + * + * You should usually call [Builder.watsonxRegionName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun watsonxRegionName(watsonxRegionName: JsonField) = apply { + this.watsonxRegionName = watsonxRegionName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LitellmParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .model() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LitellmParams = + LitellmParams( + checkRequired("model", model), + apiBase, + apiKey, + apiVersion, + autoRouterConfig, + autoRouterConfigPath, + autoRouterDefaultModel, + autoRouterEmbeddingModel, + awsAccessKeyId, + awsBedrockRuntimeEndpoint, + awsRegionName, + awsSecretAccessKey, + budgetDuration, + cacheCreationInputAudioTokenCost, + cacheCreationInputTokenCost, + cacheCreationInputTokenCostAbove1hr, + cacheCreationInputTokenCostAbove200kTokens, + cacheReadInputAudioTokenCost, + cacheReadInputTokenCost, + cacheReadInputTokenCostAbove200kTokens, + cacheReadInputTokenCostFlex, + cacheReadInputTokenCostPriority, + citationCostPerToken, + (configurableClientsideAuthParams ?: JsonMissing.of()).map { it.toImmutable() }, + customLlmProvider, + gcsBucketName, + inputCostPerAudioPerSecond, + inputCostPerAudioPerSecondAbove128kTokens, + inputCostPerAudioToken, + inputCostPerCharacter, + inputCostPerCharacterAbove128kTokens, + inputCostPerImage, + inputCostPerImageAbove128kTokens, + inputCostPerPixel, + inputCostPerQuery, + inputCostPerSecond, + inputCostPerToken, + inputCostPerTokenAbove128kTokens, + inputCostPerTokenAbove200kTokens, + inputCostPerTokenBatches, + inputCostPerTokenCacheHit, + inputCostPerTokenFlex, + inputCostPerTokenPriority, + inputCostPerVideoPerSecond, + inputCostPerVideoPerSecondAbove128kTokens, + inputCostPerVideoPerSecondAbove15sInterval, + inputCostPerVideoPerSecondAbove8sInterval, + litellmCredentialName, + litellmTraceId, + maxBudget, + maxFileSizeMb, + maxRetries, + mergeReasoningContentInChoices, + milvusTextField, + mockResponse, + modelInfo, + organization, + outputCostPerAudioPerSecond, + outputCostPerAudioToken, + outputCostPerCharacter, + outputCostPerCharacterAbove128kTokens, + outputCostPerImage, + outputCostPerImageToken, + outputCostPerPixel, + outputCostPerReasoningToken, + outputCostPerSecond, + outputCostPerToken, + outputCostPerTokenAbove128kTokens, + outputCostPerTokenAbove200kTokens, + outputCostPerTokenBatches, + outputCostPerTokenFlex, + outputCostPerTokenPriority, + outputCostPerVideoPerSecond, + regionName, + rpm, + s3BucketName, + s3EncryptionKeyId, + searchContextCostPerQuery, + streamTimeout, + (tieredPricing ?: JsonMissing.of()).map { it.toImmutable() }, + timeout, + tpm, + useInPassThrough, + useLitellmProxy, + vectorStoreId, + vertexCredentials, + vertexLocation, + vertexProject, + watsonxRegionName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LitellmParams = apply { + if (validated) { + return@apply + } + + model() + apiBase() + apiKey() + apiVersion() + autoRouterConfig() + autoRouterConfigPath() + autoRouterDefaultModel() + autoRouterEmbeddingModel() + awsAccessKeyId() + awsBedrockRuntimeEndpoint() + awsRegionName() + awsSecretAccessKey() + budgetDuration() + cacheCreationInputAudioTokenCost() + cacheCreationInputTokenCost() + cacheCreationInputTokenCostAbove1hr() + cacheCreationInputTokenCostAbove200kTokens() + cacheReadInputAudioTokenCost() + cacheReadInputTokenCost() + cacheReadInputTokenCostAbove200kTokens() + cacheReadInputTokenCostFlex() + cacheReadInputTokenCostPriority() + citationCostPerToken() + configurableClientsideAuthParams().ifPresent { it.forEach { it.validate() } } + customLlmProvider() + gcsBucketName() + inputCostPerAudioPerSecond() + inputCostPerAudioPerSecondAbove128kTokens() + inputCostPerAudioToken() + inputCostPerCharacter() + inputCostPerCharacterAbove128kTokens() + inputCostPerImage() + inputCostPerImageAbove128kTokens() + inputCostPerPixel() + inputCostPerQuery() + inputCostPerSecond() + inputCostPerToken() + inputCostPerTokenAbove128kTokens() + inputCostPerTokenAbove200kTokens() + inputCostPerTokenBatches() + inputCostPerTokenCacheHit() + inputCostPerTokenFlex() + inputCostPerTokenPriority() + inputCostPerVideoPerSecond() + inputCostPerVideoPerSecondAbove128kTokens() + inputCostPerVideoPerSecondAbove15sInterval() + inputCostPerVideoPerSecondAbove8sInterval() + litellmCredentialName() + litellmTraceId() + maxBudget() + maxFileSizeMb() + maxRetries() + mergeReasoningContentInChoices() + milvusTextField() + mockResponse().ifPresent { it.validate() } + modelInfo().ifPresent { it.validate() } + organization() + outputCostPerAudioPerSecond() + outputCostPerAudioToken() + outputCostPerCharacter() + outputCostPerCharacterAbove128kTokens() + outputCostPerImage() + outputCostPerImageToken() + outputCostPerPixel() + outputCostPerReasoningToken() + outputCostPerSecond() + outputCostPerToken() + outputCostPerTokenAbove128kTokens() + outputCostPerTokenAbove200kTokens() + outputCostPerTokenBatches() + outputCostPerTokenFlex() + outputCostPerTokenPriority() + outputCostPerVideoPerSecond() + regionName() + rpm() + s3BucketName() + s3EncryptionKeyId() + searchContextCostPerQuery().ifPresent { it.validate() } + streamTimeout().ifPresent { it.validate() } + tieredPricing().ifPresent { it.forEach { it.validate() } } + timeout().ifPresent { it.validate() } + tpm() + useInPassThrough() + useLitellmProxy() + vectorStoreId() + vertexCredentials().ifPresent { it.validate() } + vertexLocation() + vertexProject() + watsonxRegionName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (model.asKnown().isPresent) 1 else 0) + + (if (apiBase.asKnown().isPresent) 1 else 0) + + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (apiVersion.asKnown().isPresent) 1 else 0) + + (if (autoRouterConfig.asKnown().isPresent) 1 else 0) + + (if (autoRouterConfigPath.asKnown().isPresent) 1 else 0) + + (if (autoRouterDefaultModel.asKnown().isPresent) 1 else 0) + + (if (autoRouterEmbeddingModel.asKnown().isPresent) 1 else 0) + + (if (awsAccessKeyId.asKnown().isPresent) 1 else 0) + + (if (awsBedrockRuntimeEndpoint.asKnown().isPresent) 1 else 0) + + (if (awsRegionName.asKnown().isPresent) 1 else 0) + + (if (awsSecretAccessKey.asKnown().isPresent) 1 else 0) + + (if (budgetDuration.asKnown().isPresent) 1 else 0) + + (if (cacheCreationInputAudioTokenCost.asKnown().isPresent) 1 else 0) + + (if (cacheCreationInputTokenCost.asKnown().isPresent) 1 else 0) + + (if (cacheCreationInputTokenCostAbove1hr.asKnown().isPresent) 1 else 0) + + (if (cacheCreationInputTokenCostAbove200kTokens.asKnown().isPresent) 1 else 0) + + (if (cacheReadInputAudioTokenCost.asKnown().isPresent) 1 else 0) + + (if (cacheReadInputTokenCost.asKnown().isPresent) 1 else 0) + + (if (cacheReadInputTokenCostAbove200kTokens.asKnown().isPresent) 1 else 0) + + (if (cacheReadInputTokenCostFlex.asKnown().isPresent) 1 else 0) + + (if (cacheReadInputTokenCostPriority.asKnown().isPresent) 1 else 0) + + (if (citationCostPerToken.asKnown().isPresent) 1 else 0) + + (configurableClientsideAuthParams.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (customLlmProvider.asKnown().isPresent) 1 else 0) + + (if (gcsBucketName.asKnown().isPresent) 1 else 0) + + (if (inputCostPerAudioPerSecond.asKnown().isPresent) 1 else 0) + + (if (inputCostPerAudioPerSecondAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (inputCostPerAudioToken.asKnown().isPresent) 1 else 0) + + (if (inputCostPerCharacter.asKnown().isPresent) 1 else 0) + + (if (inputCostPerCharacterAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (inputCostPerImage.asKnown().isPresent) 1 else 0) + + (if (inputCostPerImageAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (inputCostPerPixel.asKnown().isPresent) 1 else 0) + + (if (inputCostPerQuery.asKnown().isPresent) 1 else 0) + + (if (inputCostPerSecond.asKnown().isPresent) 1 else 0) + + (if (inputCostPerToken.asKnown().isPresent) 1 else 0) + + (if (inputCostPerTokenAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (inputCostPerTokenAbove200kTokens.asKnown().isPresent) 1 else 0) + + (if (inputCostPerTokenBatches.asKnown().isPresent) 1 else 0) + + (if (inputCostPerTokenCacheHit.asKnown().isPresent) 1 else 0) + + (if (inputCostPerTokenFlex.asKnown().isPresent) 1 else 0) + + (if (inputCostPerTokenPriority.asKnown().isPresent) 1 else 0) + + (if (inputCostPerVideoPerSecond.asKnown().isPresent) 1 else 0) + + (if (inputCostPerVideoPerSecondAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (inputCostPerVideoPerSecondAbove15sInterval.asKnown().isPresent) 1 else 0) + + (if (inputCostPerVideoPerSecondAbove8sInterval.asKnown().isPresent) 1 else 0) + + (if (litellmCredentialName.asKnown().isPresent) 1 else 0) + + (if (litellmTraceId.asKnown().isPresent) 1 else 0) + + (if (maxBudget.asKnown().isPresent) 1 else 0) + + (if (maxFileSizeMb.asKnown().isPresent) 1 else 0) + + (if (maxRetries.asKnown().isPresent) 1 else 0) + + (if (mergeReasoningContentInChoices.asKnown().isPresent) 1 else 0) + + (if (milvusTextField.asKnown().isPresent) 1 else 0) + + (mockResponse.asKnown().getOrNull()?.validity() ?: 0) + + (modelInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (organization.asKnown().isPresent) 1 else 0) + + (if (outputCostPerAudioPerSecond.asKnown().isPresent) 1 else 0) + + (if (outputCostPerAudioToken.asKnown().isPresent) 1 else 0) + + (if (outputCostPerCharacter.asKnown().isPresent) 1 else 0) + + (if (outputCostPerCharacterAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (outputCostPerImage.asKnown().isPresent) 1 else 0) + + (if (outputCostPerImageToken.asKnown().isPresent) 1 else 0) + + (if (outputCostPerPixel.asKnown().isPresent) 1 else 0) + + (if (outputCostPerReasoningToken.asKnown().isPresent) 1 else 0) + + (if (outputCostPerSecond.asKnown().isPresent) 1 else 0) + + (if (outputCostPerToken.asKnown().isPresent) 1 else 0) + + (if (outputCostPerTokenAbove128kTokens.asKnown().isPresent) 1 else 0) + + (if (outputCostPerTokenAbove200kTokens.asKnown().isPresent) 1 else 0) + + (if (outputCostPerTokenBatches.asKnown().isPresent) 1 else 0) + + (if (outputCostPerTokenFlex.asKnown().isPresent) 1 else 0) + + (if (outputCostPerTokenPriority.asKnown().isPresent) 1 else 0) + + (if (outputCostPerVideoPerSecond.asKnown().isPresent) 1 else 0) + + (if (regionName.asKnown().isPresent) 1 else 0) + + (if (rpm.asKnown().isPresent) 1 else 0) + + (if (s3BucketName.asKnown().isPresent) 1 else 0) + + (if (s3EncryptionKeyId.asKnown().isPresent) 1 else 0) + + (searchContextCostPerQuery.asKnown().getOrNull()?.validity() ?: 0) + + (streamTimeout.asKnown().getOrNull()?.validity() ?: 0) + + (tieredPricing.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (if (tpm.asKnown().isPresent) 1 else 0) + + (if (useInPassThrough.asKnown().isPresent) 1 else 0) + + (if (useLitellmProxy.asKnown().isPresent) 1 else 0) + + (if (vectorStoreId.asKnown().isPresent) 1 else 0) + + (vertexCredentials.asKnown().getOrNull()?.validity() ?: 0) + + (if (vertexLocation.asKnown().isPresent) 1 else 0) + + (if (vertexProject.asKnown().isPresent) 1 else 0) + + (if (watsonxRegionName.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = ConfigurableClientsideAuthParam.Deserializer::class) + @JsonSerialize(using = ConfigurableClientsideAuthParam.Serializer::class) + class ConfigurableClientsideAuthParam + private constructor( + private val string: String? = null, + private val paramsCustomAuthInput: ConfigurableClientsideParamsCustomAuthInput? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun paramsCustomAuthInput(): Optional = + Optional.ofNullable(paramsCustomAuthInput) + + fun isString(): Boolean = string != null + + fun isParamsCustomAuthInput(): Boolean = paramsCustomAuthInput != null + + fun asString(): String = string.getOrThrow("string") + + fun asParamsCustomAuthInput(): ConfigurableClientsideParamsCustomAuthInput = + paramsCustomAuthInput.getOrThrow("paramsCustomAuthInput") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + paramsCustomAuthInput != null -> + visitor.visitParamsCustomAuthInput(paramsCustomAuthInput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ConfigurableClientsideAuthParam = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitParamsCustomAuthInput( + paramsCustomAuthInput: ConfigurableClientsideParamsCustomAuthInput + ) { + paramsCustomAuthInput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitParamsCustomAuthInput( + paramsCustomAuthInput: ConfigurableClientsideParamsCustomAuthInput + ) = paramsCustomAuthInput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigurableClientsideAuthParam && + string == other.string && + paramsCustomAuthInput == other.paramsCustomAuthInput + } + + override fun hashCode(): Int = Objects.hash(string, paramsCustomAuthInput) + + override fun toString(): String = + when { + string != null -> "ConfigurableClientsideAuthParam{string=$string}" + paramsCustomAuthInput != null -> + "ConfigurableClientsideAuthParam{paramsCustomAuthInput=$paramsCustomAuthInput}" + _json != null -> "ConfigurableClientsideAuthParam{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ConfigurableClientsideAuthParam") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = ConfigurableClientsideAuthParam(string = string) + + @JvmStatic + fun ofParamsCustomAuthInput( + paramsCustomAuthInput: ConfigurableClientsideParamsCustomAuthInput + ) = ConfigurableClientsideAuthParam(paramsCustomAuthInput = paramsCustomAuthInput) + } + + /** + * An interface that defines how to map each variant of + * [ConfigurableClientsideAuthParam] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitParamsCustomAuthInput( + paramsCustomAuthInput: ConfigurableClientsideParamsCustomAuthInput + ): T + + /** + * Maps an unknown variant of [ConfigurableClientsideAuthParam] to a value of type + * [T]. + * + * An instance of [ConfigurableClientsideAuthParam] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException( + "Unknown ConfigurableClientsideAuthParam: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + ConfigurableClientsideAuthParam::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ConfigurableClientsideAuthParam { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef< + ConfigurableClientsideParamsCustomAuthInput + >(), + ) + ?.let { + ConfigurableClientsideAuthParam( + paramsCustomAuthInput = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ConfigurableClientsideAuthParam(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> ConfigurableClientsideAuthParam(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + ConfigurableClientsideAuthParam::class + ) { + + override fun serialize( + value: ConfigurableClientsideAuthParam, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.paramsCustomAuthInput != null -> + generator.writeObject(value.paramsCustomAuthInput) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid ConfigurableClientsideAuthParam") + } + } + } - /** - * Sets [Builder.apiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.apiKey] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + class ConfigurableClientsideParamsCustomAuthInput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val apiBase: JsonField, + private val additionalProperties: MutableMap, + ) { - fun apiVersion(apiVersion: String?) = apiVersion(JsonField.ofNullable(apiVersion)) + @JsonCreator + private constructor( + @JsonProperty("api_base") + @ExcludeMissing + apiBase: JsonField = JsonMissing.of() + ) : this(apiBase, mutableMapOf()) - /** Alias for calling [Builder.apiVersion] with `apiVersion.orElse(null)`. */ - fun apiVersion(apiVersion: Optional) = apiVersion(apiVersion.getOrNull()) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun apiBase(): String = apiBase.getRequired("api_base") - /** - * Sets [Builder.apiVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.apiVersion] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun apiVersion(apiVersion: JsonField) = apply { this.apiVersion = apiVersion } + /** + * Returns the raw JSON value of [apiBase]. + * + * Unlike [apiBase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("api_base") + @ExcludeMissing + fun _apiBase(): JsonField = apiBase - fun awsAccessKeyId(awsAccessKeyId: String?) = - awsAccessKeyId(JsonField.ofNullable(awsAccessKeyId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.awsAccessKeyId] with `awsAccessKeyId.orElse(null)`. */ - fun awsAccessKeyId(awsAccessKeyId: Optional) = - awsAccessKeyId(awsAccessKeyId.getOrNull()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ConfigurableClientsideParamsCustomAuthInput]. + * + * The following fields are required: + * ```java + * .apiBase() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.awsAccessKeyId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsAccessKeyId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun awsAccessKeyId(awsAccessKeyId: JsonField) = apply { - this.awsAccessKeyId = awsAccessKeyId - } + /** A builder for [ConfigurableClientsideParamsCustomAuthInput]. */ + class Builder internal constructor() { + + private var apiBase: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + configurableClientsideParamsCustomAuthInput: + ConfigurableClientsideParamsCustomAuthInput + ) = apply { + apiBase = configurableClientsideParamsCustomAuthInput.apiBase + additionalProperties = + configurableClientsideParamsCustomAuthInput.additionalProperties + .toMutableMap() + } - fun awsRegionName(awsRegionName: String?) = - awsRegionName(JsonField.ofNullable(awsRegionName)) + fun apiBase(apiBase: String) = apiBase(JsonField.of(apiBase)) - /** Alias for calling [Builder.awsRegionName] with `awsRegionName.orElse(null)`. */ - fun awsRegionName(awsRegionName: Optional) = - awsRegionName(awsRegionName.getOrNull()) + /** + * Sets [Builder.apiBase] to an arbitrary JSON value. + * + * You should usually call [Builder.apiBase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun apiBase(apiBase: JsonField) = apply { this.apiBase = apiBase } - /** - * Sets [Builder.awsRegionName] to an arbitrary JSON value. - * - * You should usually call [Builder.awsRegionName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun awsRegionName(awsRegionName: JsonField) = apply { - this.awsRegionName = awsRegionName + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [ConfigurableClientsideParamsCustomAuthInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiBase() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigurableClientsideParamsCustomAuthInput = + ConfigurableClientsideParamsCustomAuthInput( + checkRequired("apiBase", apiBase), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConfigurableClientsideParamsCustomAuthInput = apply { + if (validated) { + return@apply + } + + apiBase() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (apiBase.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigurableClientsideParamsCustomAuthInput && + apiBase == other.apiBase && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(apiBase, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConfigurableClientsideParamsCustomAuthInput{apiBase=$apiBase, additionalProperties=$additionalProperties}" } + } - fun awsSecretAccessKey(awsSecretAccessKey: String?) = - awsSecretAccessKey(JsonField.ofNullable(awsSecretAccessKey)) + @JsonDeserialize(using = MockResponse.Deserializer::class) + @JsonSerialize(using = MockResponse.Serializer::class) + class MockResponse + private constructor( + private val string: String? = null, + private val model: ModelResponse? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { - /** - * Alias for calling [Builder.awsSecretAccessKey] with - * `awsSecretAccessKey.orElse(null)`. - */ - fun awsSecretAccessKey(awsSecretAccessKey: Optional) = - awsSecretAccessKey(awsSecretAccessKey.getOrNull()) + fun string(): Optional = Optional.ofNullable(string) + + fun model(): Optional = Optional.ofNullable(model) + + fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isModel(): Boolean = model != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asModel(): ModelResponse = model.getOrThrow("model") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + model != null -> visitor.visitModel(model) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MockResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitModel(model: ModelResponse) { + model.validate() + } + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } /** - * Sets [Builder.awsSecretAccessKey] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.awsSecretAccessKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun awsSecretAccessKey(awsSecretAccessKey: JsonField) = apply { - this.awsSecretAccessKey = awsSecretAccessKey + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitModel(model: ModelResponse) = model.validity() + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MockResponse && + string == other.string && + model == other.model && + jsonValue == other.jsonValue } - fun budgetDuration(budgetDuration: String?) = - budgetDuration(JsonField.ofNullable(budgetDuration)) + override fun hashCode(): Int = Objects.hash(string, model, jsonValue) - /** Alias for calling [Builder.budgetDuration] with `budgetDuration.orElse(null)`. */ - fun budgetDuration(budgetDuration: Optional) = - budgetDuration(budgetDuration.getOrNull()) + override fun toString(): String = + when { + string != null -> "MockResponse{string=$string}" + model != null -> "MockResponse{model=$model}" + jsonValue != null -> "MockResponse{jsonValue=$jsonValue}" + _json != null -> "MockResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MockResponse") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MockResponse(string = string) + + @JvmStatic fun ofModel(model: ModelResponse) = MockResponse(model = model) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = MockResponse(jsonValue = jsonValue) + } /** - * Sets [Builder.budgetDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.budgetDuration] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * An interface that defines how to map each variant of [MockResponse] to a value of + * type [T]. */ - fun budgetDuration(budgetDuration: JsonField) = apply { - this.budgetDuration = budgetDuration + interface Visitor { + + fun visitString(string: String): T + + fun visitModel(model: ModelResponse): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [MockResponse] to a value of type [T]. + * + * An instance of [MockResponse] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown MockResponse: $json") + } } - fun configurableClientsideAuthParams( - configurableClientsideAuthParams: List? - ) = - configurableClientsideAuthParams( - JsonField.ofNullable(configurableClientsideAuthParams) - ) + internal class Deserializer : BaseDeserializer(MockResponse::class) { - /** - * Alias for calling [Builder.configurableClientsideAuthParams] with - * `configurableClientsideAuthParams.orElse(null)`. - */ - fun configurableClientsideAuthParams( - configurableClientsideAuthParams: Optional> - ) = configurableClientsideAuthParams(configurableClientsideAuthParams.getOrNull()) + override fun ObjectCodec.deserialize(node: JsonNode): MockResponse { + val json = JsonValue.fromJsonNode(node) - /** - * Sets [Builder.configurableClientsideAuthParams] to an arbitrary JSON value. - * - * You should usually call [Builder.configurableClientsideAuthParams] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun configurableClientsideAuthParams( - configurableClientsideAuthParams: JsonField> - ) = apply { - this.configurableClientsideAuthParams = - configurableClientsideAuthParams.map { it.toMutableList() } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MockResponse(model = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MockResponse(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MockResponse(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants. + 0 -> MockResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - /** - * Adds a single [ConfigurableClientsideAuthParam] to - * [configurableClientsideAuthParams]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addConfigurableClientsideAuthParam( - configurableClientsideAuthParam: ConfigurableClientsideAuthParam - ) = apply { - configurableClientsideAuthParams = - (configurableClientsideAuthParams ?: JsonField.of(mutableListOf())).also { - checkKnown("configurableClientsideAuthParams", it) - .add(configurableClientsideAuthParam) + internal class Serializer : BaseSerializer(MockResponse::class) { + + override fun serialize( + value: MockResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.model != null -> generator.writeObject(value.model) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MockResponse") } + } } - /** - * Alias for calling [addConfigurableClientsideAuthParam] with - * `ConfigurableClientsideAuthParam.ofString(string)`. - */ - fun addConfigurableClientsideAuthParam(string: String) = - addConfigurableClientsideAuthParam(ConfigurableClientsideAuthParam.ofString(string)) + class ModelResponse + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val choices: JsonField>, + private val created: JsonField, + private val object_: JsonField, + private val model: JsonField, + private val systemFingerprint: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("choices") + @ExcludeMissing + choices: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("object") + @ExcludeMissing + object_: JsonField = JsonMissing.of(), + @JsonProperty("model") + @ExcludeMissing + model: JsonField = JsonMissing.of(), + @JsonProperty("system_fingerprint") + @ExcludeMissing + systemFingerprint: JsonField = JsonMissing.of(), + ) : this(id, choices, created, object_, model, systemFingerprint, mutableMapOf()) - /** - * Alias for calling [addConfigurableClientsideAuthParam] with - * `ConfigurableClientsideAuthParam.ofParamsCustomAuth(paramsCustomAuth)`. - */ - fun addConfigurableClientsideAuthParam( - paramsCustomAuth: ConfigurableClientsideParamsCustomAuth - ) = - addConfigurableClientsideAuthParam( - ConfigurableClientsideAuthParam.ofParamsCustomAuth(paramsCustomAuth) - ) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - fun customLlmProvider(customLlmProvider: String?) = - customLlmProvider(JsonField.ofNullable(customLlmProvider)) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun choices(): List = choices.getRequired("choices") - /** - * Alias for calling [Builder.customLlmProvider] with `customLlmProvider.orElse(null)`. - */ - fun customLlmProvider(customLlmProvider: Optional) = - customLlmProvider(customLlmProvider.getOrNull()) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun created(): Long = created.getRequired("created") - /** - * Sets [Builder.customLlmProvider] to an arbitrary JSON value. - * - * You should usually call [Builder.customLlmProvider] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customLlmProvider(customLlmProvider: JsonField) = apply { - this.customLlmProvider = customLlmProvider - } + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun object_(): String = object_.getRequired("object") - fun inputCostPerSecond(inputCostPerSecond: Double?) = - inputCostPerSecond(JsonField.ofNullable(inputCostPerSecond)) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") - /** - * Alias for [Builder.inputCostPerSecond]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun inputCostPerSecond(inputCostPerSecond: Double) = - inputCostPerSecond(inputCostPerSecond as Double?) + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun systemFingerprint(): Optional = + systemFingerprint.getOptional("system_fingerprint") - /** - * Alias for calling [Builder.inputCostPerSecond] with - * `inputCostPerSecond.orElse(null)`. - */ - fun inputCostPerSecond(inputCostPerSecond: Optional) = - inputCostPerSecond(inputCostPerSecond.getOrNull()) + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Sets [Builder.inputCostPerSecond] to an arbitrary JSON value. - * - * You should usually call [Builder.inputCostPerSecond] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputCostPerSecond(inputCostPerSecond: JsonField) = apply { - this.inputCostPerSecond = inputCostPerSecond - } + /** + * Returns the raw JSON value of [choices]. + * + * Unlike [choices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("choices") + @ExcludeMissing + fun _choices(): JsonField> = choices - fun inputCostPerToken(inputCostPerToken: Double?) = - inputCostPerToken(JsonField.ofNullable(inputCostPerToken)) + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** - * Alias for [Builder.inputCostPerToken]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun inputCostPerToken(inputCostPerToken: Double) = - inputCostPerToken(inputCostPerToken as Double?) + /** + * Returns the raw JSON value of [object_]. + * + * Unlike [object_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonField = object_ - /** - * Alias for calling [Builder.inputCostPerToken] with `inputCostPerToken.orElse(null)`. - */ - fun inputCostPerToken(inputCostPerToken: Optional) = - inputCostPerToken(inputCostPerToken.getOrNull()) + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - /** - * Sets [Builder.inputCostPerToken] to an arbitrary JSON value. - * - * You should usually call [Builder.inputCostPerToken] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputCostPerToken(inputCostPerToken: JsonField) = apply { - this.inputCostPerToken = inputCostPerToken - } + /** + * Returns the raw JSON value of [systemFingerprint]. + * + * Unlike [systemFingerprint], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("system_fingerprint") + @ExcludeMissing + fun _systemFingerprint(): JsonField = systemFingerprint - fun llmTraceId(llmTraceId: String?) = llmTraceId(JsonField.ofNullable(llmTraceId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.llmTraceId] with `llmTraceId.orElse(null)`. */ - fun llmTraceId(llmTraceId: Optional) = llmTraceId(llmTraceId.getOrNull()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ModelResponse]. + * + * The following fields are required: + * ```java + * .id() + * .choices() + * .created() + * .object_() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.llmTraceId] to an arbitrary JSON value. - * - * You should usually call [Builder.llmTraceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun llmTraceId(llmTraceId: JsonField) = apply { this.llmTraceId = llmTraceId } + /** A builder for [ModelResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var choices: JsonField>? = null + private var created: JsonField? = null + private var object_: JsonField? = null + private var model: JsonField = JsonMissing.of() + private var systemFingerprint: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(modelResponse: ModelResponse) = apply { + id = modelResponse.id + choices = modelResponse.choices.map { it.toMutableList() } + created = modelResponse.created + object_ = modelResponse.object_ + model = modelResponse.model + systemFingerprint = modelResponse.systemFingerprint + additionalProperties = modelResponse.additionalProperties.toMutableMap() + } - fun maxBudget(maxBudget: Double?) = maxBudget(JsonField.ofNullable(maxBudget)) + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun choices(choices: List) = choices(JsonField.of(choices)) + + /** + * Sets [Builder.choices] to an arbitrary JSON value. + * + * You should usually call [Builder.choices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun choices(choices: JsonField>) = apply { + this.choices = choices.map { it.toMutableList() } + } - /** - * Alias for [Builder.maxBudget]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxBudget(maxBudget: Double) = maxBudget(maxBudget as Double?) + /** + * Adds a single [Choice] to [choices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChoice(choice: Choice) = apply { + choices = + (choices ?: JsonField.of(mutableListOf())).also { + checkKnown("choices", it).add(choice) + } + } - /** Alias for calling [Builder.maxBudget] with `maxBudget.orElse(null)`. */ - fun maxBudget(maxBudget: Optional) = maxBudget(maxBudget.getOrNull()) + /** Alias for calling [addChoice] with `Choice.ofChoices(choices)`. */ + fun addChoice(choices: Choice.Choices) = addChoice(Choice.ofChoices(choices)) + + /** + * Alias for calling [addChoice] with + * `Choice.ofStreamingChoices(streamingChoices)`. + */ + fun addChoice(streamingChoices: Choice.StreamingChoices) = + addChoice(Choice.ofStreamingChoices(streamingChoices)) + + fun created(created: Long) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun object_(object_: String) = object_(JsonField.of(object_)) + + /** + * Sets [Builder.object_] to an arbitrary JSON value. + * + * You should usually call [Builder.object_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun object_(object_: JsonField) = apply { this.object_ = object_ } + + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + fun systemFingerprint(systemFingerprint: String?) = + systemFingerprint(JsonField.ofNullable(systemFingerprint)) + + /** + * Alias for calling [Builder.systemFingerprint] with + * `systemFingerprint.orElse(null)`. + */ + fun systemFingerprint(systemFingerprint: Optional) = + systemFingerprint(systemFingerprint.getOrNull()) + + /** + * Sets [Builder.systemFingerprint] to an arbitrary JSON value. + * + * You should usually call [Builder.systemFingerprint] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun systemFingerprint(systemFingerprint: JsonField) = apply { + this.systemFingerprint = systemFingerprint + } - /** - * Sets [Builder.maxBudget] to an arbitrary JSON value. - * - * You should usually call [Builder.maxBudget] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxBudget(maxBudget: JsonField) = apply { this.maxBudget = maxBudget } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun maxFileSizeMb(maxFileSizeMb: Double?) = - maxFileSizeMb(JsonField.ofNullable(maxFileSizeMb)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for [Builder.maxFileSizeMb]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxFileSizeMb(maxFileSizeMb: Double) = maxFileSizeMb(maxFileSizeMb as Double?) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [Builder.maxFileSizeMb] with `maxFileSizeMb.orElse(null)`. */ - fun maxFileSizeMb(maxFileSizeMb: Optional) = - maxFileSizeMb(maxFileSizeMb.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.maxFileSizeMb] to an arbitrary JSON value. - * - * You should usually call [Builder.maxFileSizeMb] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxFileSizeMb(maxFileSizeMb: JsonField) = apply { - this.maxFileSizeMb = maxFileSizeMb - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun maxRetries(maxRetries: Long?) = maxRetries(JsonField.ofNullable(maxRetries)) + /** + * Returns an immutable instance of [ModelResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .choices() + * .created() + * .object_() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ModelResponse = + ModelResponse( + checkRequired("id", id), + checkRequired("choices", choices).map { it.toImmutable() }, + checkRequired("created", created), + checkRequired("object_", object_), + model, + systemFingerprint, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for [Builder.maxRetries]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxRetries(maxRetries: Long) = maxRetries(maxRetries as Long?) + private var validated: Boolean = false - /** Alias for calling [Builder.maxRetries] with `maxRetries.orElse(null)`. */ - fun maxRetries(maxRetries: Optional) = maxRetries(maxRetries.getOrNull()) + fun validate(): ModelResponse = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.maxRetries] to an arbitrary JSON value. - * - * You should usually call [Builder.maxRetries] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxRetries(maxRetries: JsonField) = apply { this.maxRetries = maxRetries } + id() + choices().forEach { it.validate() } + created() + object_() + model() + systemFingerprint() + validated = true + } - fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: Boolean?) = - mergeReasoningContentInChoices(JsonField.ofNullable(mergeReasoningContentInChoices)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } - /** - * Alias for [Builder.mergeReasoningContentInChoices]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: Boolean) = - mergeReasoningContentInChoices(mergeReasoningContentInChoices as Boolean?) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (choices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (object_.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (systemFingerprint.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Choice.Deserializer::class) + @JsonSerialize(using = Choice.Serializer::class) + class Choice + private constructor( + private val choices: Choices? = null, + private val streamingChoices: StreamingChoices? = null, + private val _json: JsonValue? = null, + ) { - /** - * Alias for calling [Builder.mergeReasoningContentInChoices] with - * `mergeReasoningContentInChoices.orElse(null)`. - */ - fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: Optional) = - mergeReasoningContentInChoices(mergeReasoningContentInChoices.getOrNull()) + fun choices(): Optional = Optional.ofNullable(choices) - /** - * Sets [Builder.mergeReasoningContentInChoices] to an arbitrary JSON value. - * - * You should usually call [Builder.mergeReasoningContentInChoices] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun mergeReasoningContentInChoices(mergeReasoningContentInChoices: JsonField) = - apply { - this.mergeReasoningContentInChoices = mergeReasoningContentInChoices - } + fun streamingChoices(): Optional = + Optional.ofNullable(streamingChoices) + + fun isChoices(): Boolean = choices != null + + fun isStreamingChoices(): Boolean = streamingChoices != null + + fun asChoices(): Choices = choices.getOrThrow("choices") + + fun asStreamingChoices(): StreamingChoices = + streamingChoices.getOrThrow("streamingChoices") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + choices != null -> visitor.visitChoices(choices) + streamingChoices != null -> + visitor.visitStreamingChoices(streamingChoices) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false - fun modelInfo(modelInfo: JsonValue) = apply { this.modelInfo = modelInfo } + fun validate(): Choice = apply { + if (validated) { + return@apply + } - fun organization(organization: String?) = - organization(JsonField.ofNullable(organization)) + accept( + object : Visitor { + override fun visitChoices(choices: Choices) { + choices.validate() + } + + override fun visitStreamingChoices( + streamingChoices: StreamingChoices + ) { + streamingChoices.validate() + } + } + ) + validated = true + } - /** Alias for calling [Builder.organization] with `organization.orElse(null)`. */ - fun organization(organization: Optional) = - organization(organization.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } - /** - * Sets [Builder.organization] to an arbitrary JSON value. - * - * You should usually call [Builder.organization] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun organization(organization: JsonField) = apply { - this.organization = organization - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitChoices(choices: Choices) = choices.validity() + + override fun visitStreamingChoices( + streamingChoices: StreamingChoices + ) = streamingChoices.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun outputCostPerSecond(outputCostPerSecond: Double?) = - outputCostPerSecond(JsonField.ofNullable(outputCostPerSecond)) + return other is Choice && + choices == other.choices && + streamingChoices == other.streamingChoices + } - /** - * Alias for [Builder.outputCostPerSecond]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outputCostPerSecond(outputCostPerSecond: Double) = - outputCostPerSecond(outputCostPerSecond as Double?) + override fun hashCode(): Int = Objects.hash(choices, streamingChoices) - /** - * Alias for calling [Builder.outputCostPerSecond] with - * `outputCostPerSecond.orElse(null)`. - */ - fun outputCostPerSecond(outputCostPerSecond: Optional) = - outputCostPerSecond(outputCostPerSecond.getOrNull()) + override fun toString(): String = + when { + choices != null -> "Choice{choices=$choices}" + streamingChoices != null -> "Choice{streamingChoices=$streamingChoices}" + _json != null -> "Choice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Choice") + } - /** - * Sets [Builder.outputCostPerSecond] to an arbitrary JSON value. - * - * You should usually call [Builder.outputCostPerSecond] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun outputCostPerSecond(outputCostPerSecond: JsonField) = apply { - this.outputCostPerSecond = outputCostPerSecond - } + companion object { - fun outputCostPerToken(outputCostPerToken: Double?) = - outputCostPerToken(JsonField.ofNullable(outputCostPerToken)) + @JvmStatic fun ofChoices(choices: Choices) = Choice(choices = choices) - /** - * Alias for [Builder.outputCostPerToken]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outputCostPerToken(outputCostPerToken: Double) = - outputCostPerToken(outputCostPerToken as Double?) + @JvmStatic + fun ofStreamingChoices(streamingChoices: StreamingChoices) = + Choice(streamingChoices = streamingChoices) + } - /** - * Alias for calling [Builder.outputCostPerToken] with - * `outputCostPerToken.orElse(null)`. - */ - fun outputCostPerToken(outputCostPerToken: Optional) = - outputCostPerToken(outputCostPerToken.getOrNull()) + /** + * An interface that defines how to map each variant of [Choice] to a value of + * type [T]. + */ + interface Visitor { + + fun visitChoices(choices: Choices): T + + fun visitStreamingChoices(streamingChoices: StreamingChoices): T + + /** + * Maps an unknown variant of [Choice] to a value of type [T]. + * + * An instance of [Choice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws HanzoInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw HanzoInvalidDataException("Unknown Choice: $json") + } + } - /** - * Sets [Builder.outputCostPerToken] to an arbitrary JSON value. - * - * You should usually call [Builder.outputCostPerToken] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun outputCostPerToken(outputCostPerToken: JsonField) = apply { - this.outputCostPerToken = outputCostPerToken - } + internal class Deserializer : BaseDeserializer(Choice::class) { - fun regionName(regionName: String?) = regionName(JsonField.ofNullable(regionName)) + override fun ObjectCodec.deserialize(node: JsonNode): Choice { + val json = JsonValue.fromJsonNode(node) - /** Alias for calling [Builder.regionName] with `regionName.orElse(null)`. */ - fun regionName(regionName: Optional) = regionName(regionName.getOrNull()) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Choice(choices = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Choice(streamingChoices = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from boolean). + 0 -> Choice(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - /** - * Sets [Builder.regionName] to an arbitrary JSON value. - * - * You should usually call [Builder.regionName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun regionName(regionName: JsonField) = apply { this.regionName = regionName } + internal class Serializer : BaseSerializer(Choice::class) { - fun rpm(rpm: Long?) = rpm(JsonField.ofNullable(rpm)) + override fun serialize( + value: Choice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.choices != null -> generator.writeObject(value.choices) + value.streamingChoices != null -> + generator.writeObject(value.streamingChoices) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Choice") + } + } + } - /** - * Alias for [Builder.rpm]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rpm(rpm: Long) = rpm(rpm as Long?) + class Choices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val finishReason: JsonField, + private val index: JsonField, + private val message: JsonField, + private val logprobs: JsonField, + private val providerSpecificFields: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("finish_reason") + @ExcludeMissing + finishReason: JsonField = JsonMissing.of(), + @JsonProperty("index") + @ExcludeMissing + index: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("logprobs") + @ExcludeMissing + logprobs: JsonField = JsonMissing.of(), + @JsonProperty("provider_specific_fields") + @ExcludeMissing + providerSpecificFields: JsonField = + JsonMissing.of(), + ) : this( + finishReason, + index, + message, + logprobs, + providerSpecificFields, + mutableMapOf(), + ) + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun finishReason(): String = finishReason.getRequired("finish_reason") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun index(): Long = index.getRequired("index") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun logprobs(): Optional = logprobs.getOptional("logprobs") + + /** + * @throws HanzoInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun providerSpecificFields(): Optional = + providerSpecificFields.getOptional("provider_specific_fields") + + /** + * Returns the raw JSON value of [finishReason]. + * + * Unlike [finishReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("finish_reason") + @ExcludeMissing + fun _finishReason(): JsonField = finishReason + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("message") + @ExcludeMissing + fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [logprobs]. + * + * Unlike [logprobs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("logprobs") + @ExcludeMissing + fun _logprobs(): JsonField = logprobs + + /** + * Returns the raw JSON value of [providerSpecificFields]. + * + * Unlike [providerSpecificFields], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("provider_specific_fields") + @ExcludeMissing + fun _providerSpecificFields(): JsonField = + providerSpecificFields + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.rpm] with `rpm.orElse(null)`. */ - fun rpm(rpm: Optional) = rpm(rpm.getOrNull()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Choices]. + * + * The following fields are required: + * ```java + * .finishReason() + * .index() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.rpm] to an arbitrary JSON value. - * - * You should usually call [Builder.rpm] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun rpm(rpm: JsonField) = apply { this.rpm = rpm } + /** A builder for [Choices]. */ + class Builder internal constructor() { + + private var finishReason: JsonField? = null + private var index: JsonField? = null + private var message: JsonField? = null + private var logprobs: JsonField = JsonMissing.of() + private var providerSpecificFields: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(choices: Choices) = apply { + finishReason = choices.finishReason + index = choices.index + message = choices.message + logprobs = choices.logprobs + providerSpecificFields = choices.providerSpecificFields + additionalProperties = choices.additionalProperties.toMutableMap() + } + + fun finishReason(finishReason: String) = + finishReason(JsonField.of(finishReason)) + + /** + * Sets [Builder.finishReason] to an arbitrary JSON value. + * + * You should usually call [Builder.finishReason] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun finishReason(finishReason: JsonField) = apply { + this.finishReason = finishReason + } + + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { + this.message = message + } + + fun logprobs(logprobs: Logprobs?) = + logprobs(JsonField.ofNullable(logprobs)) + + /** + * Alias for calling [Builder.logprobs] with `logprobs.orElse(null)`. + */ + fun logprobs(logprobs: Optional) = + logprobs(logprobs.getOrNull()) + + /** + * Sets [Builder.logprobs] to an arbitrary JSON value. + * + * You should usually call [Builder.logprobs] with a well-typed + * [Logprobs] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun logprobs(logprobs: JsonField) = apply { + this.logprobs = logprobs + } + + /** Alias for calling [logprobs] with `Logprobs.ofChoice(choice)`. */ + fun logprobs(choice: Logprobs.ChoiceLogprobs) = + logprobs(Logprobs.ofChoice(choice)) + + /** + * Alias for calling [logprobs] with `Logprobs.ofJsonValue(jsonValue)`. + */ + fun logprobs(jsonValue: JsonValue) = + logprobs(Logprobs.ofJsonValue(jsonValue)) + + fun providerSpecificFields( + providerSpecificFields: ProviderSpecificFields? + ) = providerSpecificFields(JsonField.ofNullable(providerSpecificFields)) + + /** + * Alias for calling [Builder.providerSpecificFields] with + * `providerSpecificFields.orElse(null)`. + */ + fun providerSpecificFields( + providerSpecificFields: Optional + ) = providerSpecificFields(providerSpecificFields.getOrNull()) + + /** + * Sets [Builder.providerSpecificFields] to an arbitrary JSON value. + * + * You should usually call [Builder.providerSpecificFields] with a + * well-typed [ProviderSpecificFields] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun providerSpecificFields( + providerSpecificFields: JsonField + ) = apply { this.providerSpecificFields = providerSpecificFields } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Choices]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .finishReason() + * .index() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Choices = + Choices( + checkRequired("finishReason", finishReason), + checkRequired("index", index), + checkRequired("message", message), + logprobs, + providerSpecificFields, + additionalProperties.toMutableMap(), + ) + } - fun streamTimeout(streamTimeout: StreamTimeout?) = - streamTimeout(JsonField.ofNullable(streamTimeout)) + private var validated: Boolean = false - /** Alias for calling [Builder.streamTimeout] with `streamTimeout.orElse(null)`. */ - fun streamTimeout(streamTimeout: Optional) = - streamTimeout(streamTimeout.getOrNull()) + fun validate(): Choices = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.streamTimeout] to an arbitrary JSON value. - * - * You should usually call [Builder.streamTimeout] with a well-typed [StreamTimeout] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun streamTimeout(streamTimeout: JsonField) = apply { - this.streamTimeout = streamTimeout - } + finishReason() + index() + message().validate() + logprobs().ifPresent { it.validate() } + providerSpecificFields().ifPresent { it.validate() } + validated = true + } - /** Alias for calling [streamTimeout] with `StreamTimeout.ofNumber(number)`. */ - fun streamTimeout(number: Double) = streamTimeout(StreamTimeout.ofNumber(number)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: HanzoInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (finishReason.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (message.asKnown().getOrNull()?.validity() ?: 0) + + (logprobs.asKnown().getOrNull()?.validity() ?: 0) + + (providerSpecificFields.asKnown().getOrNull()?.validity() ?: 0) + + class Message + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val functionCall: JsonField, + private val role: JsonField, + private val toolCalls: JsonField>, + private val annotations: JsonField>, + private val audio: JsonField