diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 0000000..dce5b21 --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,41 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/zavudev/sdk-java/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Java + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 + + - name: Publish to Sonatype + run: |- + 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 publish --no-configuration-cache + env: + SONATYPE_USERNAME: ${{ secrets.ZAVUDEV_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.ZAVUDEV_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.ZAVUDEV_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.ZAVUDEV_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 0000000..61375ab --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,24 @@ +name: Release Doctor +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'zavudev/sdk-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + SONATYPE_USERNAME: ${{ secrets.ZAVUDEV_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.ZAVUDEV_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.ZAVUDEV_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.ZAVUDEV_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..3d2ac0b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 8413cc3..d9f73e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 138 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-fa2ec1f359f9ed18ba4e00d8d1edb2a10a50c02b4efd9f20736cedbefb39cc47.yml -openapi_spec_hash: 6b119a3213e324f3826453deca57f10b -config_hash: d5d02dfde2ea057fdcf5b26e3a921f7a +configured_endpoints: 183 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-fc96dae99e9649b4cfb99002b7dfee6480114b8dda4ff136541533c9c9069118.yml +openapi_spec_hash: 3c2c8da8c73cdd7e656b7f2c06cc01b4 +config_hash: 261e1b852ca7f8364e4a283a3edd350a diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..745f5cf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# Changelog + +## 0.1.0 (2026-08-31) + +Full Changelog: [v0.0.1...v0.1.0](https://github.com/zavudev/sdk-java/compare/v0.0.1...v0.1.0) + +### Features + +* **api:** api update ([b71003b](https://github.com/zavudev/sdk-java/commit/b71003be390baf70bb60e2c5692d0c7a2789acab)) +* **api:** api update ([331171f](https://github.com/zavudev/sdk-java/commit/331171f3c7fb8fba3c39663fadc8381283aa9de0)) +* **api:** api update ([f2f6b70](https://github.com/zavudev/sdk-java/commit/f2f6b7012c693ffbea5e1050451393279033ba98)) +* **api:** api update ([cc0ce4d](https://github.com/zavudev/sdk-java/commit/cc0ce4dadf0b72694a509e03591a5663aa2190e9)) +* **api:** api update ([88a8d12](https://github.com/zavudev/sdk-java/commit/88a8d12250ab108356b560b5e529b3c43da5e451)) +* **api:** api update ([5e3cf0f](https://github.com/zavudev/sdk-java/commit/5e3cf0f493d13c979c52a426e845d6713401601d)) +* **api:** api update ([097cfec](https://github.com/zavudev/sdk-java/commit/097cfec6842059736cb8e46fa21cfcfb85485867)) +* **api:** api update ([cf7c412](https://github.com/zavudev/sdk-java/commit/cf7c41255bc4ad349e9111c1abbde0b72a60539f)) +* **api:** api update ([e8dd549](https://github.com/zavudev/sdk-java/commit/e8dd549d4143f5b52c9382e556e13df063a596cc)) +* **api:** manual updates ([2299c46](https://github.com/zavudev/sdk-java/commit/2299c467566b3c253997cfdf40486c7215e24d02)) + + +### Bug Fixes + +* **docs:** link the javadoc badge so the version stays current after release ([565c2f3](https://github.com/zavudev/sdk-java/commit/565c2f36ad9cb5b2b66e0681938781d45c2f9cda)) + + +### Chores + +* configure new SDK language ([ddad6b8](https://github.com/zavudev/sdk-java/commit/ddad6b81b9625c9e4afa635d3768ac15095e2dd7)) +* **internal:** codegen related update ([a9d330b](https://github.com/zavudev/sdk-java/commit/a9d330b32f9f8fafb135ea832219f65f119c69ec)) +* update SDK settings ([97e8950](https://github.com/zavudev/sdk-java/commit/97e8950d08e11209793497c6b202276c53f0f763)) diff --git a/README.md b/README.md index 506deb7..d80a923 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # Zavudev Java API Library -[![Maven Central](https://img.shields.io/maven-central/v/com.zavudev.api/zavudev-java)](https://central.sonatype.com/artifact/com.zavudev.api/zavudev-java/0.0.1) -[![javadoc](https://javadoc.io/badge2/com.zavudev.api/zavudev-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.zavudev.api/zavudev-java/0.0.1) + + +[![Maven Central](https://img.shields.io/maven-central/v/com.zavudev.api/zavudev-java)](https://central.sonatype.com/artifact/com.zavudev.api/zavudev-java/0.1.0) +[![javadoc](https://javadoc.io/badge2/com.zavudev.api/zavudev-java/javadoc.svg)](https://javadoc.io/doc/com.zavudev.api/zavudev-java/0.1.0) + + The Zavudev Java SDK provides convenient access to the [Zavudev REST API](https://docs.zavu.dev) from applications written in Java. @@ -16,14 +20,20 @@ Use the Zavudev MCP Server to enable AI assistants to interact with this API, al > Note: You may need to set environment variables in your MCP client. -The REST API documentation can be found on [docs.zavu.dev](https://docs.zavu.dev). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.zavudev.api/zavudev-java/0.0.1). + + +The REST API documentation can be found on [docs.zavu.dev](https://docs.zavu.dev). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.zavudev.api/zavudev-java/0.1.0). + + ## Installation + + ### Gradle ```kotlin -implementation("com.zavudev.api:zavudev-java:0.0.1") +implementation("com.zavudev.api:zavudev-java:0.1.0") ``` ### Maven @@ -32,10 +42,12 @@ implementation("com.zavudev.api:zavudev-java:0.0.1") com.zavudev.api zavudev-java - 0.0.1 + 0.1.0 ``` + + ## Requirements This library requires Java 8 or later. @@ -781,4 +793,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/zavudev-java/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/zavudev/sdk-java/issues) with questions, bugs, or suggestions. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 0000000..3a6a7b4 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + 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 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 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 GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index 0621193..eeed2ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.zavudev.api" - version = "0.0.1" + version = "0.1.0" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/zavudev.publish.gradle.kts b/buildSrc/src/main/kotlin/zavudev.publish.gradle.kts index 0931234..ad77e8e 100644 --- a/buildSrc/src/main/kotlin/zavudev.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/zavudev.publish.gradle.kts @@ -27,9 +27,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/stainless-sdks/zavudev-java.git") - developerConnection.set("scm:git:git://github.com/stainless-sdks/zavudev-java.git") - url.set("https://github.com/stainless-sdks/zavudev-java") + connection.set("scm:git:git://github.com/zavudev/sdk-java.git") + developerConnection.set("scm:git:git://github.com/zavudev/sdk-java.git") + url.set("https://github.com/zavudev/sdk-java") } versionMapping { diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..8f98719 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file diff --git a/zavudev-java-core/build.gradle.kts b/zavudev-java-core/build.gradle.kts index 689e701..1df2b92 100644 --- a/zavudev-java-core/build.gradle.kts +++ b/zavudev-java-core/build.gradle.kts @@ -38,4 +38,5 @@ dependencies { 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") + testImplementation("org.slf4j:slf4j-nop:1.7.36") } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClient.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClient.kt index b11d1dc..bc7666c 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClient.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClient.kt @@ -4,9 +4,14 @@ package com.zavudev.api.client import com.zavudev.api.core.ClientOptions import com.zavudev.api.services.blocking.AddressService +import com.zavudev.api.services.blocking.AgentService +import com.zavudev.api.services.blocking.AgentTemplateService import com.zavudev.api.services.blocking.BalanceService import com.zavudev.api.services.blocking.BroadcastService +import com.zavudev.api.services.blocking.CallService import com.zavudev.api.services.blocking.ContactService +import com.zavudev.api.services.blocking.ConversationService +import com.zavudev.api.services.blocking.EmailDomainService import com.zavudev.api.services.blocking.FunctionService import com.zavudev.api.services.blocking.IntrospectService import com.zavudev.api.services.blocking.InvitationService @@ -89,6 +94,16 @@ interface ZavudevClient { fun functions(): FunctionService + fun conversations(): ConversationService + + fun calls(): CallService + + fun agentTemplates(): AgentTemplateService + + fun emailDomains(): EmailDomainService + + fun agents(): AgentService + /** * Closes this client, relinquishing any underlying resources. * @@ -143,5 +158,15 @@ interface ZavudevClient { fun me(): MeService.WithRawResponse fun functions(): FunctionService.WithRawResponse + + fun conversations(): ConversationService.WithRawResponse + + fun calls(): CallService.WithRawResponse + + fun agentTemplates(): AgentTemplateService.WithRawResponse + + fun emailDomains(): EmailDomainService.WithRawResponse + + fun agents(): AgentService.WithRawResponse } } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsync.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsync.kt index da62da0..7a2db54 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsync.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsync.kt @@ -4,9 +4,14 @@ package com.zavudev.api.client import com.zavudev.api.core.ClientOptions import com.zavudev.api.services.async.AddressServiceAsync +import com.zavudev.api.services.async.AgentServiceAsync +import com.zavudev.api.services.async.AgentTemplateServiceAsync import com.zavudev.api.services.async.BalanceServiceAsync import com.zavudev.api.services.async.BroadcastServiceAsync +import com.zavudev.api.services.async.CallServiceAsync import com.zavudev.api.services.async.ContactServiceAsync +import com.zavudev.api.services.async.ConversationServiceAsync +import com.zavudev.api.services.async.EmailDomainServiceAsync import com.zavudev.api.services.async.FunctionServiceAsync import com.zavudev.api.services.async.IntrospectServiceAsync import com.zavudev.api.services.async.InvitationServiceAsync @@ -89,6 +94,16 @@ interface ZavudevClientAsync { fun functions(): FunctionServiceAsync + fun conversations(): ConversationServiceAsync + + fun calls(): CallServiceAsync + + fun agentTemplates(): AgentTemplateServiceAsync + + fun emailDomains(): EmailDomainServiceAsync + + fun agents(): AgentServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -147,5 +162,15 @@ interface ZavudevClientAsync { fun me(): MeServiceAsync.WithRawResponse fun functions(): FunctionServiceAsync.WithRawResponse + + fun conversations(): ConversationServiceAsync.WithRawResponse + + fun calls(): CallServiceAsync.WithRawResponse + + fun agentTemplates(): AgentTemplateServiceAsync.WithRawResponse + + fun emailDomains(): EmailDomainServiceAsync.WithRawResponse + + fun agents(): AgentServiceAsync.WithRawResponse } } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsyncImpl.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsyncImpl.kt index d63c125..f3e4715 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsyncImpl.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientAsyncImpl.kt @@ -6,12 +6,22 @@ import com.zavudev.api.core.ClientOptions import com.zavudev.api.core.getPackageVersion import com.zavudev.api.services.async.AddressServiceAsync import com.zavudev.api.services.async.AddressServiceAsyncImpl +import com.zavudev.api.services.async.AgentServiceAsync +import com.zavudev.api.services.async.AgentServiceAsyncImpl +import com.zavudev.api.services.async.AgentTemplateServiceAsync +import com.zavudev.api.services.async.AgentTemplateServiceAsyncImpl import com.zavudev.api.services.async.BalanceServiceAsync import com.zavudev.api.services.async.BalanceServiceAsyncImpl import com.zavudev.api.services.async.BroadcastServiceAsync import com.zavudev.api.services.async.BroadcastServiceAsyncImpl +import com.zavudev.api.services.async.CallServiceAsync +import com.zavudev.api.services.async.CallServiceAsyncImpl import com.zavudev.api.services.async.ContactServiceAsync import com.zavudev.api.services.async.ContactServiceAsyncImpl +import com.zavudev.api.services.async.ConversationServiceAsync +import com.zavudev.api.services.async.ConversationServiceAsyncImpl +import com.zavudev.api.services.async.EmailDomainServiceAsync +import com.zavudev.api.services.async.EmailDomainServiceAsyncImpl import com.zavudev.api.services.async.FunctionServiceAsync import com.zavudev.api.services.async.FunctionServiceAsyncImpl import com.zavudev.api.services.async.IntrospectServiceAsync @@ -115,6 +125,24 @@ class ZavudevClientAsyncImpl(private val clientOptions: ClientOptions) : Zavudev FunctionServiceAsyncImpl(clientOptionsWithUserAgent) } + private val conversations: ConversationServiceAsync by lazy { + ConversationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val calls: CallServiceAsync by lazy { CallServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val agentTemplates: AgentTemplateServiceAsync by lazy { + AgentTemplateServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val emailDomains: EmailDomainServiceAsync by lazy { + EmailDomainServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val agents: AgentServiceAsync by lazy { + AgentServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): ZavudevClient = sync override fun withRawResponse(): ZavudevClientAsync.WithRawResponse = withRawResponse @@ -154,6 +182,16 @@ class ZavudevClientAsyncImpl(private val clientOptions: ClientOptions) : Zavudev override fun functions(): FunctionServiceAsync = functions + override fun conversations(): ConversationServiceAsync = conversations + + override fun calls(): CallServiceAsync = calls + + override fun agentTemplates(): AgentTemplateServiceAsync = agentTemplates + + override fun emailDomains(): EmailDomainServiceAsync = emailDomains + + override fun agents(): AgentServiceAsync = agents + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -223,6 +261,26 @@ class ZavudevClientAsyncImpl(private val clientOptions: ClientOptions) : Zavudev FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val conversations: ConversationServiceAsync.WithRawResponse by lazy { + ConversationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val calls: CallServiceAsync.WithRawResponse by lazy { + CallServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val agentTemplates: AgentTemplateServiceAsync.WithRawResponse by lazy { + AgentTemplateServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val emailDomains: EmailDomainServiceAsync.WithRawResponse by lazy { + EmailDomainServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val agents: AgentServiceAsync.WithRawResponse by lazy { + AgentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): ZavudevClientAsync.WithRawResponse = @@ -262,5 +320,15 @@ class ZavudevClientAsyncImpl(private val clientOptions: ClientOptions) : Zavudev override fun me(): MeServiceAsync.WithRawResponse = me override fun functions(): FunctionServiceAsync.WithRawResponse = functions + + override fun conversations(): ConversationServiceAsync.WithRawResponse = conversations + + override fun calls(): CallServiceAsync.WithRawResponse = calls + + override fun agentTemplates(): AgentTemplateServiceAsync.WithRawResponse = agentTemplates + + override fun emailDomains(): EmailDomainServiceAsync.WithRawResponse = emailDomains + + override fun agents(): AgentServiceAsync.WithRawResponse = agents } } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientImpl.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientImpl.kt index bd9983c..81d8a02 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientImpl.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/client/ZavudevClientImpl.kt @@ -6,12 +6,22 @@ import com.zavudev.api.core.ClientOptions import com.zavudev.api.core.getPackageVersion import com.zavudev.api.services.blocking.AddressService import com.zavudev.api.services.blocking.AddressServiceImpl +import com.zavudev.api.services.blocking.AgentService +import com.zavudev.api.services.blocking.AgentServiceImpl +import com.zavudev.api.services.blocking.AgentTemplateService +import com.zavudev.api.services.blocking.AgentTemplateServiceImpl import com.zavudev.api.services.blocking.BalanceService import com.zavudev.api.services.blocking.BalanceServiceImpl import com.zavudev.api.services.blocking.BroadcastService import com.zavudev.api.services.blocking.BroadcastServiceImpl +import com.zavudev.api.services.blocking.CallService +import com.zavudev.api.services.blocking.CallServiceImpl import com.zavudev.api.services.blocking.ContactService import com.zavudev.api.services.blocking.ContactServiceImpl +import com.zavudev.api.services.blocking.ConversationService +import com.zavudev.api.services.blocking.ConversationServiceImpl +import com.zavudev.api.services.blocking.EmailDomainService +import com.zavudev.api.services.blocking.EmailDomainServiceImpl import com.zavudev.api.services.blocking.FunctionService import com.zavudev.api.services.blocking.FunctionServiceImpl import com.zavudev.api.services.blocking.IntrospectService @@ -105,6 +115,22 @@ class ZavudevClientImpl(private val clientOptions: ClientOptions) : ZavudevClien FunctionServiceImpl(clientOptionsWithUserAgent) } + private val conversations: ConversationService by lazy { + ConversationServiceImpl(clientOptionsWithUserAgent) + } + + private val calls: CallService by lazy { CallServiceImpl(clientOptionsWithUserAgent) } + + private val agentTemplates: AgentTemplateService by lazy { + AgentTemplateServiceImpl(clientOptionsWithUserAgent) + } + + private val emailDomains: EmailDomainService by lazy { + EmailDomainServiceImpl(clientOptionsWithUserAgent) + } + + private val agents: AgentService by lazy { AgentServiceImpl(clientOptionsWithUserAgent) } + override fun async(): ZavudevClientAsync = async override fun withRawResponse(): ZavudevClient.WithRawResponse = withRawResponse @@ -144,6 +170,16 @@ class ZavudevClientImpl(private val clientOptions: ClientOptions) : ZavudevClien override fun functions(): FunctionService = functions + override fun conversations(): ConversationService = conversations + + override fun calls(): CallService = calls + + override fun agentTemplates(): AgentTemplateService = agentTemplates + + override fun emailDomains(): EmailDomainService = emailDomains + + override fun agents(): AgentService = agents + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -213,6 +249,26 @@ class ZavudevClientImpl(private val clientOptions: ClientOptions) : ZavudevClien FunctionServiceImpl.WithRawResponseImpl(clientOptions) } + private val conversations: ConversationService.WithRawResponse by lazy { + ConversationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val calls: CallService.WithRawResponse by lazy { + CallServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val agentTemplates: AgentTemplateService.WithRawResponse by lazy { + AgentTemplateServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val emailDomains: EmailDomainService.WithRawResponse by lazy { + EmailDomainServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val agents: AgentService.WithRawResponse by lazy { + AgentServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): ZavudevClient.WithRawResponse = @@ -252,5 +308,15 @@ class ZavudevClientImpl(private val clientOptions: ClientOptions) : ZavudevClien override fun me(): MeService.WithRawResponse = me override fun functions(): FunctionService.WithRawResponse = functions + + override fun conversations(): ConversationService.WithRawResponse = conversations + + override fun calls(): CallService.WithRawResponse = calls + + override fun agentTemplates(): AgentTemplateService.WithRawResponse = agentTemplates + + override fun emailDomains(): EmailDomainService.WithRawResponse = emailDomains + + override fun agents(): AgentService.WithRawResponse = agents } } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/core/Check.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/core/Check.kt index d9530a7..587d1b6 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/core/Check.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/core/Check.kt @@ -77,7 +77,7 @@ This can happen if you are either: Double-check that you are depending on compatible Jackson versions. -See https://www.github.com/stainless-sdks/zavudev-java#jackson for more information. +See https://www.github.com/zavudev/sdk-java#jackson for more information. """ .trimIndent() } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateParams.kt new file mode 100644 index 0000000..4b16bea --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateParams.kt @@ -0,0 +1,2366 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.Enum +import com.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.Params +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.AgentProvider +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Create an agent without a sender. It is created disabled; connect a sender and enable it when you + * are ready for it to answer. + * + * **Sub-resources.** An agent's tools, flows and knowledge bases are reachable at + * `/v1/agents/{agentId}/tools`, `/v1/agents/{agentId}/flows` and + * `/v1/agents/{agentId}/knowledge-bases`, mirroring the sender-scoped routes documented under + * `/v1/senders/{senderId}/agent/...` exactly. Use the agent-scoped form while the agent has no + * sender: the sender-scoped one cannot address it. + */ +class AgentCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws ZavudevInvalidDataException 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 ZavudevInvalidDataException 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 = body.name() + + /** + * LLM provider for the AI agent. + * + * @throws ZavudevInvalidDataException 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 provider(): AgentProvider = body.provider() + + /** + * @throws ZavudevInvalidDataException 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 systemPrompt(): String = body.systemPrompt() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowMessages(): Optional = body.contextWindowMessages() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeContactMetadata(): Optional = body.includeContactMetadata() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = body.maxTokens() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = body.temperature() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnChannels(): Optional> = body.triggerOnChannels() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnMessageTypes(): Optional> = body.triggerOnMessageTypes() + + /** + * Voice Agent configuration on a sender's AI agent. Controls how the agent behaves on inbound + * and outbound phone calls through Zavu's managed voice pipeline (speech recognition, the + * agent's LLM, and speech synthesis, with real-time interruption handling). Requires the Voice + * Agents feature to be enabled for your team. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voice(): Optional = body.voice() + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _provider(): JsonField = body._provider() + + /** + * Returns the raw JSON value of [systemPrompt]. + * + * Unlike [systemPrompt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _systemPrompt(): JsonField = body._systemPrompt() + + /** + * Returns the raw JSON value of [contextWindowMessages]. + * + * Unlike [contextWindowMessages], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _contextWindowMessages(): JsonField = body._contextWindowMessages() + + /** + * Returns the raw JSON value of [includeContactMetadata]. + * + * Unlike [includeContactMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _includeContactMetadata(): JsonField = body._includeContactMetadata() + + /** + * 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 [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 [triggerOnChannels]. + * + * Unlike [triggerOnChannels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _triggerOnChannels(): JsonField> = body._triggerOnChannels() + + /** + * Returns the raw JSON value of [triggerOnMessageTypes]. + * + * Unlike [triggerOnMessageTypes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _triggerOnMessageTypes(): JsonField> = body._triggerOnMessageTypes() + + /** + * Returns the raw JSON value of [voice]. + * + * Unlike [voice], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _voice(): JsonField = body._voice() + + 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) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AgentCreateParams]. + * + * The following fields are required: + * ```java + * .model() + * .name() + * .provider() + * .systemPrompt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentCreateParams]. */ + class Builder internal constructor() { + + 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(agentCreateParams: AgentCreateParams) = apply { + body = agentCreateParams.body.toBuilder() + additionalHeaders = agentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = agentCreateParams.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] + * - [name] + * - [provider] + * - [systemPrompt] + * - [contextWindowMessages] + * - 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 name(name: String) = apply { body.name(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 { body.name(name) } + + /** LLM provider for the AI agent. */ + fun provider(provider: AgentProvider) = apply { body.provider(provider) } + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [AgentProvider] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField) = apply { body.provider(provider) } + + fun systemPrompt(systemPrompt: String) = apply { body.systemPrompt(systemPrompt) } + + /** + * Sets [Builder.systemPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.systemPrompt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun systemPrompt(systemPrompt: JsonField) = apply { + body.systemPrompt(systemPrompt) + } + + fun contextWindowMessages(contextWindowMessages: Long) = apply { + body.contextWindowMessages(contextWindowMessages) + } + + /** + * Sets [Builder.contextWindowMessages] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowMessages] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun contextWindowMessages(contextWindowMessages: JsonField) = apply { + body.contextWindowMessages(contextWindowMessages) + } + + fun includeContactMetadata(includeContactMetadata: Boolean) = apply { + body.includeContactMetadata(includeContactMetadata) + } + + /** + * Sets [Builder.includeContactMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.includeContactMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun includeContactMetadata(includeContactMetadata: JsonField) = apply { + body.includeContactMetadata(includeContactMetadata) + } + + fun maxTokens(maxTokens: Long) = apply { body.maxTokens(maxTokens) } + + /** + * 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 temperature(temperature: Double) = apply { body.temperature(temperature) } + + /** + * 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 triggerOnChannels(triggerOnChannels: List) = apply { + body.triggerOnChannels(triggerOnChannels) + } + + /** + * Sets [Builder.triggerOnChannels] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnChannels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun triggerOnChannels(triggerOnChannels: JsonField>) = apply { + body.triggerOnChannels(triggerOnChannels) + } + + /** + * Adds a single [String] to [triggerOnChannels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnChannel(triggerOnChannel: String) = apply { + body.addTriggerOnChannel(triggerOnChannel) + } + + fun triggerOnMessageTypes(triggerOnMessageTypes: List) = apply { + body.triggerOnMessageTypes(triggerOnMessageTypes) + } + + /** + * Sets [Builder.triggerOnMessageTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnMessageTypes] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun triggerOnMessageTypes(triggerOnMessageTypes: JsonField>) = apply { + body.triggerOnMessageTypes(triggerOnMessageTypes) + } + + /** + * Adds a single [String] to [triggerOnMessageTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnMessageType(triggerOnMessageType: String) = apply { + body.addTriggerOnMessageType(triggerOnMessageType) + } + + /** + * Voice Agent configuration on a sender's AI agent. Controls how the agent behaves on + * inbound and outbound phone calls through Zavu's managed voice pipeline (speech + * recognition, the agent's LLM, and speech synthesis, with real-time interruption + * handling). Requires the Voice Agents feature to be enabled for your team. + */ + fun voice(voice: Voice) = apply { body.voice(voice) } + + /** + * Sets [Builder.voice] to an arbitrary JSON value. + * + * You should usually call [Builder.voice] with a well-typed [Voice] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun voice(voice: JsonField) = apply { body.voice(voice) } + + 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 [AgentCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .model() + * .name() + * .provider() + * .systemPrompt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentCreateParams = + AgentCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** + * Create an agent that exists on its own. Connect senders afterwards; an agent answers on any + * number of them. + * + * **Sub-resources.** An agent's tools, flows and knowledge bases are reachable at + * `/v1/agents/{agentId}/tools`, `/v1/agents/{agentId}/flows` and + * `/v1/agents/{agentId}/knowledge-bases`, mirroring the sender-scoped routes documented under + * `/v1/senders/{senderId}/agent/...` exactly. Use the agent-scoped form while the agent has no + * sender: the sender-scoped one cannot address it. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val model: JsonField, + private val name: JsonField, + private val provider: JsonField, + private val systemPrompt: JsonField, + private val contextWindowMessages: JsonField, + private val includeContactMetadata: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val triggerOnChannels: JsonField>, + private val triggerOnMessageTypes: JsonField>, + private val voice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField = JsonMissing.of(), + @JsonProperty("systemPrompt") + @ExcludeMissing + systemPrompt: JsonField = JsonMissing.of(), + @JsonProperty("contextWindowMessages") + @ExcludeMissing + contextWindowMessages: JsonField = JsonMissing.of(), + @JsonProperty("includeContactMetadata") + @ExcludeMissing + includeContactMetadata: JsonField = JsonMissing.of(), + @JsonProperty("maxTokens") + @ExcludeMissing + maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + temperature: JsonField = JsonMissing.of(), + @JsonProperty("triggerOnChannels") + @ExcludeMissing + triggerOnChannels: JsonField> = JsonMissing.of(), + @JsonProperty("triggerOnMessageTypes") + @ExcludeMissing + triggerOnMessageTypes: JsonField> = JsonMissing.of(), + @JsonProperty("voice") @ExcludeMissing voice: JsonField = JsonMissing.of(), + ) : this( + model, + name, + provider, + systemPrompt, + contextWindowMessages, + includeContactMetadata, + maxTokens, + temperature, + triggerOnChannels, + triggerOnMessageTypes, + voice, + mutableMapOf(), + ) + + /** + * @throws ZavudevInvalidDataException 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 ZavudevInvalidDataException 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") + + /** + * LLM provider for the AI agent. + * + * @throws ZavudevInvalidDataException 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 provider(): AgentProvider = provider.getRequired("provider") + + /** + * @throws ZavudevInvalidDataException 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 systemPrompt(): String = systemPrompt.getRequired("systemPrompt") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowMessages(): Optional = + contextWindowMessages.getOptional("contextWindowMessages") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeContactMetadata(): Optional = + includeContactMetadata.getOptional("includeContactMetadata") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = maxTokens.getOptional("maxTokens") + + /** + * @throws ZavudevInvalidDataException 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 ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnChannels(): Optional> = + triggerOnChannels.getOptional("triggerOnChannels") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnMessageTypes(): Optional> = + triggerOnMessageTypes.getOptional("triggerOnMessageTypes") + + /** + * Voice Agent configuration on a sender's AI agent. Controls how the agent behaves on + * inbound and outbound phone calls through Zavu's managed voice pipeline (speech + * recognition, the agent's LLM, and speech synthesis, with real-time interruption + * handling). Requires the Voice Agents feature to be enabled for your team. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voice(): Optional = voice.getOptional("voice") + + /** + * 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 [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 [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") + @ExcludeMissing + fun _provider(): JsonField = provider + + /** + * Returns the raw JSON value of [systemPrompt]. + * + * Unlike [systemPrompt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("systemPrompt") + @ExcludeMissing + fun _systemPrompt(): JsonField = systemPrompt + + /** + * Returns the raw JSON value of [contextWindowMessages]. + * + * Unlike [contextWindowMessages], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contextWindowMessages") + @ExcludeMissing + fun _contextWindowMessages(): JsonField = contextWindowMessages + + /** + * Returns the raw JSON value of [includeContactMetadata]. + * + * Unlike [includeContactMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeContactMetadata") + @ExcludeMissing + fun _includeContactMetadata(): JsonField = includeContactMetadata + + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxTokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + + /** + * 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 [triggerOnChannels]. + * + * Unlike [triggerOnChannels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("triggerOnChannels") + @ExcludeMissing + fun _triggerOnChannels(): JsonField> = triggerOnChannels + + /** + * Returns the raw JSON value of [triggerOnMessageTypes]. + * + * Unlike [triggerOnMessageTypes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("triggerOnMessageTypes") + @ExcludeMissing + fun _triggerOnMessageTypes(): JsonField> = triggerOnMessageTypes + + /** + * Returns the raw JSON value of [voice]. + * + * Unlike [voice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voice") @ExcludeMissing fun _voice(): JsonField = voice + + @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 + * .model() + * .name() + * .provider() + * .systemPrompt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var model: JsonField? = null + private var name: JsonField? = null + private var provider: JsonField? = null + private var systemPrompt: JsonField? = null + private var contextWindowMessages: JsonField = JsonMissing.of() + private var includeContactMetadata: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var triggerOnChannels: JsonField>? = null + private var triggerOnMessageTypes: JsonField>? = null + private var voice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + model = body.model + name = body.name + provider = body.provider + systemPrompt = body.systemPrompt + contextWindowMessages = body.contextWindowMessages + includeContactMetadata = body.includeContactMetadata + maxTokens = body.maxTokens + temperature = body.temperature + triggerOnChannels = body.triggerOnChannels.map { it.toMutableList() } + triggerOnMessageTypes = body.triggerOnMessageTypes.map { it.toMutableList() } + voice = body.voice + 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 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 } + + /** LLM provider for the AI agent. */ + fun provider(provider: AgentProvider) = provider(JsonField.of(provider)) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [AgentProvider] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } + + fun systemPrompt(systemPrompt: String) = systemPrompt(JsonField.of(systemPrompt)) + + /** + * Sets [Builder.systemPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.systemPrompt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun systemPrompt(systemPrompt: JsonField) = apply { + this.systemPrompt = systemPrompt + } + + fun contextWindowMessages(contextWindowMessages: Long) = + contextWindowMessages(JsonField.of(contextWindowMessages)) + + /** + * Sets [Builder.contextWindowMessages] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowMessages] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun contextWindowMessages(contextWindowMessages: JsonField) = apply { + this.contextWindowMessages = contextWindowMessages + } + + fun includeContactMetadata(includeContactMetadata: Boolean) = + includeContactMetadata(JsonField.of(includeContactMetadata)) + + /** + * Sets [Builder.includeContactMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.includeContactMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeContactMetadata(includeContactMetadata: JsonField) = apply { + this.includeContactMetadata = includeContactMetadata + } + + fun maxTokens(maxTokens: Long) = maxTokens(JsonField.of(maxTokens)) + + /** + * 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 temperature(temperature: Double) = temperature(JsonField.of(temperature)) + + /** + * 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 triggerOnChannels(triggerOnChannels: List) = + triggerOnChannels(JsonField.of(triggerOnChannels)) + + /** + * Sets [Builder.triggerOnChannels] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnChannels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun triggerOnChannels(triggerOnChannels: JsonField>) = apply { + this.triggerOnChannels = triggerOnChannels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [triggerOnChannels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnChannel(triggerOnChannel: String) = apply { + triggerOnChannels = + (triggerOnChannels ?: JsonField.of(mutableListOf())).also { + checkKnown("triggerOnChannels", it).add(triggerOnChannel) + } + } + + fun triggerOnMessageTypes(triggerOnMessageTypes: List) = + triggerOnMessageTypes(JsonField.of(triggerOnMessageTypes)) + + /** + * Sets [Builder.triggerOnMessageTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnMessageTypes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun triggerOnMessageTypes(triggerOnMessageTypes: JsonField>) = apply { + this.triggerOnMessageTypes = triggerOnMessageTypes.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [triggerOnMessageTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnMessageType(triggerOnMessageType: String) = apply { + triggerOnMessageTypes = + (triggerOnMessageTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("triggerOnMessageTypes", it).add(triggerOnMessageType) + } + } + + /** + * Voice Agent configuration on a sender's AI agent. Controls how the agent behaves on + * inbound and outbound phone calls through Zavu's managed voice pipeline (speech + * recognition, the agent's LLM, and speech synthesis, with real-time interruption + * handling). Requires the Voice Agents feature to be enabled for your team. + */ + fun voice(voice: Voice) = voice(JsonField.of(voice)) + + /** + * Sets [Builder.voice] to an arbitrary JSON value. + * + * You should usually call [Builder.voice] with a well-typed [Voice] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun voice(voice: JsonField) = apply { this.voice = voice } + + 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 + * .model() + * .name() + * .provider() + * .systemPrompt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("model", model), + checkRequired("name", name), + checkRequired("provider", provider), + checkRequired("systemPrompt", systemPrompt), + contextWindowMessages, + includeContactMetadata, + maxTokens, + temperature, + (triggerOnChannels ?: JsonMissing.of()).map { it.toImmutable() }, + (triggerOnMessageTypes ?: JsonMissing.of()).map { it.toImmutable() }, + voice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + model() + name() + provider().validate() + systemPrompt() + contextWindowMessages() + includeContactMetadata() + maxTokens() + temperature() + triggerOnChannels() + triggerOnMessageTypes() + voice().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (name.asKnown().isPresent) 1 else 0) + + (provider.asKnown().getOrNull()?.validity() ?: 0) + + (if (systemPrompt.asKnown().isPresent) 1 else 0) + + (if (contextWindowMessages.asKnown().isPresent) 1 else 0) + + (if (includeContactMetadata.asKnown().isPresent) 1 else 0) + + (if (maxTokens.asKnown().isPresent) 1 else 0) + + (if (temperature.asKnown().isPresent) 1 else 0) + + (triggerOnChannels.asKnown().getOrNull()?.size ?: 0) + + (triggerOnMessageTypes.asKnown().getOrNull()?.size ?: 0) + + (voice.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + model == other.model && + name == other.name && + provider == other.provider && + systemPrompt == other.systemPrompt && + contextWindowMessages == other.contextWindowMessages && + includeContactMetadata == other.includeContactMetadata && + maxTokens == other.maxTokens && + temperature == other.temperature && + triggerOnChannels == other.triggerOnChannels && + triggerOnMessageTypes == other.triggerOnMessageTypes && + voice == other.voice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + model, + name, + provider, + systemPrompt, + contextWindowMessages, + includeContactMetadata, + maxTokens, + temperature, + triggerOnChannels, + triggerOnMessageTypes, + voice, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{model=$model, name=$name, provider=$provider, systemPrompt=$systemPrompt, contextWindowMessages=$contextWindowMessages, includeContactMetadata=$includeContactMetadata, maxTokens=$maxTokens, temperature=$temperature, triggerOnChannels=$triggerOnChannels, triggerOnMessageTypes=$triggerOnMessageTypes, voice=$voice, additionalProperties=$additionalProperties}" + } + + /** + * Voice Agent configuration on a sender's AI agent. Controls how the agent behaves on inbound + * and outbound phone calls through Zavu's managed voice pipeline (speech recognition, the + * agent's LLM, and speech synthesis, with real-time interruption handling). Requires the Voice + * Agents feature to be enabled for your team. + */ + class Voice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val greeting: JsonField, + private val greetings: JsonField, + private val interruptible: JsonField, + private val language: JsonField, + private val maxCallDurationMinutes: JsonField, + private val maxIdleSeconds: JsonField, + private val model: JsonField, + private val recordCalls: JsonField, + private val sttModel: JsonField, + private val sttProvider: JsonField, + private val transferPhoneNumber: JsonField, + private val ttsProvider: JsonField, + private val ttsVoiceId: JsonField, + private val voicemailAction: JsonField, + private val voicemailMessage: JsonField, + private val voiceSpeed: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("greeting") + @ExcludeMissing + greeting: JsonField = JsonMissing.of(), + @JsonProperty("greetings") + @ExcludeMissing + greetings: JsonField = JsonMissing.of(), + @JsonProperty("interruptible") + @ExcludeMissing + interruptible: JsonField = JsonMissing.of(), + @JsonProperty("language") + @ExcludeMissing + language: JsonField = JsonMissing.of(), + @JsonProperty("maxCallDurationMinutes") + @ExcludeMissing + maxCallDurationMinutes: JsonField = JsonMissing.of(), + @JsonProperty("maxIdleSeconds") + @ExcludeMissing + maxIdleSeconds: JsonField = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("recordCalls") + @ExcludeMissing + recordCalls: JsonField = JsonMissing.of(), + @JsonProperty("sttModel") + @ExcludeMissing + sttModel: JsonField = JsonMissing.of(), + @JsonProperty("sttProvider") + @ExcludeMissing + sttProvider: JsonField = JsonMissing.of(), + @JsonProperty("transferPhoneNumber") + @ExcludeMissing + transferPhoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("ttsProvider") + @ExcludeMissing + ttsProvider: JsonField = JsonMissing.of(), + @JsonProperty("ttsVoiceId") + @ExcludeMissing + ttsVoiceId: JsonField = JsonMissing.of(), + @JsonProperty("voicemailAction") + @ExcludeMissing + voicemailAction: JsonField = JsonMissing.of(), + @JsonProperty("voicemailMessage") + @ExcludeMissing + voicemailMessage: JsonField = JsonMissing.of(), + @JsonProperty("voiceSpeed") + @ExcludeMissing + voiceSpeed: JsonField = JsonMissing.of(), + ) : this( + enabled, + greeting, + greetings, + interruptible, + language, + maxCallDurationMinutes, + maxIdleSeconds, + model, + recordCalls, + sttModel, + sttProvider, + transferPhoneNumber, + ttsProvider, + ttsVoiceId, + voicemailAction, + voicemailMessage, + voiceSpeed, + mutableMapOf(), + ) + + /** + * Whether the agent handles voice calls. When false, the sender's number is not answered by + * the voice agent and outbound calls are rejected. + * + * @throws ZavudevInvalidDataException 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") + + /** + * Opening line the agent speaks when the call connects. If omitted, the agent waits for the + * caller to speak first. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun greeting(): Optional = greeting.getOptional("greeting") + + /** + * Greeting per language, keyed by language code. Used when the caller's language differs + * from the one `greeting` is written in. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun greetings(): Optional = greetings.getOptional("greetings") + + /** + * Whether the caller can interrupt the agent while it is speaking (barge-in). When true, + * the agent stops talking as soon as the caller starts. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun interruptible(): Optional = interruptible.getOptional("interruptible") + + /** + * BCP-47 language code used for both speech recognition and speech synthesis (e.g. `en`, + * `es`, `pt-BR`). Auto-detected from the recipient when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = language.getOptional("language") + + /** + * Hard limit on call length in minutes. The call ends automatically when reached. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxCallDurationMinutes(): Optional = + maxCallDurationMinutes.getOptional("maxCallDurationMinutes") + + /** + * How long the agent waits during silence before ending the call. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxIdleSeconds(): Optional = maxIdleSeconds.getOptional("maxIdleSeconds") + + /** + * Model that runs the conversation, co-located in the voice network for lowest latency. + * Independent of the model used for text messaging. Derived from the agent's text model + * when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") + + /** + * Whether the call audio is recorded. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordCalls(): Optional = recordCalls.getOptional("recordCalls") + + /** + * Speech-recognition model. Uses the default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sttModel(): Optional = sttModel.getOptional("sttModel") + + /** + * Speech-recognition provider. Uses the default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sttProvider(): Optional = sttProvider.getOptional("sttProvider") + + /** + * E.164 phone number the agent can transfer the call to. When set, the agent is given a + * transfer tool it can use to hand the call to a human. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transferPhoneNumber(): Optional = + transferPhoneNumber.getOptional("transferPhoneNumber") + + /** + * Speech-synthesis provider. Uses the default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ttsProvider(): Optional = ttsProvider.getOptional("ttsProvider") + + /** + * Identifier of the synthesized voice that speaks. Choose from the voices available in the + * dashboard. Uses a neutral default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ttsVoiceId(): Optional = ttsVoiceId.getOptional("ttsVoiceId") + + /** + * What the agent does when an answering machine or voicemail is detected on an outbound + * call. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voicemailAction(): Optional = + voicemailAction.getOptional("voicemailAction") + + /** + * Message spoken when `voicemailAction` is `leave_message`. Falls back to `greeting` when + * omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voicemailMessage(): Optional = voicemailMessage.getOptional("voicemailMessage") + + /** + * Speech rate. 1.0 is natural. Only honoured by voices that support rate control; ignored + * by the others. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voiceSpeed(): Optional = voiceSpeed.getOptional("voiceSpeed") + + /** + * 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 + + /** + * Returns the raw JSON value of [greeting]. + * + * Unlike [greeting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("greeting") @ExcludeMissing fun _greeting(): JsonField = greeting + + /** + * Returns the raw JSON value of [greetings]. + * + * Unlike [greetings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("greetings") + @ExcludeMissing + fun _greetings(): JsonField = greetings + + /** + * Returns the raw JSON value of [interruptible]. + * + * Unlike [interruptible], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interruptible") + @ExcludeMissing + fun _interruptible(): JsonField = interruptible + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + /** + * Returns the raw JSON value of [maxCallDurationMinutes]. + * + * Unlike [maxCallDurationMinutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maxCallDurationMinutes") + @ExcludeMissing + fun _maxCallDurationMinutes(): JsonField = maxCallDurationMinutes + + /** + * Returns the raw JSON value of [maxIdleSeconds]. + * + * Unlike [maxIdleSeconds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maxIdleSeconds") + @ExcludeMissing + fun _maxIdleSeconds(): JsonField = maxIdleSeconds + + /** + * 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 [recordCalls]. + * + * Unlike [recordCalls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recordCalls") + @ExcludeMissing + fun _recordCalls(): JsonField = recordCalls + + /** + * Returns the raw JSON value of [sttModel]. + * + * Unlike [sttModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sttModel") @ExcludeMissing fun _sttModel(): JsonField = sttModel + + /** + * Returns the raw JSON value of [sttProvider]. + * + * Unlike [sttProvider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sttProvider") + @ExcludeMissing + fun _sttProvider(): JsonField = sttProvider + + /** + * Returns the raw JSON value of [transferPhoneNumber]. + * + * Unlike [transferPhoneNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("transferPhoneNumber") + @ExcludeMissing + fun _transferPhoneNumber(): JsonField = transferPhoneNumber + + /** + * Returns the raw JSON value of [ttsProvider]. + * + * Unlike [ttsProvider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttsProvider") + @ExcludeMissing + fun _ttsProvider(): JsonField = ttsProvider + + /** + * Returns the raw JSON value of [ttsVoiceId]. + * + * Unlike [ttsVoiceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttsVoiceId") + @ExcludeMissing + fun _ttsVoiceId(): JsonField = ttsVoiceId + + /** + * Returns the raw JSON value of [voicemailAction]. + * + * Unlike [voicemailAction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voicemailAction") + @ExcludeMissing + fun _voicemailAction(): JsonField = voicemailAction + + /** + * Returns the raw JSON value of [voicemailMessage]. + * + * Unlike [voicemailMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voicemailMessage") + @ExcludeMissing + fun _voicemailMessage(): JsonField = voicemailMessage + + /** + * Returns the raw JSON value of [voiceSpeed]. + * + * Unlike [voiceSpeed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voiceSpeed") + @ExcludeMissing + fun _voiceSpeed(): JsonField = voiceSpeed + + @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 [Voice]. + * + * The following fields are required: + * ```java + * .enabled() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Voice]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var greeting: JsonField = JsonMissing.of() + private var greetings: JsonField = JsonMissing.of() + private var interruptible: JsonField = JsonMissing.of() + private var language: JsonField = JsonMissing.of() + private var maxCallDurationMinutes: JsonField = JsonMissing.of() + private var maxIdleSeconds: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var recordCalls: JsonField = JsonMissing.of() + private var sttModel: JsonField = JsonMissing.of() + private var sttProvider: JsonField = JsonMissing.of() + private var transferPhoneNumber: JsonField = JsonMissing.of() + private var ttsProvider: JsonField = JsonMissing.of() + private var ttsVoiceId: JsonField = JsonMissing.of() + private var voicemailAction: JsonField = JsonMissing.of() + private var voicemailMessage: JsonField = JsonMissing.of() + private var voiceSpeed: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voice: Voice) = apply { + enabled = voice.enabled + greeting = voice.greeting + greetings = voice.greetings + interruptible = voice.interruptible + language = voice.language + maxCallDurationMinutes = voice.maxCallDurationMinutes + maxIdleSeconds = voice.maxIdleSeconds + model = voice.model + recordCalls = voice.recordCalls + sttModel = voice.sttModel + sttProvider = voice.sttProvider + transferPhoneNumber = voice.transferPhoneNumber + ttsProvider = voice.ttsProvider + ttsVoiceId = voice.ttsVoiceId + voicemailAction = voice.voicemailAction + voicemailMessage = voice.voicemailMessage + voiceSpeed = voice.voiceSpeed + additionalProperties = voice.additionalProperties.toMutableMap() + } + + /** + * Whether the agent handles voice calls. When false, the sender's number is not + * answered by the voice agent and outbound calls are rejected. + */ + 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 } + + /** + * Opening line the agent speaks when the call connects. If omitted, the agent waits for + * the caller to speak first. + */ + fun greeting(greeting: String) = greeting(JsonField.of(greeting)) + + /** + * Sets [Builder.greeting] to an arbitrary JSON value. + * + * You should usually call [Builder.greeting] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun greeting(greeting: JsonField) = apply { this.greeting = greeting } + + /** + * Greeting per language, keyed by language code. Used when the caller's language + * differs from the one `greeting` is written in. + */ + fun greetings(greetings: Greetings) = greetings(JsonField.of(greetings)) + + /** + * Sets [Builder.greetings] to an arbitrary JSON value. + * + * You should usually call [Builder.greetings] with a well-typed [Greetings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun greetings(greetings: JsonField) = apply { this.greetings = greetings } + + /** + * Whether the caller can interrupt the agent while it is speaking (barge-in). When + * true, the agent stops talking as soon as the caller starts. + */ + fun interruptible(interruptible: Boolean) = interruptible(JsonField.of(interruptible)) + + /** + * Sets [Builder.interruptible] to an arbitrary JSON value. + * + * You should usually call [Builder.interruptible] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun interruptible(interruptible: JsonField) = apply { + this.interruptible = interruptible + } + + /** + * BCP-47 language code used for both speech recognition and speech synthesis (e.g. + * `en`, `es`, `pt-BR`). Auto-detected from the recipient when omitted. + */ + fun language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + /** Hard limit on call length in minutes. The call ends automatically when reached. */ + fun maxCallDurationMinutes(maxCallDurationMinutes: Long) = + maxCallDurationMinutes(JsonField.of(maxCallDurationMinutes)) + + /** + * Sets [Builder.maxCallDurationMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.maxCallDurationMinutes] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maxCallDurationMinutes(maxCallDurationMinutes: JsonField) = apply { + this.maxCallDurationMinutes = maxCallDurationMinutes + } + + /** How long the agent waits during silence before ending the call. */ + fun maxIdleSeconds(maxIdleSeconds: Long) = maxIdleSeconds(JsonField.of(maxIdleSeconds)) + + /** + * Sets [Builder.maxIdleSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.maxIdleSeconds] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxIdleSeconds(maxIdleSeconds: JsonField) = apply { + this.maxIdleSeconds = maxIdleSeconds + } + + /** + * Model that runs the conversation, co-located in the voice network for lowest latency. + * Independent of the model used for text messaging. Derived from the agent's text model + * when omitted. + */ + 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 } + + /** Whether the call audio is recorded. */ + fun recordCalls(recordCalls: Boolean) = recordCalls(JsonField.of(recordCalls)) + + /** + * Sets [Builder.recordCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.recordCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordCalls(recordCalls: JsonField) = apply { + this.recordCalls = recordCalls + } + + /** Speech-recognition model. Uses the default when omitted. */ + fun sttModel(sttModel: String) = sttModel(JsonField.of(sttModel)) + + /** + * Sets [Builder.sttModel] to an arbitrary JSON value. + * + * You should usually call [Builder.sttModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sttModel(sttModel: JsonField) = apply { this.sttModel = sttModel } + + /** Speech-recognition provider. Uses the default when omitted. */ + fun sttProvider(sttProvider: String) = sttProvider(JsonField.of(sttProvider)) + + /** + * Sets [Builder.sttProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.sttProvider] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sttProvider(sttProvider: JsonField) = apply { + this.sttProvider = sttProvider + } + + /** + * E.164 phone number the agent can transfer the call to. When set, the agent is given a + * transfer tool it can use to hand the call to a human. + */ + fun transferPhoneNumber(transferPhoneNumber: String) = + transferPhoneNumber(JsonField.of(transferPhoneNumber)) + + /** + * Sets [Builder.transferPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.transferPhoneNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transferPhoneNumber(transferPhoneNumber: JsonField) = apply { + this.transferPhoneNumber = transferPhoneNumber + } + + /** Speech-synthesis provider. Uses the default when omitted. */ + fun ttsProvider(ttsProvider: String) = ttsProvider(JsonField.of(ttsProvider)) + + /** + * Sets [Builder.ttsProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.ttsProvider] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ttsProvider(ttsProvider: JsonField) = apply { + this.ttsProvider = ttsProvider + } + + /** + * Identifier of the synthesized voice that speaks. Choose from the voices available in + * the dashboard. Uses a neutral default when omitted. + */ + fun ttsVoiceId(ttsVoiceId: String) = ttsVoiceId(JsonField.of(ttsVoiceId)) + + /** + * Sets [Builder.ttsVoiceId] to an arbitrary JSON value. + * + * You should usually call [Builder.ttsVoiceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ttsVoiceId(ttsVoiceId: JsonField) = apply { this.ttsVoiceId = ttsVoiceId } + + /** + * What the agent does when an answering machine or voicemail is detected on an outbound + * call. + */ + fun voicemailAction(voicemailAction: VoicemailAction) = + voicemailAction(JsonField.of(voicemailAction)) + + /** + * Sets [Builder.voicemailAction] to an arbitrary JSON value. + * + * You should usually call [Builder.voicemailAction] with a well-typed [VoicemailAction] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voicemailAction(voicemailAction: JsonField) = apply { + this.voicemailAction = voicemailAction + } + + /** + * Message spoken when `voicemailAction` is `leave_message`. Falls back to `greeting` + * when omitted. + */ + fun voicemailMessage(voicemailMessage: String) = + voicemailMessage(JsonField.of(voicemailMessage)) + + /** + * Sets [Builder.voicemailMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.voicemailMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voicemailMessage(voicemailMessage: JsonField) = apply { + this.voicemailMessage = voicemailMessage + } + + /** + * Speech rate. 1.0 is natural. Only honoured by voices that support rate control; + * ignored by the others. + */ + fun voiceSpeed(voiceSpeed: Double) = voiceSpeed(JsonField.of(voiceSpeed)) + + /** + * Sets [Builder.voiceSpeed] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceSpeed] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voiceSpeed(voiceSpeed: JsonField) = apply { this.voiceSpeed = voiceSpeed } + + 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 [Voice]. + * + * 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(): Voice = + Voice( + checkRequired("enabled", enabled), + greeting, + greetings, + interruptible, + language, + maxCallDurationMinutes, + maxIdleSeconds, + model, + recordCalls, + sttModel, + sttProvider, + transferPhoneNumber, + ttsProvider, + ttsVoiceId, + voicemailAction, + voicemailMessage, + voiceSpeed, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Voice = apply { + if (validated) { + return@apply + } + + enabled() + greeting() + greetings().ifPresent { it.validate() } + interruptible() + language() + maxCallDurationMinutes() + maxIdleSeconds() + model() + recordCalls() + sttModel() + sttProvider() + transferPhoneNumber() + ttsProvider() + ttsVoiceId() + voicemailAction().ifPresent { it.validate() } + voicemailMessage() + voiceSpeed() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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) + + (if (greeting.asKnown().isPresent) 1 else 0) + + (greetings.asKnown().getOrNull()?.validity() ?: 0) + + (if (interruptible.asKnown().isPresent) 1 else 0) + + (if (language.asKnown().isPresent) 1 else 0) + + (if (maxCallDurationMinutes.asKnown().isPresent) 1 else 0) + + (if (maxIdleSeconds.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (recordCalls.asKnown().isPresent) 1 else 0) + + (if (sttModel.asKnown().isPresent) 1 else 0) + + (if (sttProvider.asKnown().isPresent) 1 else 0) + + (if (transferPhoneNumber.asKnown().isPresent) 1 else 0) + + (if (ttsProvider.asKnown().isPresent) 1 else 0) + + (if (ttsVoiceId.asKnown().isPresent) 1 else 0) + + (voicemailAction.asKnown().getOrNull()?.validity() ?: 0) + + (if (voicemailMessage.asKnown().isPresent) 1 else 0) + + (if (voiceSpeed.asKnown().isPresent) 1 else 0) + + /** + * Greeting per language, keyed by language code. Used when the caller's language differs + * from the one `greeting` is written in. + */ + class Greetings + @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 [Greetings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Greetings]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(greetings: Greetings) = apply { + additionalProperties = greetings.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 [Greetings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Greetings = Greetings(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Greetings = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 Greetings && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Greetings{additionalProperties=$additionalProperties}" + } + + /** + * What the agent does when an answering machine or voicemail is detected on an outbound + * call. + */ + class VoicemailAction + @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 HANGUP = of("hangup") + + @JvmField val LEAVE_MESSAGE = of("leave_message") + + @JvmStatic fun of(value: String) = VoicemailAction(JsonField.of(value)) + } + + /** An enum containing [VoicemailAction]'s known values. */ + enum class Known { + HANGUP, + LEAVE_MESSAGE, + } + + /** + * An enum containing [VoicemailAction]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [VoicemailAction] 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 { + HANGUP, + LEAVE_MESSAGE, + /** + * An enum member indicating that [VoicemailAction] 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) { + HANGUP -> Value.HANGUP + LEAVE_MESSAGE -> Value.LEAVE_MESSAGE + 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 ZavudevInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + HANGUP -> Known.HANGUP + LEAVE_MESSAGE -> Known.LEAVE_MESSAGE + else -> throw ZavudevInvalidDataException("Unknown VoicemailAction: $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 ZavudevInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ZavudevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): VoicemailAction = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 VoicemailAction && 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 Voice && + enabled == other.enabled && + greeting == other.greeting && + greetings == other.greetings && + interruptible == other.interruptible && + language == other.language && + maxCallDurationMinutes == other.maxCallDurationMinutes && + maxIdleSeconds == other.maxIdleSeconds && + model == other.model && + recordCalls == other.recordCalls && + sttModel == other.sttModel && + sttProvider == other.sttProvider && + transferPhoneNumber == other.transferPhoneNumber && + ttsProvider == other.ttsProvider && + ttsVoiceId == other.ttsVoiceId && + voicemailAction == other.voicemailAction && + voicemailMessage == other.voicemailMessage && + voiceSpeed == other.voiceSpeed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + greeting, + greetings, + interruptible, + language, + maxCallDurationMinutes, + maxIdleSeconds, + model, + recordCalls, + sttModel, + sttProvider, + transferPhoneNumber, + ttsProvider, + ttsVoiceId, + voicemailAction, + voicemailMessage, + voiceSpeed, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Voice{enabled=$enabled, greeting=$greeting, greetings=$greetings, interruptible=$interruptible, language=$language, maxCallDurationMinutes=$maxCallDurationMinutes, maxIdleSeconds=$maxIdleSeconds, model=$model, recordCalls=$recordCalls, sttModel=$sttModel, sttProvider=$sttProvider, transferPhoneNumber=$transferPhoneNumber, ttsProvider=$ttsProvider, ttsVoiceId=$ttsVoiceId, voicemailAction=$voicemailAction, voicemailMessage=$voicemailMessage, voiceSpeed=$voiceSpeed, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateResponse.kt new file mode 100644 index 0000000..da8ff91 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateResponse.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkRequired +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.Agent +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AgentCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val agent: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of() + ) : this(agent, mutableMapOf()) + + /** + * AI Agent configuration for a sender. + * + * @throws ZavudevInvalidDataException 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 agent(): Agent = agent.getRequired("agent") + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + @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 [AgentCreateResponse]. + * + * The following fields are required: + * ```java + * .agent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentCreateResponse]. */ + class Builder internal constructor() { + + private var agent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentCreateResponse: AgentCreateResponse) = apply { + agent = agentCreateResponse.agent + additionalProperties = agentCreateResponse.additionalProperties.toMutableMap() + } + + /** AI Agent configuration for a sender. */ + fun agent(agent: Agent) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + 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 [AgentCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentCreateResponse = + AgentCreateResponse(checkRequired("agent", agent), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentCreateResponse = apply { + if (validated) { + return@apply + } + + agent().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (agent.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentCreateResponse && + agent == other.agent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(agent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentCreateResponse{agent=$agent, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentDeleteParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentDeleteParams.kt new file mode 100644 index 0000000..955d72e --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.Params +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import com.zavudev.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete an agent */ +class AgentDeleteParams +private constructor( + private val agentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun agentId(): Optional = Optional.ofNullable(agentId) + + /** 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) + + companion object { + + @JvmStatic fun none(): AgentDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgentDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentDeleteParams]. */ + class Builder internal constructor() { + + private var agentId: 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(agentDeleteParams: AgentDeleteParams) = apply { + agentId = agentDeleteParams.agentId + additionalHeaders = agentDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = agentDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = agentDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun agentId(agentId: String?) = apply { this.agentId = agentId } + + /** Alias for calling [Builder.agentId] with `agentId.orElse(null)`. */ + fun agentId(agentId: Optional) = agentId(agentId.getOrNull()) + + 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) + } + + 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 [AgentDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentDeleteParams = + AgentDeleteParams( + agentId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> agentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentDeleteParams && + agentId == other.agentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(agentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "AgentDeleteParams{agentId=$agentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPage.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPage.kt new file mode 100644 index 0000000..272dcb9 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPage.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +import com.zavudev.api.core.AutoPager +import com.zavudev.api.core.Page +import com.zavudev.api.core.checkRequired +import com.zavudev.api.models.senders.agent.Agent +import com.zavudev.api.services.blocking.AgentService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see AgentService.list */ +class AgentListPage +private constructor( + private val service: AgentService, + private val params: AgentListParams, + private val response: AgentListPageResponse, +) : Page { + + /** + * Delegates to [AgentListPageResponse], but gracefully handles missing data. + * + * @see AgentListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [AgentListPageResponse], but gracefully handles missing data. + * + * @see AgentListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("nextCursor") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): AgentListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): AgentListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): AgentListParams = params + + /** The response that this page was parsed from. */ + fun response(): AgentListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AgentListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentListPage]. */ + class Builder internal constructor() { + + private var service: AgentService? = null + private var params: AgentListParams? = null + private var response: AgentListPageResponse? = null + + @JvmSynthetic + internal fun from(agentListPage: AgentListPage) = apply { + service = agentListPage.service + params = agentListPage.params + response = agentListPage.response + } + + fun service(service: AgentService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: AgentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: AgentListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [AgentListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentListPage = + AgentListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = "AgentListPage{service=$service, params=$params, response=$response}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageAsync.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageAsync.kt new file mode 100644 index 0000000..f9ae9ee --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageAsync.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +import com.zavudev.api.core.AutoPagerAsync +import com.zavudev.api.core.PageAsync +import com.zavudev.api.core.checkRequired +import com.zavudev.api.models.senders.agent.Agent +import com.zavudev.api.services.async.AgentServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see AgentServiceAsync.list */ +class AgentListPageAsync +private constructor( + private val service: AgentServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: AgentListParams, + private val response: AgentListPageResponse, +) : PageAsync { + + /** + * Delegates to [AgentListPageResponse], but gracefully handles missing data. + * + * @see AgentListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [AgentListPageResponse], but gracefully handles missing data. + * + * @see AgentListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("nextCursor") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): AgentListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): AgentListParams = params + + /** The response that this page was parsed from. */ + fun response(): AgentListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AgentListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentListPageAsync]. */ + class Builder internal constructor() { + + private var service: AgentServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: AgentListParams? = null + private var response: AgentListPageResponse? = null + + @JvmSynthetic + internal fun from(agentListPageAsync: AgentListPageAsync) = apply { + service = agentListPageAsync.service + streamHandlerExecutor = agentListPageAsync.streamHandlerExecutor + params = agentListPageAsync.params + response = agentListPageAsync.response + } + + fun service(service: AgentServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: AgentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: AgentListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [AgentListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentListPageAsync = + AgentListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "AgentListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageResponse.kt new file mode 100644 index 0000000..309504b --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageResponse.kt @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.Agent +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AgentListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("nextCursor") @ExcludeMissing nextCursor: JsonField = JsonMissing.of(), + ) : this(items, nextCursor, mutableMapOf()) + + /** + * @throws ZavudevInvalidDataException 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 items(): List = items.getRequired("items") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("nextCursor") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("nextCursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @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 [AgentListPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentListPageResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var nextCursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentListPageResponse: AgentListPageResponse) = apply { + items = agentListPageResponse.items.map { it.toMutableList() } + nextCursor = agentListPageResponse.nextCursor + additionalProperties = agentListPageResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Agent] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Agent) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + /** Alias for calling [Builder.nextCursor] with `nextCursor.orElse(null)`. */ + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.getOrNull()) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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 [AgentListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentListPageResponse = + AgentListPageResponse( + checkRequired("items", items).map { it.toImmutable() }, + nextCursor, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentListPageResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + nextCursor() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentListPageResponse && + items == other.items && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, nextCursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentListPageResponse{items=$items, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListParams.kt new file mode 100644 index 0000000..cda052e --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListParams.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +import com.zavudev.api.core.Params +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Every agent in the project, newest first — including agents that are not connected to any sender + * yet, which the sender-scoped routes cannot reach. Each item carries `senderIds`, the senders the + * agent answers on. + */ +class AgentListParams +private constructor( + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun cursor(): Optional = Optional.ofNullable(cursor) + + fun limit(): Optional = 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) + + companion object { + + @JvmStatic fun none(): AgentListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgentListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agentListParams: AgentListParams) = apply { + cursor = agentListParams.cursor + limit = agentListParams.limit + additionalHeaders = agentListParams.additionalHeaders.toBuilder() + additionalQueryParams = agentListParams.additionalQueryParams.toBuilder() + } + + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + 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 [AgentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentListParams = + AgentListParams(cursor, limit, additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesParams.kt new file mode 100644 index 0000000..9bd82c9 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesParams.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +import com.zavudev.api.core.Params +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * The voices an agent can speak with, for `voice.ttsVoiceId`. Filter by `language` to get the ones + * that speak it; a voice can still be used with `language: auto`, where the agent follows the + * caller and keeps the chosen voice. + */ +class AgentListVoicesParams +private constructor( + private val language: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** BCP-47 tag (`en`, `es`, `pt-BR`). Omit, or pass `auto`, for every voice. */ + fun language(): Optional = Optional.ofNullable(language) + + /** 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) + + companion object { + + @JvmStatic fun none(): AgentListVoicesParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgentListVoicesParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentListVoicesParams]. */ + class Builder internal constructor() { + + private var language: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agentListVoicesParams: AgentListVoicesParams) = apply { + language = agentListVoicesParams.language + additionalHeaders = agentListVoicesParams.additionalHeaders.toBuilder() + additionalQueryParams = agentListVoicesParams.additionalQueryParams.toBuilder() + } + + /** BCP-47 tag (`en`, `es`, `pt-BR`). Omit, or pass `auto`, for every voice. */ + fun language(language: String?) = apply { this.language = language } + + /** Alias for calling [Builder.language] with `language.orElse(null)`. */ + fun language(language: Optional) = language(language.getOrNull()) + + 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 [AgentListVoicesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentListVoicesParams = + AgentListVoicesParams( + language, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + language?.let { put("language", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentListVoicesParams && + language == other.language && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(language, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentListVoicesParams{language=$language, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesResponse.kt new file mode 100644 index 0000000..dc843fe --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesResponse.kt @@ -0,0 +1,526 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AgentListVoicesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val languages: JsonField>, + private val total: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("languages") + @ExcludeMissing + languages: JsonField> = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + ) : this(items, languages, total, mutableMapOf()) + + /** + * @throws ZavudevInvalidDataException 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 items(): List = items.getRequired("items") + + /** + * Languages an agent can be pinned to. `auto` follows the caller. + * + * @throws ZavudevInvalidDataException 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 languages(): List = languages.getRequired("languages") + + /** + * Voices in the catalog, before filtering. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun total(): Optional = total.getOptional("total") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [languages]. + * + * Unlike [languages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("languages") @ExcludeMissing fun _languages(): JsonField> = languages + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + @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 [AgentListVoicesResponse]. + * + * The following fields are required: + * ```java + * .items() + * .languages() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentListVoicesResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var languages: JsonField>? = null + private var total: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentListVoicesResponse: AgentListVoicesResponse) = apply { + items = agentListVoicesResponse.items.map { it.toMutableList() } + languages = agentListVoicesResponse.languages.map { it.toMutableList() } + total = agentListVoicesResponse.total + additionalProperties = agentListVoicesResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** Languages an agent can be pinned to. `auto` follows the caller. */ + fun languages(languages: List) = languages(JsonField.of(languages)) + + /** + * Sets [Builder.languages] to an arbitrary JSON value. + * + * You should usually call [Builder.languages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun languages(languages: JsonField>) = apply { + this.languages = languages.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [languages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLanguage(language: String) = apply { + languages = + (languages ?: JsonField.of(mutableListOf())).also { + checkKnown("languages", it).add(language) + } + } + + /** Voices in the catalog, before filtering. */ + fun total(total: Long) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + 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 [AgentListVoicesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .languages() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentListVoicesResponse = + AgentListVoicesResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("languages", languages).map { it.toImmutable() }, + total, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentListVoicesResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + languages() + total() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (languages.asKnown().getOrNull()?.size ?: 0) + + (if (total.asKnown().isPresent) 1 else 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val language: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("language") + @ExcludeMissing + language: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, language, name, mutableMapOf()) + + /** + * Value for `voice.ttsVoiceId`. + * + * @throws ZavudevInvalidDataException 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") + + /** + * @throws ZavudevInvalidDataException 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 language(): String = language.getRequired("language") + + /** + * @throws ZavudevInvalidDataException 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") + + /** + * 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 [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + /** + * 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 [Item]. + * + * The following fields are required: + * ```java + * .id() + * .language() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var language: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + language = item.language + name = item.name + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** Value for `voice.ttsVoiceId`. */ + 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 language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + 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 [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .language() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("language", language), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + language() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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) + + (if (language.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + id == other.id && + language == other.language && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, language, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, language=$language, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentListVoicesResponse && + items == other.items && + languages == other.languages && + total == other.total && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(items, languages, total, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentListVoicesResponse{items=$items, languages=$languages, total=$total, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveParams.kt new file mode 100644 index 0000000..ab6ed67 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +import com.zavudev.api.core.Params +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get an agent */ +class AgentRetrieveParams +private constructor( + private val agentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agentId(): Optional = Optional.ofNullable(agentId) + + /** 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) + + companion object { + + @JvmStatic fun none(): AgentRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgentRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentRetrieveParams]. */ + class Builder internal constructor() { + + private var agentId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agentRetrieveParams: AgentRetrieveParams) = apply { + agentId = agentRetrieveParams.agentId + additionalHeaders = agentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = agentRetrieveParams.additionalQueryParams.toBuilder() + } + + fun agentId(agentId: String?) = apply { this.agentId = agentId } + + /** Alias for calling [Builder.agentId] with `agentId.orElse(null)`. */ + fun agentId(agentId: Optional) = agentId(agentId.getOrNull()) + + 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 [AgentRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentRetrieveParams = + AgentRetrieveParams(agentId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> agentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentRetrieveParams && + agentId == other.agentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(agentId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentRetrieveParams{agentId=$agentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveResponse.kt new file mode 100644 index 0000000..8189752 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveResponse.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkRequired +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.Agent +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AgentRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val agent: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of() + ) : this(agent, mutableMapOf()) + + /** + * AI Agent configuration for a sender. + * + * @throws ZavudevInvalidDataException 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 agent(): Agent = agent.getRequired("agent") + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + @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 [AgentRetrieveResponse]. + * + * The following fields are required: + * ```java + * .agent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentRetrieveResponse]. */ + class Builder internal constructor() { + + private var agent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentRetrieveResponse: AgentRetrieveResponse) = apply { + agent = agentRetrieveResponse.agent + additionalProperties = agentRetrieveResponse.additionalProperties.toMutableMap() + } + + /** AI Agent configuration for a sender. */ + fun agent(agent: Agent) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + 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 [AgentRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentRetrieveResponse = + AgentRetrieveResponse( + checkRequired("agent", agent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentRetrieveResponse = apply { + if (validated) { + return@apply + } + + agent().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (agent.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentRetrieveResponse && + agent == other.agent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(agent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentRetrieveResponse{agent=$agent, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestParams.kt new file mode 100644 index 0000000..00e7e43 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestParams.kt @@ -0,0 +1,1073 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.Enum +import com.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.Params +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Run the agent's prompt, model and knowledge base against a message and return the reply instead + * of delivering it. Writes nothing and charges nothing, so it is safe to call repeatedly while + * iterating on a prompt. + * + * Note that a dry run never **executes** tools — running them would cause real side effects. Live + * conversations on every channel do call them. When the agent has enabled tools, that gap is + * reported in `warnings` rather than silently producing an answer that looks like a tool call + * happened. + */ +class AgentTestParams +private constructor( + private val agentId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agentId(): Optional = Optional.ofNullable(agentId) + + /** + * What to say to the agent. + * + * @throws ZavudevInvalidDataException 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(): String = body.message() + + /** + * Run the tools the agent calls instead of reporting the choice and stopping. + * + * Off by default because a tool handler talks to the outside world: a rehearsal that charges a + * card is not a rehearsal. Turn it on to exercise the loop that actually matters — the model + * picks a tool, the handler answers, the model replies with the result — without sending a + * message to anyone. What ran comes back in `executedToolCalls`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun executeTools(): Optional = body.executeTools() + + /** + * Prior turns, oldest first, to exercise multi-turn behaviour without persisting a thread. + * Trimmed to the agent's context window. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun history(): Optional> = body.history() + + /** + * Set false to skip retrieval and isolate prompt behaviour from the knowledge base. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useKnowledgeBase(): Optional = body.useKnowledgeBase() + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _message(): JsonField = body._message() + + /** + * Returns the raw JSON value of [executeTools]. + * + * Unlike [executeTools], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _executeTools(): JsonField = body._executeTools() + + /** + * Returns the raw JSON value of [history]. + * + * Unlike [history], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _history(): JsonField> = body._history() + + /** + * Returns the raw JSON value of [useKnowledgeBase]. + * + * Unlike [useKnowledgeBase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _useKnowledgeBase(): JsonField = body._useKnowledgeBase() + + 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) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AgentTestParams]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentTestParams]. */ + class Builder internal constructor() { + + private var agentId: 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(agentTestParams: AgentTestParams) = apply { + agentId = agentTestParams.agentId + body = agentTestParams.body.toBuilder() + additionalHeaders = agentTestParams.additionalHeaders.toBuilder() + additionalQueryParams = agentTestParams.additionalQueryParams.toBuilder() + } + + fun agentId(agentId: String?) = apply { this.agentId = agentId } + + /** Alias for calling [Builder.agentId] with `agentId.orElse(null)`. */ + fun agentId(agentId: Optional) = agentId(agentId.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: + * - [message] + * - [executeTools] + * - [history] + * - [useKnowledgeBase] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** What to say to the agent. */ + fun message(message: String) = apply { body.message(message) } + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { body.message(message) } + + /** + * Run the tools the agent calls instead of reporting the choice and stopping. + * + * Off by default because a tool handler talks to the outside world: a rehearsal that + * charges a card is not a rehearsal. Turn it on to exercise the loop that actually matters + * — the model picks a tool, the handler answers, the model replies with the result — + * without sending a message to anyone. What ran comes back in `executedToolCalls`. + */ + fun executeTools(executeTools: Boolean) = apply { body.executeTools(executeTools) } + + /** + * Sets [Builder.executeTools] to an arbitrary JSON value. + * + * You should usually call [Builder.executeTools] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executeTools(executeTools: JsonField) = apply { + body.executeTools(executeTools) + } + + /** + * Prior turns, oldest first, to exercise multi-turn behaviour without persisting a thread. + * Trimmed to the agent's context window. + */ + fun history(history: List) = apply { body.history(history) } + + /** + * Sets [Builder.history] to an arbitrary JSON value. + * + * You should usually call [Builder.history] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun history(history: JsonField>) = apply { body.history(history) } + + /** + * Adds a single [History] to [Builder.history]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addHistory(history: History) = apply { body.addHistory(history) } + + /** Set false to skip retrieval and isolate prompt behaviour from the knowledge base. */ + fun useKnowledgeBase(useKnowledgeBase: Boolean) = apply { + body.useKnowledgeBase(useKnowledgeBase) + } + + /** + * Sets [Builder.useKnowledgeBase] to an arbitrary JSON value. + * + * You should usually call [Builder.useKnowledgeBase] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useKnowledgeBase(useKnowledgeBase: JsonField) = apply { + body.useKnowledgeBase(useKnowledgeBase) + } + + 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 [AgentTestParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentTestParams = + AgentTestParams( + agentId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> agentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** + * Run the agent and return what it would say. Nothing is delivered to anyone, no execution is + * recorded, and nothing is charged. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val message: JsonField, + private val executeTools: JsonField, + private val history: JsonField>, + private val useKnowledgeBase: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("executeTools") + @ExcludeMissing + executeTools: JsonField = JsonMissing.of(), + @JsonProperty("history") + @ExcludeMissing + history: JsonField> = JsonMissing.of(), + @JsonProperty("useKnowledgeBase") + @ExcludeMissing + useKnowledgeBase: JsonField = JsonMissing.of(), + ) : this(message, executeTools, history, useKnowledgeBase, mutableMapOf()) + + /** + * What to say to the agent. + * + * @throws ZavudevInvalidDataException 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(): String = message.getRequired("message") + + /** + * Run the tools the agent calls instead of reporting the choice and stopping. + * + * Off by default because a tool handler talks to the outside world: a rehearsal that + * charges a card is not a rehearsal. Turn it on to exercise the loop that actually matters + * — the model picks a tool, the handler answers, the model replies with the result — + * without sending a message to anyone. What ran comes back in `executedToolCalls`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun executeTools(): Optional = executeTools.getOptional("executeTools") + + /** + * Prior turns, oldest first, to exercise multi-turn behaviour without persisting a thread. + * Trimmed to the agent's context window. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun history(): Optional> = history.getOptional("history") + + /** + * Set false to skip retrieval and isolate prompt behaviour from the knowledge base. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useKnowledgeBase(): Optional = useKnowledgeBase.getOptional("useKnowledgeBase") + + /** + * 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 [executeTools]. + * + * Unlike [executeTools], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("executeTools") + @ExcludeMissing + fun _executeTools(): JsonField = executeTools + + /** + * Returns the raw JSON value of [history]. + * + * Unlike [history], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("history") @ExcludeMissing fun _history(): JsonField> = history + + /** + * Returns the raw JSON value of [useKnowledgeBase]. + * + * Unlike [useKnowledgeBase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("useKnowledgeBase") + @ExcludeMissing + fun _useKnowledgeBase(): JsonField = useKnowledgeBase + + @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 + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var executeTools: JsonField = JsonMissing.of() + private var history: JsonField>? = null + private var useKnowledgeBase: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + message = body.message + executeTools = body.executeTools + history = body.history.map { it.toMutableList() } + useKnowledgeBase = body.useKnowledgeBase + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** What to say to the agent. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] 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 } + + /** + * Run the tools the agent calls instead of reporting the choice and stopping. + * + * Off by default because a tool handler talks to the outside world: a rehearsal that + * charges a card is not a rehearsal. Turn it on to exercise the loop that actually + * matters — the model picks a tool, the handler answers, the model replies with the + * result — without sending a message to anyone. What ran comes back in + * `executedToolCalls`. + */ + fun executeTools(executeTools: Boolean) = executeTools(JsonField.of(executeTools)) + + /** + * Sets [Builder.executeTools] to an arbitrary JSON value. + * + * You should usually call [Builder.executeTools] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun executeTools(executeTools: JsonField) = apply { + this.executeTools = executeTools + } + + /** + * Prior turns, oldest first, to exercise multi-turn behaviour without persisting a + * thread. Trimmed to the agent's context window. + */ + fun history(history: List) = history(JsonField.of(history)) + + /** + * Sets [Builder.history] to an arbitrary JSON value. + * + * You should usually call [Builder.history] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun history(history: JsonField>) = apply { + this.history = history.map { it.toMutableList() } + } + + /** + * Adds a single [History] to [Builder.history]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addHistory(history: History) = apply { + this.history = + (this.history ?: JsonField.of(mutableListOf())).also { + checkKnown("history", it).add(history) + } + } + + /** Set false to skip retrieval and isolate prompt behaviour from the knowledge base. */ + fun useKnowledgeBase(useKnowledgeBase: Boolean) = + useKnowledgeBase(JsonField.of(useKnowledgeBase)) + + /** + * Sets [Builder.useKnowledgeBase] to an arbitrary JSON value. + * + * You should usually call [Builder.useKnowledgeBase] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useKnowledgeBase(useKnowledgeBase: JsonField) = apply { + this.useKnowledgeBase = useKnowledgeBase + } + + 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 + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("message", message), + executeTools, + (history ?: JsonMissing.of()).map { it.toImmutable() }, + useKnowledgeBase, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + message() + executeTools() + history().ifPresent { it.forEach { it.validate() } } + useKnowledgeBase() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (message.asKnown().isPresent) 1 else 0) + + (if (executeTools.asKnown().isPresent) 1 else 0) + + (history.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (useKnowledgeBase.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + message == other.message && + executeTools == other.executeTools && + history == other.history && + useKnowledgeBase == other.useKnowledgeBase && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(message, executeTools, history, useKnowledgeBase, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{message=$message, executeTools=$executeTools, history=$history, useKnowledgeBase=$useKnowledgeBase, additionalProperties=$additionalProperties}" + } + + class History + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val role: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonField = JsonMissing.of(), + ) : this(content, role, mutableMapOf()) + + /** + * @throws ZavudevInvalidDataException 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(): String = content.getRequired("content") + + /** + * @throws ZavudevInvalidDataException 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 role(): Role = role.getRequired("role") + + /** + * 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 [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + + @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 [History]. + * + * The following fields are required: + * ```java + * .content() + * .role() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [History]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var role: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(history: History) = apply { + content = history.content + role = history.role + additionalProperties = history.additionalProperties.toMutableMap() + } + + fun content(content: String) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] 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 } + + fun role(role: Role) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun role(role: JsonField) = apply { this.role = role } + + 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 [History]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): History = + History( + checkRequired("content", content), + checkRequired("role", role), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): History = apply { + if (validated) { + return@apply + } + + content() + role().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (content.asKnown().isPresent) 1 else 0) + + (role.asKnown().getOrNull()?.validity() ?: 0) + + class Role @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 USER = of("user") + + @JvmField val ASSISTANT = of("assistant") + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + /** An enum containing [Role]'s known values. */ + enum class Known { + USER, + ASSISTANT, + } + + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] 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 { + USER, + ASSISTANT, + /** An enum member indicating that [Role] 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) { + USER -> Value.USER + ASSISTANT -> Value.ASSISTANT + 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 ZavudevInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER -> Known.USER + ASSISTANT -> Known.ASSISTANT + else -> throw ZavudevInvalidDataException("Unknown Role: $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 ZavudevInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ZavudevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 Role && 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 History && + content == other.content && + role == other.role && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, role, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "History{content=$content, role=$role, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentTestParams && + agentId == other.agentId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(agentId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentTestParams{agentId=$agentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestResponse.kt new file mode 100644 index 0000000..525aafc --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestResponse.kt @@ -0,0 +1,808 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AgentTestResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val error: JsonField, + private val inputTokens: JsonField, + private val knowledgeChunksUsed: JsonField, + private val latencyMs: JsonField, + private val outputTokens: JsonField, + private val success: JsonField, + private val text: JsonField, + private val warnings: JsonField>, + private val executedToolCalls: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("inputTokens") + @ExcludeMissing + inputTokens: JsonField = JsonMissing.of(), + @JsonProperty("knowledgeChunksUsed") + @ExcludeMissing + knowledgeChunksUsed: JsonField = JsonMissing.of(), + @JsonProperty("latencyMs") @ExcludeMissing latencyMs: JsonField = JsonMissing.of(), + @JsonProperty("outputTokens") + @ExcludeMissing + outputTokens: JsonField = JsonMissing.of(), + @JsonProperty("success") @ExcludeMissing success: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("warnings") + @ExcludeMissing + warnings: JsonField> = JsonMissing.of(), + @JsonProperty("executedToolCalls") + @ExcludeMissing + executedToolCalls: JsonField> = JsonMissing.of(), + ) : this( + error, + inputTokens, + knowledgeChunksUsed, + latencyMs, + outputTokens, + success, + text, + warnings, + executedToolCalls, + mutableMapOf(), + ) + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * @throws ZavudevInvalidDataException 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 inputTokens(): Long = inputTokens.getRequired("inputTokens") + + /** + * Knowledge-base chunks retrieved for this message. Zero means the answer was not grounded in + * your documents. + * + * @throws ZavudevInvalidDataException 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 knowledgeChunksUsed(): Long = knowledgeChunksUsed.getRequired("knowledgeChunksUsed") + + /** + * @throws ZavudevInvalidDataException 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 latencyMs(): Long = latencyMs.getRequired("latencyMs") + + /** + * @throws ZavudevInvalidDataException 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 outputTokens(): Long = outputTokens.getRequired("outputTokens") + + /** + * @throws ZavudevInvalidDataException 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 success(): Boolean = success.getRequired("success") + + /** + * What the agent would reply. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Things that are true of this agent but that a dry run cannot prove. Surfaced so a passing dry + * run is never mistaken for proof that the agent works live. + * - The agent being disabled. + * - Enabled tools that were **not offered to the model** here — the model never saw them, so a + * reply that looks like a lookup was invented. Live conversations on every channel do offer + * them; running them here would cause real side effects. + * - An agent whose sender has none of the channels it triggers on, which answers every dry run + * and no real message. + * - Contact metadata that exists on a real conversation but not here. + * + * @throws ZavudevInvalidDataException 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 warnings(): List = warnings.getRequired("warnings") + + /** + * Tools that actually ran, in order, when the request set `executeTools`. Empty on a normal dry + * run, where nothing is executed. An entry with `ok: false` means the agent saw an error and + * answered around it, which is what a customer would have received. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun executedToolCalls(): Optional> = + executedToolCalls.getOptional("executedToolCalls") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [inputTokens]. + * + * Unlike [inputTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputTokens") @ExcludeMissing fun _inputTokens(): JsonField = inputTokens + + /** + * Returns the raw JSON value of [knowledgeChunksUsed]. + * + * Unlike [knowledgeChunksUsed], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("knowledgeChunksUsed") + @ExcludeMissing + fun _knowledgeChunksUsed(): JsonField = knowledgeChunksUsed + + /** + * Returns the raw JSON value of [latencyMs]. + * + * Unlike [latencyMs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latencyMs") @ExcludeMissing fun _latencyMs(): JsonField = latencyMs + + /** + * Returns the raw JSON value of [outputTokens]. + * + * Unlike [outputTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputTokens") + @ExcludeMissing + fun _outputTokens(): JsonField = outputTokens + + /** + * Returns the raw JSON value of [success]. + * + * Unlike [success], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("success") @ExcludeMissing fun _success(): JsonField = success + + /** + * 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 [warnings]. + * + * Unlike [warnings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("warnings") @ExcludeMissing fun _warnings(): JsonField> = warnings + + /** + * Returns the raw JSON value of [executedToolCalls]. + * + * Unlike [executedToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("executedToolCalls") + @ExcludeMissing + fun _executedToolCalls(): JsonField> = executedToolCalls + + @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 [AgentTestResponse]. + * + * The following fields are required: + * ```java + * .error() + * .inputTokens() + * .knowledgeChunksUsed() + * .latencyMs() + * .outputTokens() + * .success() + * .text() + * .warnings() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentTestResponse]. */ + class Builder internal constructor() { + + private var error: JsonField? = null + private var inputTokens: JsonField? = null + private var knowledgeChunksUsed: JsonField? = null + private var latencyMs: JsonField? = null + private var outputTokens: JsonField? = null + private var success: JsonField? = null + private var text: JsonField? = null + private var warnings: JsonField>? = null + private var executedToolCalls: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentTestResponse: AgentTestResponse) = apply { + error = agentTestResponse.error + inputTokens = agentTestResponse.inputTokens + knowledgeChunksUsed = agentTestResponse.knowledgeChunksUsed + latencyMs = agentTestResponse.latencyMs + outputTokens = agentTestResponse.outputTokens + success = agentTestResponse.success + text = agentTestResponse.text + warnings = agentTestResponse.warnings.map { it.toMutableList() } + executedToolCalls = agentTestResponse.executedToolCalls.map { it.toMutableList() } + additionalProperties = agentTestResponse.additionalProperties.toMutableMap() + } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun inputTokens(inputTokens: Long) = inputTokens(JsonField.of(inputTokens)) + + /** + * Sets [Builder.inputTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputTokens(inputTokens: JsonField) = apply { this.inputTokens = inputTokens } + + /** + * Knowledge-base chunks retrieved for this message. Zero means the answer was not grounded + * in your documents. + */ + fun knowledgeChunksUsed(knowledgeChunksUsed: Long) = + knowledgeChunksUsed(JsonField.of(knowledgeChunksUsed)) + + /** + * Sets [Builder.knowledgeChunksUsed] to an arbitrary JSON value. + * + * You should usually call [Builder.knowledgeChunksUsed] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun knowledgeChunksUsed(knowledgeChunksUsed: JsonField) = apply { + this.knowledgeChunksUsed = knowledgeChunksUsed + } + + fun latencyMs(latencyMs: Long) = latencyMs(JsonField.of(latencyMs)) + + /** + * Sets [Builder.latencyMs] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyMs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun latencyMs(latencyMs: JsonField) = apply { this.latencyMs = latencyMs } + + fun outputTokens(outputTokens: Long) = outputTokens(JsonField.of(outputTokens)) + + /** + * Sets [Builder.outputTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.outputTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputTokens(outputTokens: JsonField) = apply { this.outputTokens = outputTokens } + + fun success(success: Boolean) = success(JsonField.of(success)) + + /** + * Sets [Builder.success] to an arbitrary JSON value. + * + * You should usually call [Builder.success] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun success(success: JsonField) = apply { this.success = success } + + /** What the agent would reply. */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * 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 } + + /** + * Things that are true of this agent but that a dry run cannot prove. Surfaced so a passing + * dry run is never mistaken for proof that the agent works live. + * - The agent being disabled. + * - Enabled tools that were **not offered to the model** here — the model never saw them, + * so a reply that looks like a lookup was invented. Live conversations on every channel + * do offer them; running them here would cause real side effects. + * - An agent whose sender has none of the channels it triggers on, which answers every dry + * run and no real message. + * - Contact metadata that exists on a real conversation but not here. + */ + fun warnings(warnings: List) = warnings(JsonField.of(warnings)) + + /** + * Sets [Builder.warnings] to an arbitrary JSON value. + * + * You should usually call [Builder.warnings] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun warnings(warnings: JsonField>) = apply { + this.warnings = warnings.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [warnings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWarning(warning: String) = apply { + warnings = + (warnings ?: JsonField.of(mutableListOf())).also { + checkKnown("warnings", it).add(warning) + } + } + + /** + * Tools that actually ran, in order, when the request set `executeTools`. Empty on a normal + * dry run, where nothing is executed. An entry with `ok: false` means the agent saw an + * error and answered around it, which is what a customer would have received. + */ + fun executedToolCalls(executedToolCalls: List) = + executedToolCalls(JsonField.of(executedToolCalls)) + + /** + * Sets [Builder.executedToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.executedToolCalls] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun executedToolCalls(executedToolCalls: JsonField>) = apply { + this.executedToolCalls = executedToolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [ExecutedToolCall] to [executedToolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExecutedToolCall(executedToolCall: ExecutedToolCall) = apply { + executedToolCalls = + (executedToolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("executedToolCalls", it).add(executedToolCall) + } + } + + 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 [AgentTestResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .error() + * .inputTokens() + * .knowledgeChunksUsed() + * .latencyMs() + * .outputTokens() + * .success() + * .text() + * .warnings() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentTestResponse = + AgentTestResponse( + checkRequired("error", error), + checkRequired("inputTokens", inputTokens), + checkRequired("knowledgeChunksUsed", knowledgeChunksUsed), + checkRequired("latencyMs", latencyMs), + checkRequired("outputTokens", outputTokens), + checkRequired("success", success), + checkRequired("text", text), + checkRequired("warnings", warnings).map { it.toImmutable() }, + (executedToolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentTestResponse = apply { + if (validated) { + return@apply + } + + error() + inputTokens() + knowledgeChunksUsed() + latencyMs() + outputTokens() + success() + text() + warnings() + executedToolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (error.asKnown().isPresent) 1 else 0) + + (if (inputTokens.asKnown().isPresent) 1 else 0) + + (if (knowledgeChunksUsed.asKnown().isPresent) 1 else 0) + + (if (latencyMs.asKnown().isPresent) 1 else 0) + + (if (outputTokens.asKnown().isPresent) 1 else 0) + + (if (success.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (warnings.asKnown().getOrNull()?.size ?: 0) + + (executedToolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ExecutedToolCall + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val ok: JsonField, + private val error: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("ok") @ExcludeMissing ok: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + ) : this(name, ok, error, mutableMapOf()) + + /** + * @throws ZavudevInvalidDataException 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") + + /** + * @throws ZavudevInvalidDataException 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 ok(): Boolean = ok.getRequired("ok") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * 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 [ok]. + * + * Unlike [ok], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ok") @ExcludeMissing fun _ok(): JsonField = ok + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + @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 [ExecutedToolCall]. + * + * The following fields are required: + * ```java + * .name() + * .ok() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExecutedToolCall]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var ok: JsonField? = null + private var error: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(executedToolCall: ExecutedToolCall) = apply { + name = executedToolCall.name + ok = executedToolCall.ok + error = executedToolCall.error + additionalProperties = executedToolCall.additionalProperties.toMutableMap() + } + + 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 ok(ok: Boolean) = ok(JsonField.of(ok)) + + /** + * Sets [Builder.ok] to an arbitrary JSON value. + * + * You should usually call [Builder.ok] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ok(ok: JsonField) = apply { this.ok = ok } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + 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 [ExecutedToolCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .ok() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExecutedToolCall = + ExecutedToolCall( + checkRequired("name", name), + checkRequired("ok", ok), + error, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ExecutedToolCall = apply { + if (validated) { + return@apply + } + + name() + ok() + error() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (name.asKnown().isPresent) 1 else 0) + + (if (ok.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExecutedToolCall && + name == other.name && + ok == other.ok && + error == other.error && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, ok, error, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExecutedToolCall{name=$name, ok=$ok, error=$error, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentTestResponse && + error == other.error && + inputTokens == other.inputTokens && + knowledgeChunksUsed == other.knowledgeChunksUsed && + latencyMs == other.latencyMs && + outputTokens == other.outputTokens && + success == other.success && + text == other.text && + warnings == other.warnings && + executedToolCalls == other.executedToolCalls && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + error, + inputTokens, + knowledgeChunksUsed, + latencyMs, + outputTokens, + success, + text, + warnings, + executedToolCalls, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentTestResponse{error=$error, inputTokens=$inputTokens, knowledgeChunksUsed=$knowledgeChunksUsed, latencyMs=$latencyMs, outputTokens=$outputTokens, success=$success, text=$text, warnings=$warnings, executedToolCalls=$executedToolCalls, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateParams.kt new file mode 100644 index 0000000..071af0b --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateParams.kt @@ -0,0 +1,2472 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.Enum +import com.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.Params +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.AgentProvider +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update an agent */ +class AgentUpdateParams +private constructor( + private val agentId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agentId(): Optional = Optional.ofNullable(agentId) + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiKey(): Optional = body.apiKey() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowMessages(): Optional = body.contextWindowMessages() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = body.enabled() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeContactMetadata(): Optional = body.includeContactMetadata() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = body.maxTokens() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = body.model() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * LLM provider for the AI agent. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun provider(): Optional = body.provider() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun systemPrompt(): Optional = body.systemPrompt() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun temperature(): Optional = body.temperature() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnChannels(): Optional> = body.triggerOnChannels() + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnMessageTypes(): Optional> = body.triggerOnMessageTypes() + + /** + * Voice Agent configuration. Patch this object to enable voice, change the greeting, or adjust + * call limits. Requires the Voice Agents feature to be enabled for your team. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voice(): Optional = body.voice() + + /** + * 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 [contextWindowMessages]. + * + * Unlike [contextWindowMessages], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _contextWindowMessages(): JsonField = body._contextWindowMessages() + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _enabled(): JsonField = body._enabled() + + /** + * Returns the raw JSON value of [includeContactMetadata]. + * + * Unlike [includeContactMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _includeContactMetadata(): JsonField = body._includeContactMetadata() + + /** + * 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 [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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _provider(): JsonField = body._provider() + + /** + * Returns the raw JSON value of [systemPrompt]. + * + * Unlike [systemPrompt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _systemPrompt(): JsonField = body._systemPrompt() + + /** + * 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 [triggerOnChannels]. + * + * Unlike [triggerOnChannels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _triggerOnChannels(): JsonField> = body._triggerOnChannels() + + /** + * Returns the raw JSON value of [triggerOnMessageTypes]. + * + * Unlike [triggerOnMessageTypes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _triggerOnMessageTypes(): JsonField> = body._triggerOnMessageTypes() + + /** + * Returns the raw JSON value of [voice]. + * + * Unlike [voice], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _voice(): JsonField = body._voice() + + 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) + + companion object { + + @JvmStatic fun none(): AgentUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgentUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentUpdateParams]. */ + class Builder internal constructor() { + + private var agentId: 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(agentUpdateParams: AgentUpdateParams) = apply { + agentId = agentUpdateParams.agentId + body = agentUpdateParams.body.toBuilder() + additionalHeaders = agentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = agentUpdateParams.additionalQueryParams.toBuilder() + } + + fun agentId(agentId: String?) = apply { this.agentId = agentId } + + /** Alias for calling [Builder.agentId] with `agentId.orElse(null)`. */ + fun agentId(agentId: Optional) = agentId(agentId.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: + * - [apiKey] + * - [contextWindowMessages] + * - [enabled] + * - [includeContactMetadata] + * - [maxTokens] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun apiKey(apiKey: String) = apply { body.apiKey(apiKey) } + + /** + * 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 contextWindowMessages(contextWindowMessages: Long) = apply { + body.contextWindowMessages(contextWindowMessages) + } + + /** + * Sets [Builder.contextWindowMessages] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowMessages] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun contextWindowMessages(contextWindowMessages: JsonField) = apply { + body.contextWindowMessages(contextWindowMessages) + } + + fun enabled(enabled: Boolean) = apply { body.enabled(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 { body.enabled(enabled) } + + fun includeContactMetadata(includeContactMetadata: Boolean) = apply { + body.includeContactMetadata(includeContactMetadata) + } + + /** + * Sets [Builder.includeContactMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.includeContactMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun includeContactMetadata(includeContactMetadata: JsonField) = apply { + body.includeContactMetadata(includeContactMetadata) + } + + 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 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 name(name: String) = apply { body.name(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 { body.name(name) } + + /** LLM provider for the AI agent. */ + fun provider(provider: AgentProvider) = apply { body.provider(provider) } + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [AgentProvider] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField) = apply { body.provider(provider) } + + fun systemPrompt(systemPrompt: String) = apply { body.systemPrompt(systemPrompt) } + + /** + * Sets [Builder.systemPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.systemPrompt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun systemPrompt(systemPrompt: JsonField) = apply { + body.systemPrompt(systemPrompt) + } + + 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 triggerOnChannels(triggerOnChannels: List) = apply { + body.triggerOnChannels(triggerOnChannels) + } + + /** + * Sets [Builder.triggerOnChannels] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnChannels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun triggerOnChannels(triggerOnChannels: JsonField>) = apply { + body.triggerOnChannels(triggerOnChannels) + } + + /** + * Adds a single [String] to [triggerOnChannels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnChannel(triggerOnChannel: String) = apply { + body.addTriggerOnChannel(triggerOnChannel) + } + + fun triggerOnMessageTypes(triggerOnMessageTypes: List) = apply { + body.triggerOnMessageTypes(triggerOnMessageTypes) + } + + /** + * Sets [Builder.triggerOnMessageTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnMessageTypes] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun triggerOnMessageTypes(triggerOnMessageTypes: JsonField>) = apply { + body.triggerOnMessageTypes(triggerOnMessageTypes) + } + + /** + * Adds a single [String] to [triggerOnMessageTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnMessageType(triggerOnMessageType: String) = apply { + body.addTriggerOnMessageType(triggerOnMessageType) + } + + /** + * Voice Agent configuration. Patch this object to enable voice, change the greeting, or + * adjust call limits. Requires the Voice Agents feature to be enabled for your team. + */ + fun voice(voice: Voice) = apply { body.voice(voice) } + + /** + * Sets [Builder.voice] to an arbitrary JSON value. + * + * You should usually call [Builder.voice] with a well-typed [Voice] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun voice(voice: JsonField) = apply { body.voice(voice) } + + 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 [AgentUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentUpdateParams = + AgentUpdateParams( + agentId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> agentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val apiKey: JsonField, + private val contextWindowMessages: JsonField, + private val enabled: JsonField, + private val includeContactMetadata: JsonField, + private val maxTokens: JsonField, + private val model: JsonField, + private val name: JsonField, + private val provider: JsonField, + private val systemPrompt: JsonField, + private val temperature: JsonField, + private val triggerOnChannels: JsonField>, + private val triggerOnMessageTypes: JsonField>, + private val voice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("apiKey") @ExcludeMissing apiKey: JsonField = JsonMissing.of(), + @JsonProperty("contextWindowMessages") + @ExcludeMissing + contextWindowMessages: JsonField = JsonMissing.of(), + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("includeContactMetadata") + @ExcludeMissing + includeContactMetadata: JsonField = JsonMissing.of(), + @JsonProperty("maxTokens") + @ExcludeMissing + maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField = JsonMissing.of(), + @JsonProperty("systemPrompt") + @ExcludeMissing + systemPrompt: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + temperature: JsonField = JsonMissing.of(), + @JsonProperty("triggerOnChannels") + @ExcludeMissing + triggerOnChannels: JsonField> = JsonMissing.of(), + @JsonProperty("triggerOnMessageTypes") + @ExcludeMissing + triggerOnMessageTypes: JsonField> = JsonMissing.of(), + @JsonProperty("voice") @ExcludeMissing voice: JsonField = JsonMissing.of(), + ) : this( + apiKey, + contextWindowMessages, + enabled, + includeContactMetadata, + maxTokens, + model, + name, + provider, + systemPrompt, + temperature, + triggerOnChannels, + triggerOnMessageTypes, + voice, + mutableMapOf(), + ) + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("apiKey") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contextWindowMessages(): Optional = + contextWindowMessages.getOptional("contextWindowMessages") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = enabled.getOptional("enabled") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeContactMetadata(): Optional = + includeContactMetadata.getOptional("includeContactMetadata") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxTokens(): Optional = maxTokens.getOptional("maxTokens") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * LLM provider for the AI agent. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun provider(): Optional = provider.getOptional("provider") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun systemPrompt(): Optional = systemPrompt.getOptional("systemPrompt") + + /** + * @throws ZavudevInvalidDataException 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 ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnChannels(): Optional> = + triggerOnChannels.getOptional("triggerOnChannels") + + /** + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun triggerOnMessageTypes(): Optional> = + triggerOnMessageTypes.getOptional("triggerOnMessageTypes") + + /** + * Voice Agent configuration. Patch this object to enable voice, change the greeting, or + * adjust call limits. Requires the Voice Agents feature to be enabled for your team. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voice(): Optional = voice.getOptional("voice") + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [contextWindowMessages]. + * + * Unlike [contextWindowMessages], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contextWindowMessages") + @ExcludeMissing + fun _contextWindowMessages(): JsonField = contextWindowMessages + + /** + * 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 + + /** + * Returns the raw JSON value of [includeContactMetadata]. + * + * Unlike [includeContactMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeContactMetadata") + @ExcludeMissing + fun _includeContactMetadata(): JsonField = includeContactMetadata + + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxTokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + + /** + * 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 [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 [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") + @ExcludeMissing + fun _provider(): JsonField = provider + + /** + * Returns the raw JSON value of [systemPrompt]. + * + * Unlike [systemPrompt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("systemPrompt") + @ExcludeMissing + fun _systemPrompt(): JsonField = systemPrompt + + /** + * 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 [triggerOnChannels]. + * + * Unlike [triggerOnChannels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("triggerOnChannels") + @ExcludeMissing + fun _triggerOnChannels(): JsonField> = triggerOnChannels + + /** + * Returns the raw JSON value of [triggerOnMessageTypes]. + * + * Unlike [triggerOnMessageTypes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("triggerOnMessageTypes") + @ExcludeMissing + fun _triggerOnMessageTypes(): JsonField> = triggerOnMessageTypes + + /** + * Returns the raw JSON value of [voice]. + * + * Unlike [voice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voice") @ExcludeMissing fun _voice(): JsonField = voice + + @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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var apiKey: JsonField = JsonMissing.of() + private var contextWindowMessages: JsonField = JsonMissing.of() + private var enabled: JsonField = JsonMissing.of() + private var includeContactMetadata: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() + private var systemPrompt: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var triggerOnChannels: JsonField>? = null + private var triggerOnMessageTypes: JsonField>? = null + private var voice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + apiKey = body.apiKey + contextWindowMessages = body.contextWindowMessages + enabled = body.enabled + includeContactMetadata = body.includeContactMetadata + maxTokens = body.maxTokens + model = body.model + name = body.name + provider = body.provider + systemPrompt = body.systemPrompt + temperature = body.temperature + triggerOnChannels = body.triggerOnChannels.map { it.toMutableList() } + triggerOnMessageTypes = body.triggerOnMessageTypes.map { it.toMutableList() } + voice = body.voice + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey)) + + /** + * 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 contextWindowMessages(contextWindowMessages: Long) = + contextWindowMessages(JsonField.of(contextWindowMessages)) + + /** + * Sets [Builder.contextWindowMessages] to an arbitrary JSON value. + * + * You should usually call [Builder.contextWindowMessages] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun contextWindowMessages(contextWindowMessages: JsonField) = apply { + this.contextWindowMessages = contextWindowMessages + } + + 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 includeContactMetadata(includeContactMetadata: Boolean) = + includeContactMetadata(JsonField.of(includeContactMetadata)) + + /** + * Sets [Builder.includeContactMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.includeContactMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeContactMetadata(includeContactMetadata: JsonField) = apply { + this.includeContactMetadata = includeContactMetadata + } + + 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 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 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 } + + /** LLM provider for the AI agent. */ + fun provider(provider: AgentProvider) = provider(JsonField.of(provider)) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [AgentProvider] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } + + fun systemPrompt(systemPrompt: String) = systemPrompt(JsonField.of(systemPrompt)) + + /** + * Sets [Builder.systemPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.systemPrompt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun systemPrompt(systemPrompt: JsonField) = apply { + this.systemPrompt = systemPrompt + } + + 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 triggerOnChannels(triggerOnChannels: List) = + triggerOnChannels(JsonField.of(triggerOnChannels)) + + /** + * Sets [Builder.triggerOnChannels] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnChannels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun triggerOnChannels(triggerOnChannels: JsonField>) = apply { + this.triggerOnChannels = triggerOnChannels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [triggerOnChannels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnChannel(triggerOnChannel: String) = apply { + triggerOnChannels = + (triggerOnChannels ?: JsonField.of(mutableListOf())).also { + checkKnown("triggerOnChannels", it).add(triggerOnChannel) + } + } + + fun triggerOnMessageTypes(triggerOnMessageTypes: List) = + triggerOnMessageTypes(JsonField.of(triggerOnMessageTypes)) + + /** + * Sets [Builder.triggerOnMessageTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.triggerOnMessageTypes] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun triggerOnMessageTypes(triggerOnMessageTypes: JsonField>) = apply { + this.triggerOnMessageTypes = triggerOnMessageTypes.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [triggerOnMessageTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTriggerOnMessageType(triggerOnMessageType: String) = apply { + triggerOnMessageTypes = + (triggerOnMessageTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("triggerOnMessageTypes", it).add(triggerOnMessageType) + } + } + + /** + * Voice Agent configuration. Patch this object to enable voice, change the greeting, or + * adjust call limits. Requires the Voice Agents feature to be enabled for your team. + */ + fun voice(voice: Voice) = voice(JsonField.of(voice)) + + /** + * Sets [Builder.voice] to an arbitrary JSON value. + * + * You should usually call [Builder.voice] with a well-typed [Voice] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun voice(voice: JsonField) = apply { this.voice = voice } + + 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. + */ + fun build(): Body = + Body( + apiKey, + contextWindowMessages, + enabled, + includeContactMetadata, + maxTokens, + model, + name, + provider, + systemPrompt, + temperature, + (triggerOnChannels ?: JsonMissing.of()).map { it.toImmutable() }, + (triggerOnMessageTypes ?: JsonMissing.of()).map { it.toImmutable() }, + voice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + apiKey() + contextWindowMessages() + enabled() + includeContactMetadata() + maxTokens() + model() + name() + provider().ifPresent { it.validate() } + systemPrompt() + temperature() + triggerOnChannels() + triggerOnMessageTypes() + voice().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (contextWindowMessages.asKnown().isPresent) 1 else 0) + + (if (enabled.asKnown().isPresent) 1 else 0) + + (if (includeContactMetadata.asKnown().isPresent) 1 else 0) + + (if (maxTokens.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (provider.asKnown().getOrNull()?.validity() ?: 0) + + (if (systemPrompt.asKnown().isPresent) 1 else 0) + + (if (temperature.asKnown().isPresent) 1 else 0) + + (triggerOnChannels.asKnown().getOrNull()?.size ?: 0) + + (triggerOnMessageTypes.asKnown().getOrNull()?.size ?: 0) + + (voice.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + apiKey == other.apiKey && + contextWindowMessages == other.contextWindowMessages && + enabled == other.enabled && + includeContactMetadata == other.includeContactMetadata && + maxTokens == other.maxTokens && + model == other.model && + name == other.name && + provider == other.provider && + systemPrompt == other.systemPrompt && + temperature == other.temperature && + triggerOnChannels == other.triggerOnChannels && + triggerOnMessageTypes == other.triggerOnMessageTypes && + voice == other.voice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + apiKey, + contextWindowMessages, + enabled, + includeContactMetadata, + maxTokens, + model, + name, + provider, + systemPrompt, + temperature, + triggerOnChannels, + triggerOnMessageTypes, + voice, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{apiKey=$apiKey, contextWindowMessages=$contextWindowMessages, enabled=$enabled, includeContactMetadata=$includeContactMetadata, maxTokens=$maxTokens, model=$model, name=$name, provider=$provider, systemPrompt=$systemPrompt, temperature=$temperature, triggerOnChannels=$triggerOnChannels, triggerOnMessageTypes=$triggerOnMessageTypes, voice=$voice, additionalProperties=$additionalProperties}" + } + + /** + * Voice Agent configuration. Patch this object to enable voice, change the greeting, or adjust + * call limits. Requires the Voice Agents feature to be enabled for your team. + */ + class Voice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val greeting: JsonField, + private val greetings: JsonField, + private val interruptible: JsonField, + private val language: JsonField, + private val maxCallDurationMinutes: JsonField, + private val maxIdleSeconds: JsonField, + private val model: JsonField, + private val recordCalls: JsonField, + private val sttModel: JsonField, + private val sttProvider: JsonField, + private val transferPhoneNumber: JsonField, + private val ttsProvider: JsonField, + private val ttsVoiceId: JsonField, + private val voicemailAction: JsonField, + private val voicemailMessage: JsonField, + private val voiceSpeed: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("greeting") + @ExcludeMissing + greeting: JsonField = JsonMissing.of(), + @JsonProperty("greetings") + @ExcludeMissing + greetings: JsonField = JsonMissing.of(), + @JsonProperty("interruptible") + @ExcludeMissing + interruptible: JsonField = JsonMissing.of(), + @JsonProperty("language") + @ExcludeMissing + language: JsonField = JsonMissing.of(), + @JsonProperty("maxCallDurationMinutes") + @ExcludeMissing + maxCallDurationMinutes: JsonField = JsonMissing.of(), + @JsonProperty("maxIdleSeconds") + @ExcludeMissing + maxIdleSeconds: JsonField = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("recordCalls") + @ExcludeMissing + recordCalls: JsonField = JsonMissing.of(), + @JsonProperty("sttModel") + @ExcludeMissing + sttModel: JsonField = JsonMissing.of(), + @JsonProperty("sttProvider") + @ExcludeMissing + sttProvider: JsonField = JsonMissing.of(), + @JsonProperty("transferPhoneNumber") + @ExcludeMissing + transferPhoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("ttsProvider") + @ExcludeMissing + ttsProvider: JsonField = JsonMissing.of(), + @JsonProperty("ttsVoiceId") + @ExcludeMissing + ttsVoiceId: JsonField = JsonMissing.of(), + @JsonProperty("voicemailAction") + @ExcludeMissing + voicemailAction: JsonField = JsonMissing.of(), + @JsonProperty("voicemailMessage") + @ExcludeMissing + voicemailMessage: JsonField = JsonMissing.of(), + @JsonProperty("voiceSpeed") + @ExcludeMissing + voiceSpeed: JsonField = JsonMissing.of(), + ) : this( + enabled, + greeting, + greetings, + interruptible, + language, + maxCallDurationMinutes, + maxIdleSeconds, + model, + recordCalls, + sttModel, + sttProvider, + transferPhoneNumber, + ttsProvider, + ttsVoiceId, + voicemailAction, + voicemailMessage, + voiceSpeed, + mutableMapOf(), + ) + + /** + * Whether the agent handles voice calls. When false, the sender's number is not answered by + * the voice agent and outbound calls are rejected. + * + * @throws ZavudevInvalidDataException 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") + + /** + * Opening line the agent speaks when the call connects. If omitted, the agent waits for the + * caller to speak first. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun greeting(): Optional = greeting.getOptional("greeting") + + /** + * Greeting per language, keyed by language code. Used when the caller's language differs + * from the one `greeting` is written in. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun greetings(): Optional = greetings.getOptional("greetings") + + /** + * Whether the caller can interrupt the agent while it is speaking (barge-in). When true, + * the agent stops talking as soon as the caller starts. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun interruptible(): Optional = interruptible.getOptional("interruptible") + + /** + * BCP-47 language code used for both speech recognition and speech synthesis (e.g. `en`, + * `es`, `pt-BR`). Auto-detected from the recipient when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun language(): Optional = language.getOptional("language") + + /** + * Hard limit on call length in minutes. The call ends automatically when reached. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxCallDurationMinutes(): Optional = + maxCallDurationMinutes.getOptional("maxCallDurationMinutes") + + /** + * How long the agent waits during silence before ending the call. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxIdleSeconds(): Optional = maxIdleSeconds.getOptional("maxIdleSeconds") + + /** + * Model that runs the conversation, co-located in the voice network for lowest latency. + * Independent of the model used for text messaging. Derived from the agent's text model + * when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") + + /** + * Whether the call audio is recorded. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordCalls(): Optional = recordCalls.getOptional("recordCalls") + + /** + * Speech-recognition model. Uses the default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sttModel(): Optional = sttModel.getOptional("sttModel") + + /** + * Speech-recognition provider. Uses the default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sttProvider(): Optional = sttProvider.getOptional("sttProvider") + + /** + * E.164 phone number the agent can transfer the call to. When set, the agent is given a + * transfer tool it can use to hand the call to a human. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transferPhoneNumber(): Optional = + transferPhoneNumber.getOptional("transferPhoneNumber") + + /** + * Speech-synthesis provider. Uses the default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ttsProvider(): Optional = ttsProvider.getOptional("ttsProvider") + + /** + * Identifier of the synthesized voice that speaks. Choose from the voices available in the + * dashboard. Uses a neutral default when omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ttsVoiceId(): Optional = ttsVoiceId.getOptional("ttsVoiceId") + + /** + * What the agent does when an answering machine or voicemail is detected on an outbound + * call. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voicemailAction(): Optional = + voicemailAction.getOptional("voicemailAction") + + /** + * Message spoken when `voicemailAction` is `leave_message`. Falls back to `greeting` when + * omitted. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voicemailMessage(): Optional = voicemailMessage.getOptional("voicemailMessage") + + /** + * Speech rate. 1.0 is natural. Only honoured by voices that support rate control; ignored + * by the others. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voiceSpeed(): Optional = voiceSpeed.getOptional("voiceSpeed") + + /** + * 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 + + /** + * Returns the raw JSON value of [greeting]. + * + * Unlike [greeting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("greeting") @ExcludeMissing fun _greeting(): JsonField = greeting + + /** + * Returns the raw JSON value of [greetings]. + * + * Unlike [greetings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("greetings") + @ExcludeMissing + fun _greetings(): JsonField = greetings + + /** + * Returns the raw JSON value of [interruptible]. + * + * Unlike [interruptible], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interruptible") + @ExcludeMissing + fun _interruptible(): JsonField = interruptible + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + /** + * Returns the raw JSON value of [maxCallDurationMinutes]. + * + * Unlike [maxCallDurationMinutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maxCallDurationMinutes") + @ExcludeMissing + fun _maxCallDurationMinutes(): JsonField = maxCallDurationMinutes + + /** + * Returns the raw JSON value of [maxIdleSeconds]. + * + * Unlike [maxIdleSeconds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maxIdleSeconds") + @ExcludeMissing + fun _maxIdleSeconds(): JsonField = maxIdleSeconds + + /** + * 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 [recordCalls]. + * + * Unlike [recordCalls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recordCalls") + @ExcludeMissing + fun _recordCalls(): JsonField = recordCalls + + /** + * Returns the raw JSON value of [sttModel]. + * + * Unlike [sttModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sttModel") @ExcludeMissing fun _sttModel(): JsonField = sttModel + + /** + * Returns the raw JSON value of [sttProvider]. + * + * Unlike [sttProvider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sttProvider") + @ExcludeMissing + fun _sttProvider(): JsonField = sttProvider + + /** + * Returns the raw JSON value of [transferPhoneNumber]. + * + * Unlike [transferPhoneNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("transferPhoneNumber") + @ExcludeMissing + fun _transferPhoneNumber(): JsonField = transferPhoneNumber + + /** + * Returns the raw JSON value of [ttsProvider]. + * + * Unlike [ttsProvider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttsProvider") + @ExcludeMissing + fun _ttsProvider(): JsonField = ttsProvider + + /** + * Returns the raw JSON value of [ttsVoiceId]. + * + * Unlike [ttsVoiceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttsVoiceId") + @ExcludeMissing + fun _ttsVoiceId(): JsonField = ttsVoiceId + + /** + * Returns the raw JSON value of [voicemailAction]. + * + * Unlike [voicemailAction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voicemailAction") + @ExcludeMissing + fun _voicemailAction(): JsonField = voicemailAction + + /** + * Returns the raw JSON value of [voicemailMessage]. + * + * Unlike [voicemailMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voicemailMessage") + @ExcludeMissing + fun _voicemailMessage(): JsonField = voicemailMessage + + /** + * Returns the raw JSON value of [voiceSpeed]. + * + * Unlike [voiceSpeed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voiceSpeed") + @ExcludeMissing + fun _voiceSpeed(): JsonField = voiceSpeed + + @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 [Voice]. + * + * The following fields are required: + * ```java + * .enabled() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Voice]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var greeting: JsonField = JsonMissing.of() + private var greetings: JsonField = JsonMissing.of() + private var interruptible: JsonField = JsonMissing.of() + private var language: JsonField = JsonMissing.of() + private var maxCallDurationMinutes: JsonField = JsonMissing.of() + private var maxIdleSeconds: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var recordCalls: JsonField = JsonMissing.of() + private var sttModel: JsonField = JsonMissing.of() + private var sttProvider: JsonField = JsonMissing.of() + private var transferPhoneNumber: JsonField = JsonMissing.of() + private var ttsProvider: JsonField = JsonMissing.of() + private var ttsVoiceId: JsonField = JsonMissing.of() + private var voicemailAction: JsonField = JsonMissing.of() + private var voicemailMessage: JsonField = JsonMissing.of() + private var voiceSpeed: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(voice: Voice) = apply { + enabled = voice.enabled + greeting = voice.greeting + greetings = voice.greetings + interruptible = voice.interruptible + language = voice.language + maxCallDurationMinutes = voice.maxCallDurationMinutes + maxIdleSeconds = voice.maxIdleSeconds + model = voice.model + recordCalls = voice.recordCalls + sttModel = voice.sttModel + sttProvider = voice.sttProvider + transferPhoneNumber = voice.transferPhoneNumber + ttsProvider = voice.ttsProvider + ttsVoiceId = voice.ttsVoiceId + voicemailAction = voice.voicemailAction + voicemailMessage = voice.voicemailMessage + voiceSpeed = voice.voiceSpeed + additionalProperties = voice.additionalProperties.toMutableMap() + } + + /** + * Whether the agent handles voice calls. When false, the sender's number is not + * answered by the voice agent and outbound calls are rejected. + */ + 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 } + + /** + * Opening line the agent speaks when the call connects. If omitted, the agent waits for + * the caller to speak first. + */ + fun greeting(greeting: String) = greeting(JsonField.of(greeting)) + + /** + * Sets [Builder.greeting] to an arbitrary JSON value. + * + * You should usually call [Builder.greeting] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun greeting(greeting: JsonField) = apply { this.greeting = greeting } + + /** + * Greeting per language, keyed by language code. Used when the caller's language + * differs from the one `greeting` is written in. + */ + fun greetings(greetings: Greetings) = greetings(JsonField.of(greetings)) + + /** + * Sets [Builder.greetings] to an arbitrary JSON value. + * + * You should usually call [Builder.greetings] with a well-typed [Greetings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun greetings(greetings: JsonField) = apply { this.greetings = greetings } + + /** + * Whether the caller can interrupt the agent while it is speaking (barge-in). When + * true, the agent stops talking as soon as the caller starts. + */ + fun interruptible(interruptible: Boolean) = interruptible(JsonField.of(interruptible)) + + /** + * Sets [Builder.interruptible] to an arbitrary JSON value. + * + * You should usually call [Builder.interruptible] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun interruptible(interruptible: JsonField) = apply { + this.interruptible = interruptible + } + + /** + * BCP-47 language code used for both speech recognition and speech synthesis (e.g. + * `en`, `es`, `pt-BR`). Auto-detected from the recipient when omitted. + */ + fun language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + /** Hard limit on call length in minutes. The call ends automatically when reached. */ + fun maxCallDurationMinutes(maxCallDurationMinutes: Long) = + maxCallDurationMinutes(JsonField.of(maxCallDurationMinutes)) + + /** + * Sets [Builder.maxCallDurationMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.maxCallDurationMinutes] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maxCallDurationMinutes(maxCallDurationMinutes: JsonField) = apply { + this.maxCallDurationMinutes = maxCallDurationMinutes + } + + /** How long the agent waits during silence before ending the call. */ + fun maxIdleSeconds(maxIdleSeconds: Long) = maxIdleSeconds(JsonField.of(maxIdleSeconds)) + + /** + * Sets [Builder.maxIdleSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.maxIdleSeconds] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxIdleSeconds(maxIdleSeconds: JsonField) = apply { + this.maxIdleSeconds = maxIdleSeconds + } + + /** + * Model that runs the conversation, co-located in the voice network for lowest latency. + * Independent of the model used for text messaging. Derived from the agent's text model + * when omitted. + */ + 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 } + + /** Whether the call audio is recorded. */ + fun recordCalls(recordCalls: Boolean) = recordCalls(JsonField.of(recordCalls)) + + /** + * Sets [Builder.recordCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.recordCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recordCalls(recordCalls: JsonField) = apply { + this.recordCalls = recordCalls + } + + /** Speech-recognition model. Uses the default when omitted. */ + fun sttModel(sttModel: String) = sttModel(JsonField.of(sttModel)) + + /** + * Sets [Builder.sttModel] to an arbitrary JSON value. + * + * You should usually call [Builder.sttModel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sttModel(sttModel: JsonField) = apply { this.sttModel = sttModel } + + /** Speech-recognition provider. Uses the default when omitted. */ + fun sttProvider(sttProvider: String) = sttProvider(JsonField.of(sttProvider)) + + /** + * Sets [Builder.sttProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.sttProvider] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sttProvider(sttProvider: JsonField) = apply { + this.sttProvider = sttProvider + } + + /** + * E.164 phone number the agent can transfer the call to. When set, the agent is given a + * transfer tool it can use to hand the call to a human. + */ + fun transferPhoneNumber(transferPhoneNumber: String) = + transferPhoneNumber(JsonField.of(transferPhoneNumber)) + + /** + * Sets [Builder.transferPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.transferPhoneNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transferPhoneNumber(transferPhoneNumber: JsonField) = apply { + this.transferPhoneNumber = transferPhoneNumber + } + + /** Speech-synthesis provider. Uses the default when omitted. */ + fun ttsProvider(ttsProvider: String) = ttsProvider(JsonField.of(ttsProvider)) + + /** + * Sets [Builder.ttsProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.ttsProvider] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ttsProvider(ttsProvider: JsonField) = apply { + this.ttsProvider = ttsProvider + } + + /** + * Identifier of the synthesized voice that speaks. Choose from the voices available in + * the dashboard. Uses a neutral default when omitted. + */ + fun ttsVoiceId(ttsVoiceId: String) = ttsVoiceId(JsonField.of(ttsVoiceId)) + + /** + * Sets [Builder.ttsVoiceId] to an arbitrary JSON value. + * + * You should usually call [Builder.ttsVoiceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ttsVoiceId(ttsVoiceId: JsonField) = apply { this.ttsVoiceId = ttsVoiceId } + + /** + * What the agent does when an answering machine or voicemail is detected on an outbound + * call. + */ + fun voicemailAction(voicemailAction: VoicemailAction) = + voicemailAction(JsonField.of(voicemailAction)) + + /** + * Sets [Builder.voicemailAction] to an arbitrary JSON value. + * + * You should usually call [Builder.voicemailAction] with a well-typed [VoicemailAction] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voicemailAction(voicemailAction: JsonField) = apply { + this.voicemailAction = voicemailAction + } + + /** + * Message spoken when `voicemailAction` is `leave_message`. Falls back to `greeting` + * when omitted. + */ + fun voicemailMessage(voicemailMessage: String) = + voicemailMessage(JsonField.of(voicemailMessage)) + + /** + * Sets [Builder.voicemailMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.voicemailMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voicemailMessage(voicemailMessage: JsonField) = apply { + this.voicemailMessage = voicemailMessage + } + + /** + * Speech rate. 1.0 is natural. Only honoured by voices that support rate control; + * ignored by the others. + */ + fun voiceSpeed(voiceSpeed: Double) = voiceSpeed(JsonField.of(voiceSpeed)) + + /** + * Sets [Builder.voiceSpeed] to an arbitrary JSON value. + * + * You should usually call [Builder.voiceSpeed] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voiceSpeed(voiceSpeed: JsonField) = apply { this.voiceSpeed = voiceSpeed } + + 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 [Voice]. + * + * 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(): Voice = + Voice( + checkRequired("enabled", enabled), + greeting, + greetings, + interruptible, + language, + maxCallDurationMinutes, + maxIdleSeconds, + model, + recordCalls, + sttModel, + sttProvider, + transferPhoneNumber, + ttsProvider, + ttsVoiceId, + voicemailAction, + voicemailMessage, + voiceSpeed, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Voice = apply { + if (validated) { + return@apply + } + + enabled() + greeting() + greetings().ifPresent { it.validate() } + interruptible() + language() + maxCallDurationMinutes() + maxIdleSeconds() + model() + recordCalls() + sttModel() + sttProvider() + transferPhoneNumber() + ttsProvider() + ttsVoiceId() + voicemailAction().ifPresent { it.validate() } + voicemailMessage() + voiceSpeed() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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) + + (if (greeting.asKnown().isPresent) 1 else 0) + + (greetings.asKnown().getOrNull()?.validity() ?: 0) + + (if (interruptible.asKnown().isPresent) 1 else 0) + + (if (language.asKnown().isPresent) 1 else 0) + + (if (maxCallDurationMinutes.asKnown().isPresent) 1 else 0) + + (if (maxIdleSeconds.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (recordCalls.asKnown().isPresent) 1 else 0) + + (if (sttModel.asKnown().isPresent) 1 else 0) + + (if (sttProvider.asKnown().isPresent) 1 else 0) + + (if (transferPhoneNumber.asKnown().isPresent) 1 else 0) + + (if (ttsProvider.asKnown().isPresent) 1 else 0) + + (if (ttsVoiceId.asKnown().isPresent) 1 else 0) + + (voicemailAction.asKnown().getOrNull()?.validity() ?: 0) + + (if (voicemailMessage.asKnown().isPresent) 1 else 0) + + (if (voiceSpeed.asKnown().isPresent) 1 else 0) + + /** + * Greeting per language, keyed by language code. Used when the caller's language differs + * from the one `greeting` is written in. + */ + class Greetings + @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 [Greetings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Greetings]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(greetings: Greetings) = apply { + additionalProperties = greetings.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 [Greetings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Greetings = Greetings(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Greetings = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 Greetings && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Greetings{additionalProperties=$additionalProperties}" + } + + /** + * What the agent does when an answering machine or voicemail is detected on an outbound + * call. + */ + class VoicemailAction + @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 HANGUP = of("hangup") + + @JvmField val LEAVE_MESSAGE = of("leave_message") + + @JvmStatic fun of(value: String) = VoicemailAction(JsonField.of(value)) + } + + /** An enum containing [VoicemailAction]'s known values. */ + enum class Known { + HANGUP, + LEAVE_MESSAGE, + } + + /** + * An enum containing [VoicemailAction]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [VoicemailAction] 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 { + HANGUP, + LEAVE_MESSAGE, + /** + * An enum member indicating that [VoicemailAction] 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) { + HANGUP -> Value.HANGUP + LEAVE_MESSAGE -> Value.LEAVE_MESSAGE + 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 ZavudevInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + HANGUP -> Known.HANGUP + LEAVE_MESSAGE -> Known.LEAVE_MESSAGE + else -> throw ZavudevInvalidDataException("Unknown VoicemailAction: $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 ZavudevInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ZavudevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): VoicemailAction = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 VoicemailAction && 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 Voice && + enabled == other.enabled && + greeting == other.greeting && + greetings == other.greetings && + interruptible == other.interruptible && + language == other.language && + maxCallDurationMinutes == other.maxCallDurationMinutes && + maxIdleSeconds == other.maxIdleSeconds && + model == other.model && + recordCalls == other.recordCalls && + sttModel == other.sttModel && + sttProvider == other.sttProvider && + transferPhoneNumber == other.transferPhoneNumber && + ttsProvider == other.ttsProvider && + ttsVoiceId == other.ttsVoiceId && + voicemailAction == other.voicemailAction && + voicemailMessage == other.voicemailMessage && + voiceSpeed == other.voiceSpeed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + greeting, + greetings, + interruptible, + language, + maxCallDurationMinutes, + maxIdleSeconds, + model, + recordCalls, + sttModel, + sttProvider, + transferPhoneNumber, + ttsProvider, + ttsVoiceId, + voicemailAction, + voicemailMessage, + voiceSpeed, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Voice{enabled=$enabled, greeting=$greeting, greetings=$greetings, interruptible=$interruptible, language=$language, maxCallDurationMinutes=$maxCallDurationMinutes, maxIdleSeconds=$maxIdleSeconds, model=$model, recordCalls=$recordCalls, sttModel=$sttModel, sttProvider=$sttProvider, transferPhoneNumber=$transferPhoneNumber, ttsProvider=$ttsProvider, ttsVoiceId=$ttsVoiceId, voicemailAction=$voicemailAction, voicemailMessage=$voicemailMessage, voiceSpeed=$voiceSpeed, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentUpdateParams && + agentId == other.agentId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(agentId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentUpdateParams{agentId=$agentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateResponse.kt new file mode 100644 index 0000000..93117ca --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateResponse.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkRequired +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.Agent +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AgentUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val agent: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of() + ) : this(agent, mutableMapOf()) + + /** + * AI Agent configuration for a sender. + * + * @throws ZavudevInvalidDataException 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 agent(): Agent = agent.getRequired("agent") + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + @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 [AgentUpdateResponse]. + * + * The following fields are required: + * ```java + * .agent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentUpdateResponse]. */ + class Builder internal constructor() { + + private var agent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentUpdateResponse: AgentUpdateResponse) = apply { + agent = agentUpdateResponse.agent + additionalProperties = agentUpdateResponse.additionalProperties.toMutableMap() + } + + /** AI Agent configuration for a sender. */ + fun agent(agent: Agent) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + 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 [AgentUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentUpdateResponse = + AgentUpdateResponse(checkRequired("agent", agent), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentUpdateResponse = apply { + if (validated) { + return@apply + } + + agent().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (agent.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentUpdateResponse && + agent == other.agent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(agent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentUpdateResponse{agent=$agent, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectParams.kt new file mode 100644 index 0000000..01a1a5e --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectParams.kt @@ -0,0 +1,449 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents.senders + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.Params +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import com.zavudev.api.errors.ZavudevInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Make the agent answer on this sender. An agent can serve several senders; a sender answers with + * at most one agent, so connecting one that is already in use returns `400` naming the agent that + * holds it. + */ +class SenderConnectParams +private constructor( + private val agentId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agentId(): Optional = Optional.ofNullable(agentId) + + /** + * Sender to connect. + * + * @throws ZavudevInvalidDataException 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 senderId(): String = body.senderId() + + /** + * Returns the raw JSON value of [senderId]. + * + * Unlike [senderId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _senderId(): JsonField = body._senderId() + + 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) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SenderConnectParams]. + * + * The following fields are required: + * ```java + * .senderId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SenderConnectParams]. */ + class Builder internal constructor() { + + private var agentId: 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(senderConnectParams: SenderConnectParams) = apply { + agentId = senderConnectParams.agentId + body = senderConnectParams.body.toBuilder() + additionalHeaders = senderConnectParams.additionalHeaders.toBuilder() + additionalQueryParams = senderConnectParams.additionalQueryParams.toBuilder() + } + + fun agentId(agentId: String?) = apply { this.agentId = agentId } + + /** Alias for calling [Builder.agentId] with `agentId.orElse(null)`. */ + fun agentId(agentId: Optional) = agentId(agentId.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: + * - [senderId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Sender to connect. */ + fun senderId(senderId: String) = apply { body.senderId(senderId) } + + /** + * Sets [Builder.senderId] to an arbitrary JSON value. + * + * You should usually call [Builder.senderId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun senderId(senderId: JsonField) = apply { body.senderId(senderId) } + + 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 [SenderConnectParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .senderId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SenderConnectParams = + SenderConnectParams( + agentId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> agentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val senderId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("senderId") @ExcludeMissing senderId: JsonField = JsonMissing.of() + ) : this(senderId, mutableMapOf()) + + /** + * Sender to connect. + * + * @throws ZavudevInvalidDataException 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 senderId(): String = senderId.getRequired("senderId") + + /** + * Returns the raw JSON value of [senderId]. + * + * Unlike [senderId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("senderId") @ExcludeMissing fun _senderId(): JsonField = senderId + + @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 + * .senderId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var senderId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + senderId = body.senderId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Sender to connect. */ + fun senderId(senderId: String) = senderId(JsonField.of(senderId)) + + /** + * Sets [Builder.senderId] to an arbitrary JSON value. + * + * You should usually call [Builder.senderId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderId(senderId: JsonField) = apply { this.senderId = senderId } + + 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 + * .senderId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("senderId", senderId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + senderId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 (senderId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + senderId == other.senderId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(senderId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{senderId=$senderId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SenderConnectParams && + agentId == other.agentId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(agentId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SenderConnectParams{agentId=$agentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectResponse.kt new file mode 100644 index 0000000..d3c0cf8 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectResponse.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents.senders + +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.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkRequired +import com.zavudev.api.errors.ZavudevInvalidDataException +import com.zavudev.api.models.senders.agent.Agent +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class SenderConnectResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val agent: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of() + ) : this(agent, mutableMapOf()) + + /** + * AI Agent configuration for a sender. + * + * @throws ZavudevInvalidDataException 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 agent(): Agent = agent.getRequired("agent") + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + @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 [SenderConnectResponse]. + * + * The following fields are required: + * ```java + * .agent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SenderConnectResponse]. */ + class Builder internal constructor() { + + private var agent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(senderConnectResponse: SenderConnectResponse) = apply { + agent = senderConnectResponse.agent + additionalProperties = senderConnectResponse.additionalProperties.toMutableMap() + } + + /** AI Agent configuration for a sender. */ + fun agent(agent: Agent) = agent(JsonField.of(agent)) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + 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 [SenderConnectResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SenderConnectResponse = + SenderConnectResponse( + checkRequired("agent", agent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SenderConnectResponse = apply { + if (validated) { + return@apply + } + + agent().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (agent.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SenderConnectResponse && + agent == other.agent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(agent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SenderConnectResponse{agent=$agent, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderDisconnectParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderDisconnectParams.kt new file mode 100644 index 0000000..3fc1d28 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderDisconnectParams.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agents.senders + +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.Params +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import com.zavudev.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Stop the agent answering on this sender. The agent's primary sender is part of the agent itself + * and cannot be disconnected here. + */ +class SenderDisconnectParams +private constructor( + private val agentId: String, + private val senderId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun agentId(): String = agentId + + fun senderId(): Optional = Optional.ofNullable(senderId) + + /** 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) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SenderDisconnectParams]. + * + * The following fields are required: + * ```java + * .agentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SenderDisconnectParams]. */ + class Builder internal constructor() { + + private var agentId: String? = null + private var senderId: 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(senderDisconnectParams: SenderDisconnectParams) = apply { + agentId = senderDisconnectParams.agentId + senderId = senderDisconnectParams.senderId + additionalHeaders = senderDisconnectParams.additionalHeaders.toBuilder() + additionalQueryParams = senderDisconnectParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + senderDisconnectParams.additionalBodyProperties.toMutableMap() + } + + fun agentId(agentId: String) = apply { this.agentId = agentId } + + fun senderId(senderId: String?) = apply { this.senderId = senderId } + + /** Alias for calling [Builder.senderId] with `senderId.orElse(null)`. */ + fun senderId(senderId: Optional) = senderId(senderId.getOrNull()) + + 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) + } + + 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 [SenderDisconnectParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SenderDisconnectParams = + SenderDisconnectParams( + checkRequired("agentId", agentId), + senderId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> agentId + 1 -> senderId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SenderDisconnectParams && + agentId == other.agentId && + senderId == other.senderId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + agentId, + senderId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "SenderDisconnectParams{agentId=$agentId, senderId=$senderId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListParams.kt new file mode 100644 index 0000000..b885939 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListParams.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agenttemplates + +import com.zavudev.api.core.Params +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import java.util.Objects + +/** + * List the factory agents available to scaffold with `npx zavudev agents pull`. Each entry is a + * ready-made voice or text agent (system prompt, skills, and — for voice agents — a co-located + * voice config). + */ +class AgentTemplateListParams +private constructor( + private val additionalHeaders: Headers, + 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) + + companion object { + + @JvmStatic fun none(): AgentTemplateListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgentTemplateListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentTemplateListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agentTemplateListParams: AgentTemplateListParams) = apply { + additionalHeaders = agentTemplateListParams.additionalHeaders.toBuilder() + additionalQueryParams = agentTemplateListParams.additionalQueryParams.toBuilder() + } + + 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 [AgentTemplateListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentTemplateListParams = + AgentTemplateListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentTemplateListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentTemplateListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListResponse.kt new file mode 100644 index 0000000..927257e --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListResponse.kt @@ -0,0 +1,696 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agenttemplates + +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.zavudev.api.core.Enum +import com.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AgentTemplateListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws ZavudevInvalidDataException 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 items(): List = items.getRequired("items") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + @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 [AgentTemplateListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentTemplateListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agentTemplateListResponse: AgentTemplateListResponse) = apply { + items = agentTemplateListResponse.items.map { it.toMutableList() } + additionalProperties = agentTemplateListResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + 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 [AgentTemplateListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AgentTemplateListResponse = + AgentTemplateListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AgentTemplateListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Compact catalog entry for a factory agent. */ + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val category: JsonField, + private val name: JsonField, + private val summary: JsonField, + private val toolCount: JsonField, + private val voice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), + @JsonProperty("toolCount") + @ExcludeMissing + toolCount: JsonField = JsonMissing.of(), + @JsonProperty("voice") @ExcludeMissing voice: JsonField = JsonMissing.of(), + ) : this(id, category, name, summary, toolCount, voice, mutableMapOf()) + + /** + * @throws ZavudevInvalidDataException 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") + + /** + * @throws ZavudevInvalidDataException 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 category(): Category = category.getRequired("category") + + /** + * @throws ZavudevInvalidDataException 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") + + /** + * @throws ZavudevInvalidDataException 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 summary(): String = summary.getRequired("summary") + + /** + * @throws ZavudevInvalidDataException 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 toolCount(): Long = toolCount.getRequired("toolCount") + + /** + * Whether this agent answers phone calls. + * + * @throws ZavudevInvalidDataException 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 voice(): Boolean = voice.getRequired("voice") + + /** + * 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 [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + + /** + * 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 [summary]. + * + * Unlike [summary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField = summary + + /** + * Returns the raw JSON value of [toolCount]. + * + * Unlike [toolCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("toolCount") @ExcludeMissing fun _toolCount(): JsonField = toolCount + + /** + * Returns the raw JSON value of [voice]. + * + * Unlike [voice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voice") @ExcludeMissing fun _voice(): JsonField = voice + + @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 [Item]. + * + * The following fields are required: + * ```java + * .id() + * .category() + * .name() + * .summary() + * .toolCount() + * .voice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var category: JsonField? = null + private var name: JsonField? = null + private var summary: JsonField? = null + private var toolCount: JsonField? = null + private var voice: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + category = item.category + name = item.name + summary = item.summary + toolCount = item.toolCount + voice = item.voice + additionalProperties = item.additionalProperties.toMutableMap() + } + + 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 category(category: Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [Category] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun category(category: JsonField) = apply { this.category = category } + + 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 summary(summary: String) = summary(JsonField.of(summary)) + + /** + * Sets [Builder.summary] to an arbitrary JSON value. + * + * You should usually call [Builder.summary] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun summary(summary: JsonField) = apply { this.summary = summary } + + fun toolCount(toolCount: Long) = toolCount(JsonField.of(toolCount)) + + /** + * Sets [Builder.toolCount] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolCount(toolCount: JsonField) = apply { this.toolCount = toolCount } + + /** Whether this agent answers phone calls. */ + fun voice(voice: Boolean) = voice(JsonField.of(voice)) + + /** + * Sets [Builder.voice] to an arbitrary JSON value. + * + * You should usually call [Builder.voice] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voice(voice: JsonField) = apply { this.voice = voice } + + 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 [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .category() + * .name() + * .summary() + * .toolCount() + * .voice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("category", category), + checkRequired("name", name), + checkRequired("summary", summary), + checkRequired("toolCount", toolCount), + checkRequired("voice", voice), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + category().validate() + name() + summary() + toolCount() + voice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (summary.asKnown().isPresent) 1 else 0) + + (if (toolCount.asKnown().isPresent) 1 else 0) + + (if (voice.asKnown().isPresent) 1 else 0) + + class Category @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 SALES = of("sales") + + @JvmField val SUPPORT = of("support") + + @JvmField val FRONT_DESK = of("frontDesk") + + @JvmField val OPS = of("ops") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + SALES, + SUPPORT, + FRONT_DESK, + OPS, + } + + /** + * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Category] 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 { + SALES, + SUPPORT, + FRONT_DESK, + OPS, + /** + * An enum member indicating that [Category] 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) { + SALES -> Value.SALES + SUPPORT -> Value.SUPPORT + FRONT_DESK -> Value.FRONT_DESK + OPS -> Value.OPS + 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 ZavudevInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SALES -> Known.SALES + SUPPORT -> Known.SUPPORT + FRONT_DESK -> Known.FRONT_DESK + OPS -> Known.OPS + else -> throw ZavudevInvalidDataException("Unknown Category: $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 ZavudevInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ZavudevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ZavudevInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ZavudevInvalidDataException) { + false + } + + /** + * Returns 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 Category && 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 Item && + id == other.id && + category == other.category && + name == other.name && + summary == other.summary && + toolCount == other.toolCount && + voice == other.voice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, category, name, summary, toolCount, voice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, category=$category, name=$name, summary=$summary, toolCount=$toolCount, voice=$voice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentTemplateListResponse && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgentTemplateListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveParams.kt new file mode 100644 index 0000000..df620a7 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveParams.kt @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agenttemplates + +import com.zavudev.api.core.Params +import com.zavudev.api.core.http.Headers +import com.zavudev.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Fetch a single factory agent fully rendered: the function files to scaffold (an `index.ts` that + * declares the agent with `defineAgent` and its skills with `defineTool`) plus the secrets it + * needs. This is what `npx zavudev agents pull ` writes to disk before `npx zavudev deploy`. + */ +class AgentTemplateRetrieveParams +private constructor( + private val templateId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun templateId(): Optional = Optional.ofNullable(templateId) + + /** 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) + + companion object { + + @JvmStatic fun none(): AgentTemplateRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AgentTemplateRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgentTemplateRetrieveParams]. */ + class Builder internal constructor() { + + private var templateId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agentTemplateRetrieveParams: AgentTemplateRetrieveParams) = apply { + templateId = agentTemplateRetrieveParams.templateId + additionalHeaders = agentTemplateRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = agentTemplateRetrieveParams.additionalQueryParams.toBuilder() + } + + fun templateId(templateId: String?) = apply { this.templateId = templateId } + + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) + + 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 [AgentTemplateRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgentTemplateRetrieveParams = + AgentTemplateRetrieveParams( + templateId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> templateId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AgentTemplateRetrieveParams && + templateId == other.templateId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(templateId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgentTemplateRetrieveParams{templateId=$templateId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveResponse.kt new file mode 100644 index 0000000..7712a70 --- /dev/null +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveResponse.kt @@ -0,0 +1,1394 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.zavudev.api.models.agenttemplates + +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.zavudev.api.core.Enum +import com.zavudev.api.core.ExcludeMissing +import com.zavudev.api.core.JsonField +import com.zavudev.api.core.JsonMissing +import com.zavudev.api.core.JsonValue +import com.zavudev.api.core.checkKnown +import com.zavudev.api.core.checkRequired +import com.zavudev.api.core.toImmutable +import com.zavudev.api.errors.ZavudevInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AgentTemplateRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val template: JsonField