From 97e8950d08e11209793497c6b202276c53f0f763 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 23:50:05 +0000 Subject: [PATCH 01/24] chore: update SDK settings --- .github/workflows/publish-sonatype.yml | 41 ++++++++++++ .github/workflows/release-doctor.yml | 24 +++++++ .release-please-manifest.json | 3 + .stats.yml | 4 +- README.md | 14 +++- bin/check-release-environment | 33 +++++++++ build.gradle.kts | 2 +- .../main/kotlin/zavudev.publish.gradle.kts | 6 +- release-please-config.json | 67 +++++++++++++++++++ .../main/kotlin/com/zavudev/api/core/Check.kt | 2 +- 10 files changed, 188 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish-sonatype.yml create mode 100644 .github/workflows/release-doctor.yml create mode 100644 .release-please-manifest.json create mode 100644 bin/check-release-environment create mode 100644 release-please-config.json 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..1332969 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 8413cc3..037d39e 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_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-ce051733263f4e5809b254dbe76a500eb4101355b294decac25dfd0b31509908.yml openapi_spec_hash: 6b119a3213e324f3826453deca57f10b -config_hash: d5d02dfde2ea057fdcf5b26e3a921f7a +config_hash: a541f8cf3cf7c3035a581a022d87dc0e diff --git a/README.md b/README.md index 506deb7..cc716b5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ # 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) + + The Zavudev Java SDK provides convenient access to the [Zavudev REST API](https://docs.zavu.dev) from applications written in Java. It is generated with [Stainless](https://www.stainless.com/). @@ -16,10 +20,16 @@ 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). + + ## Installation + + ### Gradle ```kotlin @@ -36,6 +46,8 @@ implementation("com.zavudev.api:zavudev-java:0.0.1") ``` + + ## 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..6301922 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.0.1" // 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/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() } From d91fb26b7bf0a68053341b7ba37d21eaabcc78dc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 23:50:27 +0000 Subject: [PATCH 02/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 037d39e..46aef62 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-ce051733263f4e5809b254dbe76a500eb4101355b294decac25dfd0b31509908.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-7e8b631015f94fd76c51f5c435bc3a22a858d1e40b89c0daf4ae8f1324412fa8.yml openapi_spec_hash: 6b119a3213e324f3826453deca57f10b -config_hash: a541f8cf3cf7c3035a581a022d87dc0e +config_hash: ef364b35e7dbd38ff92ce0ddaf429906 From be65cb57141e2426ddbc84f4d588309b256d2db5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 23:50:49 +0000 Subject: [PATCH 03/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 46aef62..754d90b 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-7e8b631015f94fd76c51f5c435bc3a22a858d1e40b89c0daf4ae8f1324412fa8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-86aec85be1021cea51f9fc0bb95248276c8b85e3ac0fd810490114599ed7cf00.yml openapi_spec_hash: 6b119a3213e324f3826453deca57f10b -config_hash: ef364b35e7dbd38ff92ce0ddaf429906 +config_hash: 7fca08d9dae18513f5d7451cea11e34c From e8dd549d4143f5b52c9382e556e13df063a596cc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 02:43:26 +0000 Subject: [PATCH 04/24] feat(api): api update --- .stats.yml | 4 +- .../models/functions/FunctionCreateParams.kt | 301 ++++++++++++++++- .../models/functions/FunctionDeployParams.kt | 310 ++++++++++++++++- .../functions/FunctionDeployResponse.kt | 6 + .../FunctionGetDeploymentResponse.kt | 6 + .../models/functions/FunctionUpdateParams.kt | 318 +++++++++++++++++- .../functions/FunctionCreateParamsTest.kt | 52 +++ .../functions/FunctionDeployParamsTest.kt | 52 +++ .../functions/FunctionUpdateParamsTest.kt | 52 +++ .../async/FunctionServiceAsyncTest.kt | 51 +++ .../services/blocking/FunctionServiceTest.kt | 51 +++ 11 files changed, 1177 insertions(+), 26 deletions(-) diff --git a/.stats.yml b/.stats.yml index 754d90b..484237c 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-86aec85be1021cea51f9fc0bb95248276c8b85e3ac0fd810490114599ed7cf00.yml -openapi_spec_hash: 6b119a3213e324f3826453deca57f10b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-21db15ab8c7fc4a95f96e62e9ae84d4db9696f41adf62806c9be4043268b0fad.yml +openapi_spec_hash: f5928b2d6fc0d6f10ea63acac9dead60 config_hash: 7fca08d9dae18513f5d7451cea11e34c diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionCreateParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionCreateParams.kt index f653b70..7bef8b7 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionCreateParams.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionCreateParams.kt @@ -65,6 +65,28 @@ private constructor( */ fun description(): Optional = body.description() + /** + * Which file in `files` is the entry point. Defaults to `index.ts`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entrypoint(): Optional = body.entrypoint() + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a function + * can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` are + * rejected. npm packages are not uploaded here — declare them under `dependencies` and Zavu + * installs them. Limits: 200 files and 900,000 bytes for the whole tree. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional = body.files() + /** * Whether to expose a public HTTPS URL for this function. * @@ -88,7 +110,9 @@ private constructor( fun runtime(): Optional = body.runtime() /** - * TypeScript source code for the function entry point (max ~900KB). + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. If + * both are sent, `files` wins. * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -133,6 +157,20 @@ private constructor( */ fun _description(): JsonField = body._description() + /** + * Returns the raw JSON value of [entrypoint]. + * + * Unlike [entrypoint], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _entrypoint(): JsonField = body._entrypoint() + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _files(): JsonField = body._files() + /** * Returns the raw JSON value of [httpEnabled]. * @@ -215,7 +253,7 @@ private constructor( * - [slug] * - [dependencies] * - [description] - * - [httpEnabled] + * - [entrypoint] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -266,6 +304,37 @@ private constructor( */ fun description(description: JsonField) = apply { body.description(description) } + /** Which file in `files` is the entry point. Defaults to `index.ts`. */ + fun entrypoint(entrypoint: String) = apply { body.entrypoint(entrypoint) } + + /** + * Sets [Builder.entrypoint] to an arbitrary JSON value. + * + * You should usually call [Builder.entrypoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entrypoint(entrypoint: JsonField) = apply { body.entrypoint(entrypoint) } + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a + * function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` + * are rejected. npm packages are not uploaded here — declare them under `dependencies` and + * Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree. + */ + fun files(files: Files) = apply { body.files(files) } + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed [Files] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun files(files: JsonField) = apply { body.files(files) } + /** Whether to expose a public HTTPS URL for this function. */ fun httpEnabled(httpEnabled: Boolean) = apply { body.httpEnabled(httpEnabled) } @@ -300,7 +369,11 @@ private constructor( */ fun runtime(runtime: JsonField) = apply { body.runtime(runtime) } - /** TypeScript source code for the function entry point (max ~900KB). */ + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. + * If both are sent, `files` wins. + */ fun sourceCode(sourceCode: String) = apply { body.sourceCode(sourceCode) } /** @@ -479,6 +552,8 @@ private constructor( private val slug: JsonField, private val dependencies: JsonField, private val description: JsonField, + private val entrypoint: JsonField, + private val files: JsonField, private val httpEnabled: JsonField, private val memoryMb: JsonField, private val runtime: JsonField, @@ -497,6 +572,10 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("entrypoint") + @ExcludeMissing + entrypoint: JsonField = JsonMissing.of(), + @JsonProperty("files") @ExcludeMissing files: JsonField = JsonMissing.of(), @JsonProperty("httpEnabled") @ExcludeMissing httpEnabled: JsonField = JsonMissing.of(), @@ -515,6 +594,8 @@ private constructor( slug, dependencies, description, + entrypoint, + files, httpEnabled, memoryMb, runtime, @@ -551,6 +632,28 @@ private constructor( */ fun description(): Optional = description.getOptional("description") + /** + * Which file in `files` is the entry point. Defaults to `index.ts`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entrypoint(): Optional = entrypoint.getOptional("entrypoint") + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a + * function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` + * are rejected. npm packages are not uploaded here — declare them under `dependencies` and + * Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional = files.getOptional("files") + /** * Whether to expose a public HTTPS URL for this function. * @@ -574,7 +677,9 @@ private constructor( fun runtime(): Optional = runtime.getOptional("runtime") /** - * TypeScript source code for the function entry point (max ~900KB). + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. + * If both are sent, `files` wins. * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -625,6 +730,22 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [entrypoint]. + * + * Unlike [entrypoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entrypoint") + @ExcludeMissing + fun _entrypoint(): JsonField = entrypoint + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("files") @ExcludeMissing fun _files(): JsonField = files + /** * Returns the raw JSON value of [httpEnabled]. * @@ -697,6 +818,8 @@ private constructor( private var slug: JsonField? = null private var dependencies: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() + private var entrypoint: JsonField = JsonMissing.of() + private var files: JsonField = JsonMissing.of() private var httpEnabled: JsonField = JsonMissing.of() private var memoryMb: JsonField = JsonMissing.of() private var runtime: JsonField = JsonMissing.of() @@ -710,6 +833,8 @@ private constructor( slug = body.slug dependencies = body.dependencies description = body.description + entrypoint = body.entrypoint + files = body.files httpEnabled = body.httpEnabled memoryMb = body.memoryMb runtime = body.runtime @@ -768,6 +893,39 @@ private constructor( this.description = description } + /** Which file in `files` is the entry point. Defaults to `index.ts`. */ + fun entrypoint(entrypoint: String) = entrypoint(JsonField.of(entrypoint)) + + /** + * Sets [Builder.entrypoint] to an arbitrary JSON value. + * + * You should usually call [Builder.entrypoint] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun entrypoint(entrypoint: JsonField) = apply { this.entrypoint = entrypoint } + + /** + * The project's source files, keyed by path relative to the project root (e.g. + * `index.ts`, `lib/orders.ts`). Imports between them are resolved when the function is + * built, so a function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and + * `package.json` are rejected. npm packages are not uploaded here — declare them under + * `dependencies` and Zavu installs them. Limits: 200 files and 900,000 bytes for the + * whole tree. + */ + fun files(files: Files) = files(JsonField.of(files)) + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed [Files] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun files(files: JsonField) = apply { this.files = files } + /** Whether to expose a public HTTPS URL for this function. */ fun httpEnabled(httpEnabled: Boolean) = httpEnabled(JsonField.of(httpEnabled)) @@ -805,7 +963,11 @@ private constructor( */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } - /** TypeScript source code for the function entry point (max ~900KB). */ + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one + * entry named after `entrypoint` (`index.ts` by default). Fully supported — use + * whichever fits. If both are sent, `files` wins. + */ fun sourceCode(sourceCode: String) = sourceCode(JsonField.of(sourceCode)) /** @@ -872,6 +1034,8 @@ private constructor( checkRequired("slug", slug), dependencies, description, + entrypoint, + files, httpEnabled, memoryMb, runtime, @@ -901,6 +1065,8 @@ private constructor( slug() dependencies().ifPresent { it.validate() } description() + entrypoint() + files().ifPresent { it.validate() } httpEnabled() memoryMb().ifPresent { it.validate() } runtime().ifPresent { it.validate() } @@ -929,6 +1095,8 @@ private constructor( (if (slug.asKnown().isPresent) 1 else 0) + (dependencies.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + + (if (entrypoint.asKnown().isPresent) 1 else 0) + + (files.asKnown().getOrNull()?.validity() ?: 0) + (if (httpEnabled.asKnown().isPresent) 1 else 0) + (memoryMb.asKnown().getOrNull()?.validity() ?: 0) + (runtime.asKnown().getOrNull()?.validity() ?: 0) + @@ -945,6 +1113,8 @@ private constructor( slug == other.slug && dependencies == other.dependencies && description == other.description && + entrypoint == other.entrypoint && + files == other.files && httpEnabled == other.httpEnabled && memoryMb == other.memoryMb && runtime == other.runtime && @@ -959,6 +1129,8 @@ private constructor( slug, dependencies, description, + entrypoint, + files, httpEnabled, memoryMb, runtime, @@ -971,7 +1143,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, slug=$slug, dependencies=$dependencies, description=$description, httpEnabled=$httpEnabled, memoryMb=$memoryMb, runtime=$runtime, sourceCode=$sourceCode, timeoutSec=$timeoutSec, additionalProperties=$additionalProperties}" + "Body{name=$name, slug=$slug, dependencies=$dependencies, description=$description, entrypoint=$entrypoint, files=$files, httpEnabled=$httpEnabled, memoryMb=$memoryMb, runtime=$runtime, sourceCode=$sourceCode, timeoutSec=$timeoutSec, additionalProperties=$additionalProperties}" } /** npm dependencies. Keys are package names, values are semver ranges. */ @@ -1083,6 +1255,123 @@ private constructor( override fun toString() = "Dependencies{additionalProperties=$additionalProperties}" } + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a function + * can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` are + * rejected. npm packages are not uploaded here — declare them under `dependencies` and Zavu + * installs them. Limits: 200 files and 900,000 bytes for the whole tree. + */ + class Files + @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 [Files]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Files]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(files: Files) = apply { + additionalProperties = files.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 [Files]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Files = Files(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(): Files = 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 Files && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Files{additionalProperties=$additionalProperties}" + } + class MemoryMb @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployParams.kt index 46cb3a6..b685867 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployParams.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployParams.kt @@ -44,7 +44,31 @@ private constructor( fun dependencies(): Optional = body.dependencies() /** - * New source code to publish (replaces the draft). + * Which file in `files` is the entry point. Defaults to `index.ts`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entrypoint(): Optional = body.entrypoint() + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a function + * can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` are + * rejected. npm packages are not uploaded here — declare them under `dependencies` and Zavu + * installs them. Limits: 200 files and 900,000 bytes for the whole tree. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional = body.files() + + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. If + * both are sent, `files` wins. * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -58,6 +82,20 @@ private constructor( */ fun _dependencies(): JsonField = body._dependencies() + /** + * Returns the raw JSON value of [entrypoint]. + * + * Unlike [entrypoint], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _entrypoint(): JsonField = body._entrypoint() + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _files(): JsonField = body._files() + /** * Returns the raw JSON value of [sourceCode]. * @@ -110,6 +148,8 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [dependencies] + * - [entrypoint] + * - [files] * - [sourceCode] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -128,7 +168,42 @@ private constructor( body.dependencies(dependencies) } - /** New source code to publish (replaces the draft). */ + /** Which file in `files` is the entry point. Defaults to `index.ts`. */ + fun entrypoint(entrypoint: String) = apply { body.entrypoint(entrypoint) } + + /** + * Sets [Builder.entrypoint] to an arbitrary JSON value. + * + * You should usually call [Builder.entrypoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entrypoint(entrypoint: JsonField) = apply { body.entrypoint(entrypoint) } + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a + * function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` + * are rejected. npm packages are not uploaded here — declare them under `dependencies` and + * Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree. + */ + fun files(files: Files) = apply { body.files(files) } + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed [Files] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun files(files: JsonField) = apply { body.files(files) } + + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. + * If both are sent, `files` wins. + */ fun sourceCode(sourceCode: String) = apply { body.sourceCode(sourceCode) } /** @@ -284,13 +359,15 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams /** - * Optional source/dependencies update applied before deploying. Omit both fields to redeploy + * Optional source/dependencies update applied before deploying. Omit every field to redeploy * the current draft as-is. */ class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dependencies: JsonField, + private val entrypoint: JsonField, + private val files: JsonField, private val sourceCode: JsonField, private val additionalProperties: MutableMap, ) { @@ -300,10 +377,14 @@ private constructor( @JsonProperty("dependencies") @ExcludeMissing dependencies: JsonField = JsonMissing.of(), + @JsonProperty("entrypoint") + @ExcludeMissing + entrypoint: JsonField = JsonMissing.of(), + @JsonProperty("files") @ExcludeMissing files: JsonField = JsonMissing.of(), @JsonProperty("sourceCode") @ExcludeMissing sourceCode: JsonField = JsonMissing.of(), - ) : this(dependencies, sourceCode, mutableMapOf()) + ) : this(dependencies, entrypoint, files, sourceCode, mutableMapOf()) /** * New dependency map (replaces existing dependencies). @@ -314,7 +395,31 @@ private constructor( fun dependencies(): Optional = dependencies.getOptional("dependencies") /** - * New source code to publish (replaces the draft). + * Which file in `files` is the entry point. Defaults to `index.ts`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entrypoint(): Optional = entrypoint.getOptional("entrypoint") + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a + * function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` + * are rejected. npm packages are not uploaded here — declare them under `dependencies` and + * Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional = files.getOptional("files") + + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. + * If both are sent, `files` wins. * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -331,6 +436,22 @@ private constructor( @ExcludeMissing fun _dependencies(): JsonField = dependencies + /** + * Returns the raw JSON value of [entrypoint]. + * + * Unlike [entrypoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entrypoint") + @ExcludeMissing + fun _entrypoint(): JsonField = entrypoint + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("files") @ExcludeMissing fun _files(): JsonField = files + /** * Returns the raw JSON value of [sourceCode]. * @@ -362,12 +483,16 @@ private constructor( class Builder internal constructor() { private var dependencies: JsonField = JsonMissing.of() + private var entrypoint: JsonField = JsonMissing.of() + private var files: JsonField = JsonMissing.of() private var sourceCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { dependencies = body.dependencies + entrypoint = body.entrypoint + files = body.files sourceCode = body.sourceCode additionalProperties = body.additionalProperties.toMutableMap() } @@ -386,7 +511,44 @@ private constructor( this.dependencies = dependencies } - /** New source code to publish (replaces the draft). */ + /** Which file in `files` is the entry point. Defaults to `index.ts`. */ + fun entrypoint(entrypoint: String) = entrypoint(JsonField.of(entrypoint)) + + /** + * Sets [Builder.entrypoint] to an arbitrary JSON value. + * + * You should usually call [Builder.entrypoint] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun entrypoint(entrypoint: JsonField) = apply { this.entrypoint = entrypoint } + + /** + * The project's source files, keyed by path relative to the project root (e.g. + * `index.ts`, `lib/orders.ts`). Imports between them are resolved when the function is + * built, so a function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and + * `package.json` are rejected. npm packages are not uploaded here — declare them under + * `dependencies` and Zavu installs them. Limits: 200 files and 900,000 bytes for the + * whole tree. + */ + fun files(files: Files) = files(JsonField.of(files)) + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed [Files] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun files(files: JsonField) = apply { this.files = files } + + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one + * entry named after `entrypoint` (`index.ts` by default). Fully supported — use + * whichever fits. If both are sent, `files` wins. + */ fun sourceCode(sourceCode: String) = sourceCode(JsonField.of(sourceCode)) /** @@ -422,7 +584,14 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(dependencies, sourceCode, additionalProperties.toMutableMap()) + fun build(): Body = + Body( + dependencies, + entrypoint, + files, + sourceCode, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -442,6 +611,8 @@ private constructor( } dependencies().ifPresent { it.validate() } + entrypoint() + files().ifPresent { it.validate() } sourceCode() validated = true } @@ -463,6 +634,8 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (dependencies.asKnown().getOrNull()?.validity() ?: 0) + + (if (entrypoint.asKnown().isPresent) 1 else 0) + + (files.asKnown().getOrNull()?.validity() ?: 0) + (if (sourceCode.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -472,18 +645,20 @@ private constructor( return other is Body && dependencies == other.dependencies && + entrypoint == other.entrypoint && + files == other.files && sourceCode == other.sourceCode && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dependencies, sourceCode, additionalProperties) + Objects.hash(dependencies, entrypoint, files, sourceCode, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{dependencies=$dependencies, sourceCode=$sourceCode, additionalProperties=$additionalProperties}" + "Body{dependencies=$dependencies, entrypoint=$entrypoint, files=$files, sourceCode=$sourceCode, additionalProperties=$additionalProperties}" } /** New dependency map (replaces existing dependencies). */ @@ -595,6 +770,123 @@ private constructor( override fun toString() = "Dependencies{additionalProperties=$additionalProperties}" } + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a function + * can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` are + * rejected. npm packages are not uploaded here — declare them under `dependencies` and Zavu + * installs them. Limits: 200 files and 900,000 bytes for the whole tree. + */ + class Files + @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 [Files]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Files]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(files: Files) = apply { + additionalProperties = files.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 [Files]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Files = Files(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(): Files = 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 Files && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Files{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt index 64c744c..7287764 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt @@ -254,6 +254,8 @@ private constructor( fun version(): Long = version.getRequired("version") /** + * Size of the built bundle in bytes. Null until the build finishes. + * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -274,6 +276,8 @@ private constructor( fun errorMessage(): Optional = errorMessage.getOptional("errorMessage") /** + * Total size of the deployed source tree in bytes. + * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -472,6 +476,7 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } + /** Size of the built bundle in bytes. Null until the build finishes. */ fun bundleBytes(bundleBytes: Long?) = bundleBytes(JsonField.ofNullable(bundleBytes)) /** @@ -530,6 +535,7 @@ private constructor( this.errorMessage = errorMessage } + /** Total size of the deployed source tree in bytes. */ fun sourceCodeBytes(sourceCodeBytes: Long?) = sourceCodeBytes(JsonField.ofNullable(sourceCodeBytes)) diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt index 5431c1c..c595ec0 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt @@ -255,6 +255,8 @@ private constructor( fun version(): Long = version.getRequired("version") /** + * Size of the built bundle in bytes. Null until the build finishes. + * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -275,6 +277,8 @@ private constructor( fun errorMessage(): Optional = errorMessage.getOptional("errorMessage") /** + * Total size of the deployed source tree in bytes. + * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -473,6 +477,7 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } + /** Size of the built bundle in bytes. Null until the build finishes. */ fun bundleBytes(bundleBytes: Long?) = bundleBytes(JsonField.ofNullable(bundleBytes)) /** @@ -531,6 +536,7 @@ private constructor( this.errorMessage = errorMessage } + /** Total size of the deployed source tree in bytes. */ fun sourceCodeBytes(sourceCodeBytes: Long?) = sourceCodeBytes(JsonField.ofNullable(sourceCodeBytes)) diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionUpdateParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionUpdateParams.kt index 61d4a6d..e26e70a 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionUpdateParams.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionUpdateParams.kt @@ -44,6 +44,28 @@ private constructor( */ fun dependencies(): Optional = body.dependencies() + /** + * Which file in `files` is the entry point. Defaults to `index.ts`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entrypoint(): Optional = body.entrypoint() + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a function + * can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` are + * rejected. npm packages are not uploaded here — declare them under `dependencies` and Zavu + * installs them. Limits: 200 files and 900,000 bytes for the whole tree. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional = body.files() + /** * Expose the function on its public HTTPS URL, or take it down. Applies to the already-deployed * function without redeploying; the URL is returned as `publicUrl`. @@ -54,7 +76,9 @@ private constructor( fun httpEnabled(): Optional = body.httpEnabled() /** - * New source code for the draft (replaces it). + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. If + * both are sent, `files` wins. * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -68,6 +92,20 @@ private constructor( */ fun _dependencies(): JsonField = body._dependencies() + /** + * Returns the raw JSON value of [entrypoint]. + * + * Unlike [entrypoint], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _entrypoint(): JsonField = body._entrypoint() + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _files(): JsonField = body._files() + /** * Returns the raw JSON value of [httpEnabled]. * @@ -127,8 +165,11 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [dependencies] + * - [entrypoint] + * - [files] * - [httpEnabled] * - [sourceCode] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -146,6 +187,37 @@ private constructor( body.dependencies(dependencies) } + /** Which file in `files` is the entry point. Defaults to `index.ts`. */ + fun entrypoint(entrypoint: String) = apply { body.entrypoint(entrypoint) } + + /** + * Sets [Builder.entrypoint] to an arbitrary JSON value. + * + * You should usually call [Builder.entrypoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entrypoint(entrypoint: JsonField) = apply { body.entrypoint(entrypoint) } + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a + * function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` + * are rejected. npm packages are not uploaded here — declare them under `dependencies` and + * Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree. + */ + fun files(files: Files) = apply { body.files(files) } + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed [Files] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun files(files: JsonField) = apply { body.files(files) } + /** * Expose the function on its public HTTPS URL, or take it down. Applies to the * already-deployed function without redeploying; the URL is returned as `publicUrl`. @@ -161,7 +233,11 @@ private constructor( */ fun httpEnabled(httpEnabled: JsonField) = apply { body.httpEnabled(httpEnabled) } - /** New source code for the draft (replaces it). */ + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. + * If both are sent, `files` wins. + */ fun sourceCode(sourceCode: String) = apply { body.sourceCode(sourceCode) } /** @@ -317,7 +393,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams /** - * Fields to update on an existing function. Provide at least one. `sourceCode` and + * Fields to update on an existing function. Provide at least one. `files` / `sourceCode` and * `dependencies` edit the draft and take effect on the next deploy; `httpEnabled` applies * immediately to the deployed function. */ @@ -325,6 +401,8 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dependencies: JsonField, + private val entrypoint: JsonField, + private val files: JsonField, private val httpEnabled: JsonField, private val sourceCode: JsonField, private val additionalProperties: MutableMap, @@ -335,13 +413,17 @@ private constructor( @JsonProperty("dependencies") @ExcludeMissing dependencies: JsonField = JsonMissing.of(), + @JsonProperty("entrypoint") + @ExcludeMissing + entrypoint: JsonField = JsonMissing.of(), + @JsonProperty("files") @ExcludeMissing files: JsonField = JsonMissing.of(), @JsonProperty("httpEnabled") @ExcludeMissing httpEnabled: JsonField = JsonMissing.of(), @JsonProperty("sourceCode") @ExcludeMissing sourceCode: JsonField = JsonMissing.of(), - ) : this(dependencies, httpEnabled, sourceCode, mutableMapOf()) + ) : this(dependencies, entrypoint, files, httpEnabled, sourceCode, mutableMapOf()) /** * New dependency map (replaces existing dependencies). @@ -351,6 +433,28 @@ private constructor( */ fun dependencies(): Optional = dependencies.getOptional("dependencies") + /** + * Which file in `files` is the entry point. Defaults to `index.ts`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entrypoint(): Optional = entrypoint.getOptional("entrypoint") + + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a + * function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` + * are rejected. npm packages are not uploaded here — declare them under `dependencies` and + * Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional = files.getOptional("files") + /** * Expose the function on its public HTTPS URL, or take it down. Applies to the * already-deployed function without redeploying; the URL is returned as `publicUrl`. @@ -361,7 +465,9 @@ private constructor( fun httpEnabled(): Optional = httpEnabled.getOptional("httpEnabled") /** - * New source code for the draft (replaces it). + * Shortcut for a single-file function: exactly equivalent to sending `files` with one entry + * named after `entrypoint` (`index.ts` by default). Fully supported — use whichever fits. + * If both are sent, `files` wins. * * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -378,6 +484,22 @@ private constructor( @ExcludeMissing fun _dependencies(): JsonField = dependencies + /** + * Returns the raw JSON value of [entrypoint]. + * + * Unlike [entrypoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entrypoint") + @ExcludeMissing + fun _entrypoint(): JsonField = entrypoint + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("files") @ExcludeMissing fun _files(): JsonField = files + /** * Returns the raw JSON value of [httpEnabled]. * @@ -418,6 +540,8 @@ private constructor( class Builder internal constructor() { private var dependencies: JsonField = JsonMissing.of() + private var entrypoint: JsonField = JsonMissing.of() + private var files: JsonField = JsonMissing.of() private var httpEnabled: JsonField = JsonMissing.of() private var sourceCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -425,6 +549,8 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { dependencies = body.dependencies + entrypoint = body.entrypoint + files = body.files httpEnabled = body.httpEnabled sourceCode = body.sourceCode additionalProperties = body.additionalProperties.toMutableMap() @@ -444,6 +570,39 @@ private constructor( this.dependencies = dependencies } + /** Which file in `files` is the entry point. Defaults to `index.ts`. */ + fun entrypoint(entrypoint: String) = entrypoint(JsonField.of(entrypoint)) + + /** + * Sets [Builder.entrypoint] to an arbitrary JSON value. + * + * You should usually call [Builder.entrypoint] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun entrypoint(entrypoint: JsonField) = apply { this.entrypoint = entrypoint } + + /** + * The project's source files, keyed by path relative to the project root (e.g. + * `index.ts`, `lib/orders.ts`). Imports between them are resolved when the function is + * built, so a function can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and + * `package.json` are rejected. npm packages are not uploaded here — declare them under + * `dependencies` and Zavu installs them. Limits: 200 files and 900,000 bytes for the + * whole tree. + */ + fun files(files: Files) = files(JsonField.of(files)) + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed [Files] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun files(files: JsonField) = apply { this.files = files } + /** * Expose the function on its public HTTPS URL, or take it down. Applies to the * already-deployed function without redeploying; the URL is returned as `publicUrl`. @@ -461,7 +620,11 @@ private constructor( this.httpEnabled = httpEnabled } - /** New source code for the draft (replaces it). */ + /** + * Shortcut for a single-file function: exactly equivalent to sending `files` with one + * entry named after `entrypoint` (`index.ts` by default). Fully supported — use + * whichever fits. If both are sent, `files` wins. + */ fun sourceCode(sourceCode: String) = sourceCode(JsonField.of(sourceCode)) /** @@ -498,7 +661,14 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(dependencies, httpEnabled, sourceCode, additionalProperties.toMutableMap()) + Body( + dependencies, + entrypoint, + files, + httpEnabled, + sourceCode, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -518,6 +688,8 @@ private constructor( } dependencies().ifPresent { it.validate() } + entrypoint() + files().ifPresent { it.validate() } httpEnabled() sourceCode() validated = true @@ -540,6 +712,8 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (dependencies.asKnown().getOrNull()?.validity() ?: 0) + + (if (entrypoint.asKnown().isPresent) 1 else 0) + + (files.asKnown().getOrNull()?.validity() ?: 0) + (if (httpEnabled.asKnown().isPresent) 1 else 0) + (if (sourceCode.asKnown().isPresent) 1 else 0) @@ -550,19 +724,28 @@ private constructor( return other is Body && dependencies == other.dependencies && + entrypoint == other.entrypoint && + files == other.files && httpEnabled == other.httpEnabled && sourceCode == other.sourceCode && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dependencies, httpEnabled, sourceCode, additionalProperties) + Objects.hash( + dependencies, + entrypoint, + files, + httpEnabled, + sourceCode, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{dependencies=$dependencies, httpEnabled=$httpEnabled, sourceCode=$sourceCode, additionalProperties=$additionalProperties}" + "Body{dependencies=$dependencies, entrypoint=$entrypoint, files=$files, httpEnabled=$httpEnabled, sourceCode=$sourceCode, additionalProperties=$additionalProperties}" } /** New dependency map (replaces existing dependencies). */ @@ -674,6 +857,123 @@ private constructor( override fun toString() = "Dependencies{additionalProperties=$additionalProperties}" } + /** + * The project's source files, keyed by path relative to the project root (e.g. `index.ts`, + * `lib/orders.ts`). Imports between them are resolved when the function is built, so a function + * can be split across as many files as it needs. + * + * Paths must be relative and use forward slashes; `..`, `node_modules/` and `package.json` are + * rejected. npm packages are not uploaded here — declare them under `dependencies` and Zavu + * installs them. Limits: 200 files and 900,000 bytes for the whole tree. + */ + class Files + @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 [Files]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Files]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(files: Files) = apply { + additionalProperties = files.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 [Files]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Files = Files(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(): Files = 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 Files && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Files{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionCreateParamsTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionCreateParamsTest.kt index cad1506..bc2ac9a 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionCreateParamsTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionCreateParamsTest.kt @@ -19,6 +19,23 @@ internal class FunctionCreateParamsTest { .build() ) .description("Replies to order status questions on WhatsApp.") + .entrypoint("index.ts") + .files( + FunctionCreateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .memoryMb(FunctionCreateParams.MemoryMb._128) .runtime(FunctionCreateParams.Runtime.NODEJS24) @@ -41,6 +58,23 @@ internal class FunctionCreateParamsTest { .build() ) .description("Replies to order status questions on WhatsApp.") + .entrypoint("index.ts") + .files( + FunctionCreateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .memoryMb(FunctionCreateParams.MemoryMb._128) .runtime(FunctionCreateParams.Runtime.NODEJS24) @@ -61,6 +95,24 @@ internal class FunctionCreateParamsTest { .build() ) assertThat(body.description()).contains("Replies to order status questions on WhatsApp.") + assertThat(body.entrypoint()).contains("index.ts") + assertThat(body.files()) + .contains( + FunctionCreateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) assertThat(body.httpEnabled()).contains(true) assertThat(body.memoryMb()).contains(FunctionCreateParams.MemoryMb._128) assertThat(body.runtime()).contains(FunctionCreateParams.Runtime.NODEJS24) diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployParamsTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployParamsTest.kt index 388eeba..ff516d2 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployParamsTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployParamsTest.kt @@ -17,6 +17,23 @@ internal class FunctionDeployParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionDeployParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .sourceCode("sourceCode") .build() } @@ -40,6 +57,23 @@ internal class FunctionDeployParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionDeployParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .sourceCode("sourceCode") .build() @@ -51,6 +85,24 @@ internal class FunctionDeployParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + assertThat(body.entrypoint()).contains("index.ts") + assertThat(body.files()) + .contains( + FunctionDeployParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) assertThat(body.sourceCode()).contains("sourceCode") } diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionUpdateParamsTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionUpdateParamsTest.kt index 4850563..ebcab02 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionUpdateParamsTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionUpdateParamsTest.kt @@ -17,6 +17,23 @@ internal class FunctionUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionUpdateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .sourceCode("sourceCode") .build() @@ -41,6 +58,23 @@ internal class FunctionUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionUpdateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .sourceCode("sourceCode") .build() @@ -53,6 +87,24 @@ internal class FunctionUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + assertThat(body.entrypoint()).contains("index.ts") + assertThat(body.files()) + .contains( + FunctionUpdateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) assertThat(body.httpEnabled()).contains(true) assertThat(body.sourceCode()).contains("sourceCode") } diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/FunctionServiceAsyncTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/FunctionServiceAsyncTest.kt index 0afb69c..50ab417 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/FunctionServiceAsyncTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/FunctionServiceAsyncTest.kt @@ -30,6 +30,23 @@ internal class FunctionServiceAsyncTest { .build() ) .description("Replies to order status questions on WhatsApp.") + .entrypoint("index.ts") + .files( + FunctionCreateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .memoryMb(FunctionCreateParams.MemoryMb._128) .runtime(FunctionCreateParams.Runtime.NODEJS24) @@ -71,6 +88,23 @@ internal class FunctionServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionUpdateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .sourceCode("sourceCode") .build() @@ -107,6 +141,23 @@ internal class FunctionServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionDeployParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .sourceCode("sourceCode") .build() ) diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/FunctionServiceTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/FunctionServiceTest.kt index c0cebe6..10d9acc 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/FunctionServiceTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/FunctionServiceTest.kt @@ -30,6 +30,23 @@ internal class FunctionServiceTest { .build() ) .description("Replies to order status questions on WhatsApp.") + .entrypoint("index.ts") + .files( + FunctionCreateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .memoryMb(FunctionCreateParams.MemoryMb._128) .runtime(FunctionCreateParams.Runtime.NODEJS24) @@ -69,6 +86,23 @@ internal class FunctionServiceTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionUpdateParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .httpEnabled(true) .sourceCode("sourceCode") .build() @@ -103,6 +137,23 @@ internal class FunctionServiceTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .entrypoint("index.ts") + .files( + FunctionDeployParams.Files.builder() + .putAdditionalProperty( + "index.ts", + JsonValue.from( + "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n" + ), + ) + .putAdditionalProperty( + "lib/orders.ts", + JsonValue.from( + "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n" + ), + ) + .build() + ) .sourceCode("sourceCode") .build() ) From cf7c41255bc4ad349e9111c1abbde0b72a60539f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 03:47:57 +0000 Subject: [PATCH 05/24] feat(api): api update --- .stats.yml | 4 +- .../functions/FunctionDeployResponse.kt | 53 ++++++++++++++++++- .../FunctionGetDeploymentResponse.kt | 53 ++++++++++++++++++- .../functions/FunctionDeployResponseTest.kt | 3 ++ .../FunctionGetDeploymentResponseTest.kt | 3 ++ 5 files changed, 112 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 484237c..0b60fcc 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-21db15ab8c7fc4a95f96e62e9ae84d4db9696f41adf62806c9be4043268b0fad.yml -openapi_spec_hash: f5928b2d6fc0d6f10ea63acac9dead60 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-e4987140138afb7287e25f31dc8cff94c6b11975e460e0c19d54ec457d009a1b.yml +openapi_spec_hash: d20e1b8d0a9a7a65dc8a21e3a151111e config_hash: 7fca08d9dae18513f5d7451cea11e34c diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt index 7287764..8f435f7 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionDeployResponse.kt @@ -176,6 +176,7 @@ private constructor( private val functionId: JsonField, private val status: JsonField, private val version: JsonField, + private val buildLogs: JsonField, private val bundleBytes: JsonField, private val deployedAt: JsonField, private val errorMessage: JsonField, @@ -194,6 +195,9 @@ private constructor( functionId: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("buildLogs") + @ExcludeMissing + buildLogs: JsonField = JsonMissing.of(), @JsonProperty("bundleBytes") @ExcludeMissing bundleBytes: JsonField = JsonMissing.of(), @@ -212,6 +216,7 @@ private constructor( functionId, status, version, + buildLogs, bundleBytes, deployedAt, errorMessage, @@ -253,6 +258,17 @@ private constructor( */ fun version(): Long = version.getRequired("version") + /** + * What the build printed: dependency installation, the bundler's output, and the compiler's + * message when it failed. Returned when fetching a single deployment, omitted from the + * list. Read this first when a deploy fails — `errorMessage` is often the outer wrapper's + * summary, and the line that names the broken import or the syntax error is here. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun buildLogs(): Optional = buildLogs.getOptional("buildLogs") + /** * Size of the built bundle in bytes. Null until the build finishes. * @@ -322,6 +338,13 @@ private constructor( */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + /** + * Returns the raw JSON value of [buildLogs]. + * + * Unlike [buildLogs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("buildLogs") @ExcludeMissing fun _buildLogs(): JsonField = buildLogs + /** * Returns the raw JSON value of [bundleBytes]. * @@ -397,6 +420,7 @@ private constructor( private var functionId: JsonField? = null private var status: JsonField? = null private var version: JsonField? = null + private var buildLogs: JsonField = JsonMissing.of() private var bundleBytes: JsonField = JsonMissing.of() private var deployedAt: JsonField = JsonMissing.of() private var errorMessage: JsonField = JsonMissing.of() @@ -410,6 +434,7 @@ private constructor( functionId = deployment.functionId status = deployment.status version = deployment.version + buildLogs = deployment.buildLogs bundleBytes = deployment.bundleBytes deployedAt = deployment.deployedAt errorMessage = deployment.errorMessage @@ -476,6 +501,27 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } + /** + * What the build printed: dependency installation, the bundler's output, and the + * compiler's message when it failed. Returned when fetching a single deployment, + * omitted from the list. Read this first when a deploy fails — `errorMessage` is often + * the outer wrapper's summary, and the line that names the broken import or the syntax + * error is here. + */ + fun buildLogs(buildLogs: String?) = buildLogs(JsonField.ofNullable(buildLogs)) + + /** Alias for calling [Builder.buildLogs] with `buildLogs.orElse(null)`. */ + fun buildLogs(buildLogs: Optional) = buildLogs(buildLogs.getOrNull()) + + /** + * Sets [Builder.buildLogs] to an arbitrary JSON value. + * + * You should usually call [Builder.buildLogs] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun buildLogs(buildLogs: JsonField) = apply { this.buildLogs = buildLogs } + /** Size of the built bundle in bytes. Null until the build finishes. */ fun bundleBytes(bundleBytes: Long?) = bundleBytes(JsonField.ofNullable(bundleBytes)) @@ -603,6 +649,7 @@ private constructor( checkRequired("functionId", functionId), checkRequired("status", status), checkRequired("version", version), + buildLogs, bundleBytes, deployedAt, errorMessage, @@ -632,6 +679,7 @@ private constructor( functionId() status().validate() version() + buildLogs() bundleBytes() deployedAt() errorMessage() @@ -660,6 +708,7 @@ private constructor( (if (functionId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + (if (version.asKnown().isPresent) 1 else 0) + + (if (buildLogs.asKnown().isPresent) 1 else 0) + (if (bundleBytes.asKnown().isPresent) 1 else 0) + (if (deployedAt.asKnown().isPresent) 1 else 0) + (if (errorMessage.asKnown().isPresent) 1 else 0) + @@ -846,6 +895,7 @@ private constructor( functionId == other.functionId && status == other.status && version == other.version && + buildLogs == other.buildLogs && bundleBytes == other.bundleBytes && deployedAt == other.deployedAt && errorMessage == other.errorMessage && @@ -860,6 +910,7 @@ private constructor( functionId, status, version, + buildLogs, bundleBytes, deployedAt, errorMessage, @@ -871,7 +922,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Deployment{id=$id, createdAt=$createdAt, functionId=$functionId, status=$status, version=$version, bundleBytes=$bundleBytes, deployedAt=$deployedAt, errorMessage=$errorMessage, sourceCodeBytes=$sourceCodeBytes, additionalProperties=$additionalProperties}" + "Deployment{id=$id, createdAt=$createdAt, functionId=$functionId, status=$status, version=$version, buildLogs=$buildLogs, bundleBytes=$bundleBytes, deployedAt=$deployedAt, errorMessage=$errorMessage, sourceCodeBytes=$sourceCodeBytes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt index c595ec0..9ae38bb 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponse.kt @@ -177,6 +177,7 @@ private constructor( private val functionId: JsonField, private val status: JsonField, private val version: JsonField, + private val buildLogs: JsonField, private val bundleBytes: JsonField, private val deployedAt: JsonField, private val errorMessage: JsonField, @@ -195,6 +196,9 @@ private constructor( functionId: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("buildLogs") + @ExcludeMissing + buildLogs: JsonField = JsonMissing.of(), @JsonProperty("bundleBytes") @ExcludeMissing bundleBytes: JsonField = JsonMissing.of(), @@ -213,6 +217,7 @@ private constructor( functionId, status, version, + buildLogs, bundleBytes, deployedAt, errorMessage, @@ -254,6 +259,17 @@ private constructor( */ fun version(): Long = version.getRequired("version") + /** + * What the build printed: dependency installation, the bundler's output, and the compiler's + * message when it failed. Returned when fetching a single deployment, omitted from the + * list. Read this first when a deploy fails — `errorMessage` is often the outer wrapper's + * summary, and the line that names the broken import or the syntax error is here. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun buildLogs(): Optional = buildLogs.getOptional("buildLogs") + /** * Size of the built bundle in bytes. Null until the build finishes. * @@ -323,6 +339,13 @@ private constructor( */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + /** + * Returns the raw JSON value of [buildLogs]. + * + * Unlike [buildLogs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("buildLogs") @ExcludeMissing fun _buildLogs(): JsonField = buildLogs + /** * Returns the raw JSON value of [bundleBytes]. * @@ -398,6 +421,7 @@ private constructor( private var functionId: JsonField? = null private var status: JsonField? = null private var version: JsonField? = null + private var buildLogs: JsonField = JsonMissing.of() private var bundleBytes: JsonField = JsonMissing.of() private var deployedAt: JsonField = JsonMissing.of() private var errorMessage: JsonField = JsonMissing.of() @@ -411,6 +435,7 @@ private constructor( functionId = deployment.functionId status = deployment.status version = deployment.version + buildLogs = deployment.buildLogs bundleBytes = deployment.bundleBytes deployedAt = deployment.deployedAt errorMessage = deployment.errorMessage @@ -477,6 +502,27 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } + /** + * What the build printed: dependency installation, the bundler's output, and the + * compiler's message when it failed. Returned when fetching a single deployment, + * omitted from the list. Read this first when a deploy fails — `errorMessage` is often + * the outer wrapper's summary, and the line that names the broken import or the syntax + * error is here. + */ + fun buildLogs(buildLogs: String?) = buildLogs(JsonField.ofNullable(buildLogs)) + + /** Alias for calling [Builder.buildLogs] with `buildLogs.orElse(null)`. */ + fun buildLogs(buildLogs: Optional) = buildLogs(buildLogs.getOrNull()) + + /** + * Sets [Builder.buildLogs] to an arbitrary JSON value. + * + * You should usually call [Builder.buildLogs] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun buildLogs(buildLogs: JsonField) = apply { this.buildLogs = buildLogs } + /** Size of the built bundle in bytes. Null until the build finishes. */ fun bundleBytes(bundleBytes: Long?) = bundleBytes(JsonField.ofNullable(bundleBytes)) @@ -604,6 +650,7 @@ private constructor( checkRequired("functionId", functionId), checkRequired("status", status), checkRequired("version", version), + buildLogs, bundleBytes, deployedAt, errorMessage, @@ -633,6 +680,7 @@ private constructor( functionId() status().validate() version() + buildLogs() bundleBytes() deployedAt() errorMessage() @@ -661,6 +709,7 @@ private constructor( (if (functionId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + (if (version.asKnown().isPresent) 1 else 0) + + (if (buildLogs.asKnown().isPresent) 1 else 0) + (if (bundleBytes.asKnown().isPresent) 1 else 0) + (if (deployedAt.asKnown().isPresent) 1 else 0) + (if (errorMessage.asKnown().isPresent) 1 else 0) + @@ -847,6 +896,7 @@ private constructor( functionId == other.functionId && status == other.status && version == other.version && + buildLogs == other.buildLogs && bundleBytes == other.bundleBytes && deployedAt == other.deployedAt && errorMessage == other.errorMessage && @@ -861,6 +911,7 @@ private constructor( functionId, status, version, + buildLogs, bundleBytes, deployedAt, errorMessage, @@ -872,7 +923,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Deployment{id=$id, createdAt=$createdAt, functionId=$functionId, status=$status, version=$version, bundleBytes=$bundleBytes, deployedAt=$deployedAt, errorMessage=$errorMessage, sourceCodeBytes=$sourceCodeBytes, additionalProperties=$additionalProperties}" + "Deployment{id=$id, createdAt=$createdAt, functionId=$functionId, status=$status, version=$version, buildLogs=$buildLogs, bundleBytes=$bundleBytes, deployedAt=$deployedAt, errorMessage=$errorMessage, sourceCodeBytes=$sourceCodeBytes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployResponseTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployResponseTest.kt index 18817dc..df44968 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployResponseTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionDeployResponseTest.kt @@ -21,6 +21,7 @@ internal class FunctionDeployResponseTest { .functionId("functionId") .status(FunctionDeployResponse.Deployment.Status.PENDING) .version(0L) + .buildLogs("buildLogs") .bundleBytes(0L) .deployedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorMessage("errorMessage") @@ -37,6 +38,7 @@ internal class FunctionDeployResponseTest { .functionId("functionId") .status(FunctionDeployResponse.Deployment.Status.PENDING) .version(0L) + .buildLogs("buildLogs") .bundleBytes(0L) .deployedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorMessage("errorMessage") @@ -57,6 +59,7 @@ internal class FunctionDeployResponseTest { .functionId("functionId") .status(FunctionDeployResponse.Deployment.Status.PENDING) .version(0L) + .buildLogs("buildLogs") .bundleBytes(0L) .deployedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorMessage("errorMessage") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponseTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponseTest.kt index f304114..ab6fb11 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponseTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionGetDeploymentResponseTest.kt @@ -21,6 +21,7 @@ internal class FunctionGetDeploymentResponseTest { .functionId("functionId") .status(FunctionGetDeploymentResponse.Deployment.Status.PENDING) .version(0L) + .buildLogs("buildLogs") .bundleBytes(0L) .deployedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorMessage("errorMessage") @@ -37,6 +38,7 @@ internal class FunctionGetDeploymentResponseTest { .functionId("functionId") .status(FunctionGetDeploymentResponse.Deployment.Status.PENDING) .version(0L) + .buildLogs("buildLogs") .bundleBytes(0L) .deployedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorMessage("errorMessage") @@ -57,6 +59,7 @@ internal class FunctionGetDeploymentResponseTest { .functionId("functionId") .status(FunctionGetDeploymentResponse.Deployment.Status.PENDING) .version(0L) + .buildLogs("buildLogs") .bundleBytes(0L) .deployedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorMessage("errorMessage") From 64671039e62ed865fdf28a804224f75927ce6952 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 03:54:27 +0000 Subject: [PATCH 06/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0b60fcc..edddea6 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-e4987140138afb7287e25f31dc8cff94c6b11975e460e0c19d54ec457d009a1b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-f94b2cae6c929ce34c51007444f7105c96b458c2cb9b07be2ce7d434adda4e66.yml openapi_spec_hash: d20e1b8d0a9a7a65dc8a21e3a151111e -config_hash: 7fca08d9dae18513f5d7451cea11e34c +config_hash: 942fad5624cf310889c6161a3b6bf725 From 9692c72c1ec3ec634d9548115271a5a42031f789 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 03:54:46 +0000 Subject: [PATCH 07/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index edddea6..0b60fcc 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-f94b2cae6c929ce34c51007444f7105c96b458c2cb9b07be2ce7d434adda4e66.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-e4987140138afb7287e25f31dc8cff94c6b11975e460e0c19d54ec457d009a1b.yml openapi_spec_hash: d20e1b8d0a9a7a65dc8a21e3a151111e -config_hash: 942fad5624cf310889c6161a3b6bf725 +config_hash: 7fca08d9dae18513f5d7451cea11e34c From 097cfec6842059736cb8e46fa21cfcfb85485867 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 23:28:46 +0000 Subject: [PATCH 08/24] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/broadcasts/BroadcastSendParams.kt | 13 ++++++++----- .../api/services/async/BroadcastServiceAsync.kt | 13 ++++++++----- .../api/services/blocking/BroadcastService.kt | 13 ++++++++----- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0b60fcc..d105c4b 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-e4987140138afb7287e25f31dc8cff94c6b11975e460e0c19d54ec457d009a1b.yml -openapi_spec_hash: d20e1b8d0a9a7a65dc8a21e3a151111e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-dd62b3849e15304da4087f73928025602737e10a414c87a6c2a5fe7059b9ea37.yml +openapi_spec_hash: 5a3d5cb61a7dd5d556a9f9abd9db01d4 config_hash: 7fca08d9dae18513f5d7451cea11e34c diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/broadcasts/BroadcastSendParams.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/broadcasts/BroadcastSendParams.kt index 2536383..ae98250 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/broadcasts/BroadcastSendParams.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/broadcasts/BroadcastSendParams.kt @@ -23,11 +23,14 @@ import kotlin.jvm.optionals.getOrNull /** * Start sending the broadcast immediately or schedule for later. * - * **Verification is required to send, and there are two of them.** The team must have completed - * both identity verification (KYC) and business verification (KYB); passing one is not enough. - * Drafts can be created, edited and kept without either. Every send path — dashboard, API and CLI - * alike — enforces both, returning `403` with code `kyc_required` or `kyb_required` for whichever - * is outstanding. + * **Verification is required to send, except on WhatsApp.** On every channel other than `whatsapp`, + * the team must have completed both identity verification (KYC) and business verification (KYB); + * passing one is not enough. A `whatsapp` broadcast requires neither: it can only be built on a + * template, and Meta vets the business and the content when it approves that template, so an + * unapproved template is refused instead. `smart` is not exempt — it can route a contact to SMS or + * email. Drafts can be created, edited and kept without any check. Every send path — dashboard, API + * and CLI alike — enforces the same rule, returning `403` with code `kyc_required` or + * `kyb_required` for whichever is outstanding. * * **Review depends on the channel, and cannot be bypassed.** A draft is submitted to automated * content review here; it does not go straight out. A WhatsApp broadcast built on a Meta-approved diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/BroadcastServiceAsync.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/BroadcastServiceAsync.kt index 11a7ef1..08b7bd2 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/BroadcastServiceAsync.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/BroadcastServiceAsync.kt @@ -366,11 +366,14 @@ interface BroadcastServiceAsync { /** * Start sending the broadcast immediately or schedule for later. * - * **Verification is required to send, and there are two of them.** The team must have completed - * both identity verification (KYC) and business verification (KYB); passing one is not enough. - * Drafts can be created, edited and kept without either. Every send path — dashboard, API and - * CLI alike — enforces both, returning `403` with code `kyc_required` or `kyb_required` for - * whichever is outstanding. + * **Verification is required to send, except on WhatsApp.** On every channel other than + * `whatsapp`, the team must have completed both identity verification (KYC) and business + * verification (KYB); passing one is not enough. A `whatsapp` broadcast requires neither: it + * can only be built on a template, and Meta vets the business and the content when it approves + * that template, so an unapproved template is refused instead. `smart` is not exempt — it can + * route a contact to SMS or email. Drafts can be created, edited and kept without any check. + * Every send path — dashboard, API and CLI alike — enforces the same rule, returning `403` with + * code `kyc_required` or `kyb_required` for whichever is outstanding. * * **Review depends on the channel, and cannot be bypassed.** A draft is submitted to automated * content review here; it does not go straight out. A WhatsApp broadcast built on a diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/BroadcastService.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/BroadcastService.kt index 76a9fa0..4ea9424 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/BroadcastService.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/BroadcastService.kt @@ -338,11 +338,14 @@ interface BroadcastService { /** * Start sending the broadcast immediately or schedule for later. * - * **Verification is required to send, and there are two of them.** The team must have completed - * both identity verification (KYC) and business verification (KYB); passing one is not enough. - * Drafts can be created, edited and kept without either. Every send path — dashboard, API and - * CLI alike — enforces both, returning `403` with code `kyc_required` or `kyb_required` for - * whichever is outstanding. + * **Verification is required to send, except on WhatsApp.** On every channel other than + * `whatsapp`, the team must have completed both identity verification (KYC) and business + * verification (KYB); passing one is not enough. A `whatsapp` broadcast requires neither: it + * can only be built on a template, and Meta vets the business and the content when it approves + * that template, so an unapproved template is refused instead. `smart` is not exempt — it can + * route a contact to SMS or email. Drafts can be created, edited and kept without any check. + * Every send path — dashboard, API and CLI alike — enforces the same rule, returning `403` with + * code `kyc_required` or `kyb_required` for whichever is outstanding. * * **Review depends on the channel, and cannot be bypassed.** A draft is submitted to automated * content review here; it does not go straight out. A WhatsApp broadcast built on a From 565c2f36ad9cb5b2b66e0681938781d45c2f9cda Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Aug 2026 06:19:02 +0000 Subject: [PATCH 09/24] fix(docs): link the javadoc badge so the version stays current after release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc716b5..7c45c54 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![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) +[![javadoc](https://javadoc.io/badge2/com.zavudev.api/zavudev-java/javadoc.svg)](https://javadoc.io/doc/com.zavudev.api/zavudev-java/0.0.1) From 5e3cf0f493d13c979c52a426e845d6713401601d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Aug 2026 23:51:51 +0000 Subject: [PATCH 10/24] feat(api): api update --- .stats.yml | 4 +- .../api/models/messages/MessageContent.kt | 882 +++++++++++++++++- .../api/models/senders/WebhookEvent.kt | 6 +- .../api/models/messages/MessageContentTest.kt | 43 + .../messages/MessageListPageResponseTest.kt | 42 + .../models/messages/MessageResponseTest.kt | 42 + .../models/messages/MessageSendParamsTest.kt | 56 ++ .../api/models/messages/MessageTest.kt | 42 + .../zavudev/api/services/ErrorHandlingTest.kt | 238 +++++ .../zavudev/api/services/ServiceParamsTest.kt | 14 + .../services/async/MessageServiceAsyncTest.kt | 14 + .../services/blocking/MessageServiceTest.kt | 14 + .../api/proguard/ProGuardCompatibilityTest.kt | 14 + 13 files changed, 1407 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index d105c4b..c8f40a3 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-dd62b3849e15304da4087f73928025602737e10a414c87a6c2a5fe7059b9ea37.yml -openapi_spec_hash: 5a3d5cb61a7dd5d556a9f9abd9db01d4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-8ead699d165bc116549ef757ace827bf39add6e0e19afdc1653f0d0282947eae.yml +openapi_spec_hash: 5a35a5dab833f4d1e6deeea795e1abf2 config_hash: 7fca08d9dae18513f5d7451cea11e34c diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/messages/MessageContent.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/messages/MessageContent.kt index 17bbcb4..df213c0 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/messages/MessageContent.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/messages/MessageContent.kt @@ -43,6 +43,7 @@ private constructor( private val mediaUrl: JsonField, private val mimeType: JsonField, private val reactToMessageId: JsonField, + private val referral: JsonField, private val replyToFrom: JsonField, private val replyToMessageId: JsonField, private val replyToMessageType: JsonField, @@ -99,6 +100,7 @@ private constructor( @JsonProperty("reactToMessageId") @ExcludeMissing reactToMessageId: JsonField = JsonMissing.of(), + @JsonProperty("referral") @ExcludeMissing referral: JsonField = JsonMissing.of(), @JsonProperty("replyToFrom") @ExcludeMissing replyToFrom: JsonField = JsonMissing.of(), @@ -149,6 +151,7 @@ private constructor( mediaUrl, mimeType, reactToMessageId, + referral, replyToFrom, replyToMessageId, replyToMessageType, @@ -317,6 +320,22 @@ private constructor( */ fun reactToMessageId(): Optional = reactToMessageId.getOptional("reactToMessageId") + /** + * Click-to-WhatsApp (CTWA) ad attribution: where an inbound conversation came from. + * + * WhatsApp only. Present on the **first inbound message** of a conversation opened from a Meta + * ad or post, and on no message after it — so store it when it arrives rather than expecting it + * again. Organic conversations never carry it. + * + * Field names are camelCased to match the rest of this API; Meta sends them as snake_case + * (`ctwa_clid`, `source_id`, ...). Fields that do not apply are omitted: a `post` source has no + * click id, and an image ad has no `videoUrl`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referral(): Optional = referral.getOptional("referral") + /** * Sender of the quoted message (phone number in E.164 format). * @@ -570,6 +589,13 @@ private constructor( @ExcludeMissing fun _reactToMessageId(): JsonField = reactToMessageId + /** + * Returns the raw JSON value of [referral]. + * + * Unlike [referral], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("referral") @ExcludeMissing fun _referral(): JsonField = referral + /** * Returns the raw JSON value of [replyToFrom]. * @@ -698,6 +724,7 @@ private constructor( private var mediaUrl: JsonField = JsonMissing.of() private var mimeType: JsonField = JsonMissing.of() private var reactToMessageId: JsonField = JsonMissing.of() + private var referral: JsonField = JsonMissing.of() private var replyToFrom: JsonField = JsonMissing.of() private var replyToMessageId: JsonField = JsonMissing.of() private var replyToMessageType: JsonField = JsonMissing.of() @@ -731,6 +758,7 @@ private constructor( mediaUrl = messageContent.mediaUrl mimeType = messageContent.mimeType reactToMessageId = messageContent.reactToMessageId + referral = messageContent.referral replyToFrom = messageContent.replyToFrom replyToMessageId = messageContent.replyToMessageId replyToMessageType = messageContent.replyToMessageType @@ -1017,6 +1045,28 @@ private constructor( this.reactToMessageId = reactToMessageId } + /** + * Click-to-WhatsApp (CTWA) ad attribution: where an inbound conversation came from. + * + * WhatsApp only. Present on the **first inbound message** of a conversation opened from a + * Meta ad or post, and on no message after it — so store it when it arrives rather than + * expecting it again. Organic conversations never carry it. + * + * Field names are camelCased to match the rest of this API; Meta sends them as snake_case + * (`ctwa_clid`, `source_id`, ...). Fields that do not apply are omitted: a `post` source + * has no click id, and an image ad has no `videoUrl`. + */ + fun referral(referral: Referral) = referral(JsonField.of(referral)) + + /** + * Sets [Builder.referral] to an arbitrary JSON value. + * + * You should usually call [Builder.referral] with a well-typed [Referral] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun referral(referral: JsonField) = apply { this.referral = referral } + /** Sender of the quoted message (phone number in E.164 format). */ fun replyToFrom(replyToFrom: String) = replyToFrom(JsonField.of(replyToFrom)) @@ -1249,6 +1299,7 @@ private constructor( mediaUrl, mimeType, reactToMessageId, + referral, replyToFrom, replyToMessageId, replyToMessageType, @@ -1297,6 +1348,7 @@ private constructor( mediaUrl() mimeType() reactToMessageId() + referral().ifPresent { it.validate() } replyToFrom() replyToMessageId() replyToMessageType() @@ -1344,6 +1396,7 @@ private constructor( (if (mediaUrl.asKnown().isPresent) 1 else 0) + (if (mimeType.asKnown().isPresent) 1 else 0) + (if (reactToMessageId.asKnown().isPresent) 1 else 0) + + (referral.asKnown().getOrNull()?.validity() ?: 0) + (if (replyToFrom.asKnown().isPresent) 1 else 0) + (if (replyToMessageId.asKnown().isPresent) 1 else 0) + (if (replyToMessageType.asKnown().isPresent) 1 else 0) + @@ -1906,6 +1959,831 @@ private constructor( override fun toString() = value.toString() } + /** + * Click-to-WhatsApp (CTWA) ad attribution: where an inbound conversation came from. + * + * WhatsApp only. Present on the **first inbound message** of a conversation opened from a Meta + * ad or post, and on no message after it — so store it when it arrives rather than expecting it + * again. Organic conversations never carry it. + * + * Field names are camelCased to match the rest of this API; Meta sends them as snake_case + * (`ctwa_clid`, `source_id`, ...). Fields that do not apply are omitted: a `post` source has no + * click id, and an image ad has no `videoUrl`. + */ + class Referral + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val body: JsonField, + private val ctwaClid: JsonField, + private val headline: JsonField, + private val imageUrl: JsonField, + private val mediaType: JsonField, + private val sourceId: JsonField, + private val sourceType: JsonField, + private val sourceUrl: JsonField, + private val thumbnailUrl: JsonField, + private val videoUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), + @JsonProperty("ctwaClid") + @ExcludeMissing + ctwaClid: JsonField = JsonMissing.of(), + @JsonProperty("headline") + @ExcludeMissing + headline: JsonField = JsonMissing.of(), + @JsonProperty("imageUrl") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("mediaType") + @ExcludeMissing + mediaType: JsonField = JsonMissing.of(), + @JsonProperty("sourceId") + @ExcludeMissing + sourceId: JsonField = JsonMissing.of(), + @JsonProperty("sourceType") + @ExcludeMissing + sourceType: JsonField = JsonMissing.of(), + @JsonProperty("sourceUrl") + @ExcludeMissing + sourceUrl: JsonField = JsonMissing.of(), + @JsonProperty("thumbnailUrl") + @ExcludeMissing + thumbnailUrl: JsonField = JsonMissing.of(), + @JsonProperty("videoUrl") @ExcludeMissing videoUrl: JsonField = JsonMissing.of(), + ) : this( + body, + ctwaClid, + headline, + imageUrl, + mediaType, + sourceId, + sourceType, + sourceUrl, + thumbnailUrl, + videoUrl, + mutableMapOf(), + ) + + /** + * Body copy of the ad or post. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun body(): Optional = body.getOptional("body") + + /** + * Click-to-WhatsApp click identifier. This is the value Meta's Conversions API needs to + * credit a conversion back to the ad that produced the conversation. Present on `ad` + * sources; a `post` source has none. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ctwaClid(): Optional = ctwaClid.getOptional("ctwaClid") + + /** + * Headline of the ad or post. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun headline(): Optional = headline.getOptional("headline") + + /** + * Image of the ad. Present when `mediaType` is `image`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun imageUrl(): Optional = imageUrl.getOptional("imageUrl") + + /** + * Type of media on the ad, when it had any. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mediaType(): Optional = mediaType.getOptional("mediaType") + + /** + * Identifier of the ad or post that produced the click. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceId(): Optional = sourceId.getOptional("sourceId") + + /** + * Where the click came from. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceType(): Optional = sourceType.getOptional("sourceType") + + /** + * Meta permalink to the ad or post. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceUrl(): Optional = sourceUrl.getOptional("sourceUrl") + + /** + * Thumbnail of the ad media. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thumbnailUrl(): Optional = thumbnailUrl.getOptional("thumbnailUrl") + + /** + * Video of the ad. Present when `mediaType` is `video`. + * + * @throws ZavudevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoUrl(): Optional = videoUrl.getOptional("videoUrl") + + /** + * Returns the raw JSON value of [body]. + * + * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + + /** + * Returns the raw JSON value of [ctwaClid]. + * + * Unlike [ctwaClid], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ctwaClid") @ExcludeMissing fun _ctwaClid(): JsonField = ctwaClid + + /** + * Returns the raw JSON value of [headline]. + * + * Unlike [headline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headline") @ExcludeMissing fun _headline(): JsonField = headline + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("imageUrl") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [mediaType]. + * + * Unlike [mediaType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mediaType") + @ExcludeMissing + fun _mediaType(): JsonField = mediaType + + /** + * Returns the raw JSON value of [sourceId]. + * + * Unlike [sourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sourceId") @ExcludeMissing fun _sourceId(): JsonField = sourceId + + /** + * Returns the raw JSON value of [sourceType]. + * + * Unlike [sourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sourceType") + @ExcludeMissing + fun _sourceType(): JsonField = sourceType + + /** + * Returns the raw JSON value of [sourceUrl]. + * + * Unlike [sourceUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sourceUrl") @ExcludeMissing fun _sourceUrl(): JsonField = sourceUrl + + /** + * Returns the raw JSON value of [thumbnailUrl]. + * + * Unlike [thumbnailUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("thumbnailUrl") + @ExcludeMissing + fun _thumbnailUrl(): JsonField = thumbnailUrl + + /** + * Returns the raw JSON value of [videoUrl]. + * + * Unlike [videoUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoUrl") @ExcludeMissing fun _videoUrl(): JsonField = videoUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Referral]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Referral]. */ + class Builder internal constructor() { + + private var body: JsonField = JsonMissing.of() + private var ctwaClid: JsonField = JsonMissing.of() + private var headline: JsonField = JsonMissing.of() + private var imageUrl: JsonField = JsonMissing.of() + private var mediaType: JsonField = JsonMissing.of() + private var sourceId: JsonField = JsonMissing.of() + private var sourceType: JsonField = JsonMissing.of() + private var sourceUrl: JsonField = JsonMissing.of() + private var thumbnailUrl: JsonField = JsonMissing.of() + private var videoUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(referral: Referral) = apply { + body = referral.body + ctwaClid = referral.ctwaClid + headline = referral.headline + imageUrl = referral.imageUrl + mediaType = referral.mediaType + sourceId = referral.sourceId + sourceType = referral.sourceType + sourceUrl = referral.sourceUrl + thumbnailUrl = referral.thumbnailUrl + videoUrl = referral.videoUrl + additionalProperties = referral.additionalProperties.toMutableMap() + } + + /** Body copy of the ad or post. */ + fun body(body: String) = body(JsonField.of(body)) + + /** + * Sets [Builder.body] to an arbitrary JSON value. + * + * You should usually call [Builder.body] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun body(body: JsonField) = apply { this.body = body } + + /** + * Click-to-WhatsApp click identifier. This is the value Meta's Conversions API needs to + * credit a conversion back to the ad that produced the conversation. Present on `ad` + * sources; a `post` source has none. + */ + fun ctwaClid(ctwaClid: String) = ctwaClid(JsonField.of(ctwaClid)) + + /** + * Sets [Builder.ctwaClid] to an arbitrary JSON value. + * + * You should usually call [Builder.ctwaClid] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ctwaClid(ctwaClid: JsonField) = apply { this.ctwaClid = ctwaClid } + + /** Headline of the ad or post. */ + fun headline(headline: String) = headline(JsonField.of(headline)) + + /** + * Sets [Builder.headline] to an arbitrary JSON value. + * + * You should usually call [Builder.headline] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun headline(headline: JsonField) = apply { this.headline = headline } + + /** Image of the ad. Present when `mediaType` is `image`. */ + fun imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } + + /** Type of media on the ad, when it had any. */ + fun mediaType(mediaType: MediaType) = mediaType(JsonField.of(mediaType)) + + /** + * Sets [Builder.mediaType] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaType] with a well-typed [MediaType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mediaType(mediaType: JsonField) = apply { this.mediaType = mediaType } + + /** Identifier of the ad or post that produced the click. */ + fun sourceId(sourceId: String) = sourceId(JsonField.of(sourceId)) + + /** + * Sets [Builder.sourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } + + /** Where the click came from. */ + fun sourceType(sourceType: SourceType) = sourceType(JsonField.of(sourceType)) + + /** + * Sets [Builder.sourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceType] with a well-typed [SourceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceType(sourceType: JsonField) = apply { + this.sourceType = sourceType + } + + /** Meta permalink to the ad or post. */ + fun sourceUrl(sourceUrl: String) = sourceUrl(JsonField.of(sourceUrl)) + + /** + * Sets [Builder.sourceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceUrl(sourceUrl: JsonField) = apply { this.sourceUrl = sourceUrl } + + /** Thumbnail of the ad media. */ + fun thumbnailUrl(thumbnailUrl: String) = thumbnailUrl(JsonField.of(thumbnailUrl)) + + /** + * Sets [Builder.thumbnailUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun thumbnailUrl(thumbnailUrl: JsonField) = apply { + this.thumbnailUrl = thumbnailUrl + } + + /** Video of the ad. Present when `mediaType` is `video`. */ + fun videoUrl(videoUrl: String) = videoUrl(JsonField.of(videoUrl)) + + /** + * Sets [Builder.videoUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.videoUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun videoUrl(videoUrl: JsonField) = apply { this.videoUrl = videoUrl } + + 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 [Referral]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Referral = + Referral( + body, + ctwaClid, + headline, + imageUrl, + mediaType, + sourceId, + sourceType, + sourceUrl, + thumbnailUrl, + videoUrl, + 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(): Referral = apply { + if (validated) { + return@apply + } + + body() + ctwaClid() + headline() + imageUrl() + mediaType().ifPresent { it.validate() } + sourceId() + sourceType().ifPresent { it.validate() } + sourceUrl() + thumbnailUrl() + videoUrl() + 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 (body.asKnown().isPresent) 1 else 0) + + (if (ctwaClid.asKnown().isPresent) 1 else 0) + + (if (headline.asKnown().isPresent) 1 else 0) + + (if (imageUrl.asKnown().isPresent) 1 else 0) + + (mediaType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sourceId.asKnown().isPresent) 1 else 0) + + (sourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sourceUrl.asKnown().isPresent) 1 else 0) + + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + + (if (videoUrl.asKnown().isPresent) 1 else 0) + + /** Type of media on the ad, when it had any. */ + class MediaType @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 IMAGE = of("image") + + @JvmField val VIDEO = of("video") + + @JvmStatic fun of(value: String) = MediaType(JsonField.of(value)) + } + + /** An enum containing [MediaType]'s known values. */ + enum class Known { + IMAGE, + VIDEO, + } + + /** + * An enum containing [MediaType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [MediaType] 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 { + IMAGE, + VIDEO, + /** + * An enum member indicating that [MediaType] 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) { + IMAGE -> Value.IMAGE + VIDEO -> Value.VIDEO + 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) { + IMAGE -> Known.IMAGE + VIDEO -> Known.VIDEO + else -> throw ZavudevInvalidDataException("Unknown MediaType: $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(): MediaType = 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 MediaType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Where the click came from. */ + class SourceType @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 AD = of("ad") + + @JvmField val POST = of("post") + + @JvmStatic fun of(value: String) = SourceType(JsonField.of(value)) + } + + /** An enum containing [SourceType]'s known values. */ + enum class Known { + AD, + POST, + } + + /** + * An enum containing [SourceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SourceType] 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 { + AD, + POST, + /** + * An enum member indicating that [SourceType] 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) { + AD -> Value.AD + POST -> Value.POST + 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) { + AD -> Known.AD + POST -> Known.POST + else -> throw ZavudevInvalidDataException("Unknown SourceType: $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(): SourceType = 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 SourceType && 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 Referral && + body == other.body && + ctwaClid == other.ctwaClid && + headline == other.headline && + imageUrl == other.imageUrl && + mediaType == other.mediaType && + sourceId == other.sourceId && + sourceType == other.sourceType && + sourceUrl == other.sourceUrl && + thumbnailUrl == other.thumbnailUrl && + videoUrl == other.videoUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + body, + ctwaClid, + headline, + imageUrl, + mediaType, + sourceId, + sourceType, + sourceUrl, + thumbnailUrl, + videoUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Referral{body=$body, ctwaClid=$ctwaClid, headline=$headline, imageUrl=$imageUrl, mediaType=$mediaType, sourceId=$sourceId, sourceType=$sourceType, sourceUrl=$sourceUrl, thumbnailUrl=$thumbnailUrl, videoUrl=$videoUrl, additionalProperties=$additionalProperties}" + } + class Section @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -2750,6 +3628,7 @@ private constructor( mediaUrl == other.mediaUrl && mimeType == other.mimeType && reactToMessageId == other.reactToMessageId && + referral == other.referral && replyToFrom == other.replyToFrom && replyToMessageId == other.replyToMessageId && replyToMessageType == other.replyToMessageType && @@ -2784,6 +3663,7 @@ private constructor( mediaUrl, mimeType, reactToMessageId, + referral, replyToFrom, replyToMessageId, replyToMessageType, @@ -2801,5 +3681,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MessageContent{buttons=$buttons, contacts=$contacts, ctaDisplayText=$ctaDisplayText, ctaHeaderMediaUrl=$ctaHeaderMediaUrl, ctaHeaderText=$ctaHeaderText, ctaHeaderType=$ctaHeaderType, ctaUrl=$ctaUrl, emoji=$emoji, filename=$filename, footerText=$footerText, latitude=$latitude, listButton=$listButton, locationAddress=$locationAddress, locationName=$locationName, longitude=$longitude, mediaId=$mediaId, mediaUrl=$mediaUrl, mimeType=$mimeType, reactToMessageId=$reactToMessageId, replyToFrom=$replyToFrom, replyToMessageId=$replyToMessageId, replyToMessageType=$replyToMessageType, replyToProviderMessageId=$replyToProviderMessageId, replyToText=$replyToText, sections=$sections, templateButtonVariables=$templateButtonVariables, templateHeaderVariables=$templateHeaderVariables, templateId=$templateId, templateVariables=$templateVariables, additionalProperties=$additionalProperties}" + "MessageContent{buttons=$buttons, contacts=$contacts, ctaDisplayText=$ctaDisplayText, ctaHeaderMediaUrl=$ctaHeaderMediaUrl, ctaHeaderText=$ctaHeaderText, ctaHeaderType=$ctaHeaderType, ctaUrl=$ctaUrl, emoji=$emoji, filename=$filename, footerText=$footerText, latitude=$latitude, listButton=$listButton, locationAddress=$locationAddress, locationName=$locationName, longitude=$longitude, mediaId=$mediaId, mediaUrl=$mediaUrl, mimeType=$mimeType, reactToMessageId=$reactToMessageId, referral=$referral, replyToFrom=$replyToFrom, replyToMessageId=$replyToMessageId, replyToMessageType=$replyToMessageType, replyToProviderMessageId=$replyToProviderMessageId, replyToText=$replyToText, sections=$sections, templateButtonVariables=$templateButtonVariables, templateHeaderVariables=$templateHeaderVariables, templateId=$templateId, templateVariables=$templateVariables, additionalProperties=$additionalProperties}" } diff --git a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/WebhookEvent.kt b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/WebhookEvent.kt index dfa0da9..336361f 100644 --- a/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/WebhookEvent.kt +++ b/zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/WebhookEvent.kt @@ -29,7 +29,11 @@ import com.zavudev.api.errors.ZavudevInvalidDataException * `data.providerTimestamp` is the provider's original receive time in Unix milliseconds (the * moment the channel received the message from the contact — WhatsApp, Telegram, Instagram, * Messenger; `null` for SMS and email). Compare it against the top-level `timestamp` (when Zavu - * dispatched the webhook) to detect and ignore delayed deliveries. + * dispatched the webhook) to detect and ignore delayed deliveries. When the conversation was + * opened from a Click-to-WhatsApp ad or post, `data.referral` carries the ad attribution — + * including `ctwaClid`, the identifier Meta's Conversions API needs to credit a conversion back + * to that ad. WhatsApp only, and only on the first message of the thread: it is absent from every + * later message, so persist it when it arrives. * - `message.unsupported`: Received a message type that is not supported * * **Broadcast events:** diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageContentTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageContentTest.kt index 04ba3cd..155f599 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageContentTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageContentTest.kt @@ -36,6 +36,20 @@ internal class MessageContentTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -95,6 +109,21 @@ internal class MessageContentTest { assertThat(messageContent.mediaUrl()).contains("https://example.com/image.jpg") assertThat(messageContent.mimeType()).contains("image/jpeg") assertThat(messageContent.reactToMessageId()).contains("reactToMessageId") + assertThat(messageContent.referral()) + .contains( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) assertThat(messageContent.replyToFrom()).contains("replyToFrom") assertThat(messageContent.replyToMessageId()).contains("replyToMessageId") assertThat(messageContent.replyToMessageType()).contains("replyToMessageType") @@ -161,6 +190,20 @@ internal class MessageContentTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageListPageResponseTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageListPageResponseTest.kt index ef03ca3..89c4488 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageListPageResponseTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageListPageResponseTest.kt @@ -51,6 +51,20 @@ internal class MessageListPageResponseTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -148,6 +162,20 @@ internal class MessageListPageResponseTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -246,6 +274,20 @@ internal class MessageListPageResponseTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageResponseTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageResponseTest.kt index 49fc63f..f9f3ff1 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageResponseTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageResponseTest.kt @@ -51,6 +51,20 @@ internal class MessageResponseTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -147,6 +161,20 @@ internal class MessageResponseTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -244,6 +272,20 @@ internal class MessageResponseTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageSendParamsTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageSendParamsTest.kt index af9622e..dc87f76 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageSendParamsTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageSendParamsTest.kt @@ -48,6 +48,20 @@ internal class MessageSendParamsTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -139,6 +153,20 @@ internal class MessageSendParamsTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -243,6 +271,20 @@ internal class MessageSendParamsTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -332,6 +374,20 @@ internal class MessageSendParamsTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageTest.kt index 69884fd..bfac608 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageTest.kt @@ -44,6 +44,20 @@ internal class MessageTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -128,6 +142,20 @@ internal class MessageTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -217,6 +245,20 @@ internal class MessageTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ErrorHandlingTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ErrorHandlingTest.kt index 858bad3..fe4a19a 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ErrorHandlingTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ErrorHandlingTest.kt @@ -115,6 +115,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -230,6 +244,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -345,6 +373,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -460,6 +502,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -575,6 +631,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -690,6 +760,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -805,6 +889,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -920,6 +1018,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1035,6 +1147,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1150,6 +1276,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1265,6 +1405,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1380,6 +1534,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1495,6 +1663,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1610,6 +1792,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1725,6 +1921,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1840,6 +2050,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") @@ -1953,6 +2177,20 @@ internal class ErrorHandlingTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ServiceParamsTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ServiceParamsTest.kt index de52639..1293e5a 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ServiceParamsTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/ServiceParamsTest.kt @@ -82,6 +82,20 @@ internal class ServiceParamsTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/MessageServiceAsyncTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/MessageServiceAsyncTest.kt index 6f7d36f..9e08131 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/MessageServiceAsyncTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/MessageServiceAsyncTest.kt @@ -107,6 +107,20 @@ internal class MessageServiceAsyncTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/MessageServiceTest.kt b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/MessageServiceTest.kt index d57aff7..9eafeeb 100644 --- a/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/MessageServiceTest.kt +++ b/zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/MessageServiceTest.kt @@ -104,6 +104,20 @@ internal class MessageServiceTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") diff --git a/zavudev-java-proguard-test/src/test/kotlin/com/zavudev/api/proguard/ProGuardCompatibilityTest.kt b/zavudev-java-proguard-test/src/test/kotlin/com/zavudev/api/proguard/ProGuardCompatibilityTest.kt index eae9851..a7d938d 100644 --- a/zavudev-java-proguard-test/src/test/kotlin/com/zavudev/api/proguard/ProGuardCompatibilityTest.kt +++ b/zavudev-java-proguard-test/src/test/kotlin/com/zavudev/api/proguard/ProGuardCompatibilityTest.kt @@ -105,6 +105,20 @@ internal class ProGuardCompatibilityTest { .mediaUrl("https://example.com/image.jpg") .mimeType("image/jpeg") .reactToMessageId("reactToMessageId") + .referral( + MessageContent.Referral.builder() + .body("body") + .ctwaClid("ARIzZm9vYmFyY3R3YWNsaWQ") + .headline("headline") + .imageUrl("https://example.com") + .mediaType(MessageContent.Referral.MediaType.IMAGE) + .sourceId("120210000000000000") + .sourceType(MessageContent.Referral.SourceType.AD) + .sourceUrl("https://example.com") + .thumbnailUrl("https://example.com") + .videoUrl("https://example.com") + .build() + ) .replyToFrom("replyToFrom") .replyToMessageId("replyToMessageId") .replyToMessageType("replyToMessageType") From 267117fd99196f24178a3ebd8a07cd05a9d75b98 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2026 20:34:17 +0000 Subject: [PATCH 11/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index c8f40a3..d1cb2f5 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-8ead699d165bc116549ef757ace827bf39add6e0e19afdc1653f0d0282947eae.yml -openapi_spec_hash: 5a35a5dab833f4d1e6deeea795e1abf2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-a3e89fc19e2d04b767db8da79617311c572cc2a0273abf1f211c77999c164a71.yml +openapi_spec_hash: 920231951c3213b2a70bdddf6f4922fb config_hash: 7fca08d9dae18513f5d7451cea11e34c From a9d330b32f9f8fafb135ea832219f65f119c69ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Aug 2026 05:37:20 +0000 Subject: [PATCH 12/24] chore(internal): codegen related update --- zavudev-java-core/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) 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") } From 13701dd5a04f1544d874462a2ff357e12efe5b81 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 12:41:39 +0000 Subject: [PATCH 13/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d1cb2f5..968d7bb 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-a3e89fc19e2d04b767db8da79617311c572cc2a0273abf1f211c77999c164a71.yml -openapi_spec_hash: 920231951c3213b2a70bdddf6f4922fb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-5f801823f89d92d2c00f2bc33b30aa7b127f21b5f3fb38f9278f06ce1d79b869.yml +openapi_spec_hash: d1baedab2c021ab97b4aba0030180b29 config_hash: 7fca08d9dae18513f5d7451cea11e34c From 63b44c49d54d30acf64ecb1133a8bc4b62991591 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:06:41 +0000 Subject: [PATCH 14/24] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 968d7bb..ec5b810 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-5f801823f89d92d2c00f2bc33b30aa7b127f21b5f3fb38f9278f06ce1d79b869.yml -openapi_spec_hash: d1baedab2c021ab97b4aba0030180b29 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-9acbefe4fc4908c698c1165bed491d415687f0092e9df6ffb968f92e43b11961.yml +openapi_spec_hash: 410cb45b6fa3a8a1f3da3aba50accbdc config_hash: 7fca08d9dae18513f5d7451cea11e34c From 2299c467566b3c253997cfdf40486c7215e24d02 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:23:42 +0000 Subject: [PATCH 15/24] feat(api): manual updates --- .stats.yml | 6 +- .../com/zavudev/api/client/ZavudevClient.kt | 25 + .../zavudev/api/client/ZavudevClientAsync.kt | 25 + .../api/client/ZavudevClientAsyncImpl.kt | 68 + .../zavudev/api/client/ZavudevClientImpl.kt | 66 + .../api/models/agents/AgentCreateParams.kt | 2366 ++++++++++++++++ .../api/models/agents/AgentCreateResponse.kt | 180 ++ .../api/models/agents/AgentDeleteParams.kt | 229 ++ .../api/models/agents/AgentListPage.kt | 131 + .../api/models/agents/AgentListPageAsync.kt | 145 + .../models/agents/AgentListPageResponse.kt | 233 ++ .../api/models/agents/AgentListParams.kt | 213 ++ .../models/agents/AgentListVoicesParams.kt | 199 ++ .../models/agents/AgentListVoicesResponse.kt | 526 ++++ .../api/models/agents/AgentRetrieveParams.kt | 189 ++ .../models/agents/AgentRetrieveResponse.kt | 183 ++ .../api/models/agents/AgentTestParams.kt | 1073 +++++++ .../api/models/agents/AgentTestResponse.kt | 808 ++++++ .../api/models/agents/AgentUpdateParams.kt | 2472 +++++++++++++++++ .../api/models/agents/AgentUpdateResponse.kt | 180 ++ .../agents/senders/SenderConnectParams.kt | 449 +++ .../agents/senders/SenderConnectResponse.kt | 183 ++ .../agents/senders/SenderDisconnectParams.kt | 262 ++ .../agenttemplates/AgentTemplateListParams.kt | 174 ++ .../AgentTemplateListResponse.kt | 696 +++++ .../AgentTemplateRetrieveParams.kt | 200 ++ .../AgentTemplateRetrieveResponse.kt | 1394 ++++++++++ .../api/models/calls/CallCreateParams.kt | 935 +++++++ .../api/models/calls/CallCreateResponse.kt | 1954 +++++++++++++ .../api/models/calls/CallHangupParams.kt | 232 ++ .../api/models/calls/CallHangupResponse.kt | 1954 +++++++++++++ .../zavudev/api/models/calls/CallListPage.kt | 130 + .../api/models/calls/CallListPageAsync.kt | 145 + .../api/models/calls/CallListPageResponse.kt | 234 ++ .../api/models/calls/CallListParams.kt | 589 ++++ .../api/models/calls/CallListResponse.kt | 1739 ++++++++++++ .../api/models/calls/CallRetrieveParams.kt | 192 ++ .../api/models/calls/CallRetrieveResponse.kt | 1954 +++++++++++++ .../ConversationListMessagesPage.kt | 134 + .../ConversationListMessagesPageAsync.kt | 150 + .../ConversationListMessagesPageResponse.kt | 237 ++ .../ConversationListMessagesParams.kt | 242 ++ .../conversations/ConversationListPage.kt | 131 + .../ConversationListPageAsync.kt | 146 + .../ConversationListPageResponse.kt | 236 ++ .../conversations/ConversationListParams.kt | 477 ++++ .../conversations/ConversationListResponse.kt | 1591 +++++++++++ .../ConversationMarkAsReadParams.kt | 241 ++ .../ConversationMarkAsReadResponse.kt | 1834 ++++++++++++ .../ConversationRetrieveParams.kt | 197 ++ .../ConversationRetrieveResponse.kt | 1832 ++++++++++++ .../emaildomains/EmailDomainCreateParams.kt | 426 +++ .../emaildomains/EmailDomainCreateResponse.kt | 1046 +++++++ .../emaildomains/EmailDomainDeleteParams.kt | 230 ++ .../emaildomains/EmailDomainListParams.kt | 170 ++ .../emaildomains/EmailDomainListResponse.kt | 1061 +++++++ .../emaildomains/EmailDomainRetrieveParams.kt | 195 ++ .../EmailDomainRetrieveResponse.kt | 1046 +++++++ .../emaildomains/EmailDomainVerifyParams.kt | 230 ++ .../emaildomains/EmailDomainVerifyResponse.kt | 1046 +++++++ .../FunctionListDeploymentsParams.kt | 225 ++ .../FunctionListDeploymentsResponse.kt | 830 ++++++ .../functions/FunctionListEventTypesParams.kt | 176 ++ .../FunctionListEventTypesResponse.kt | 198 ++ .../FunctionRollbackDeploymentParams.kt | 467 ++++ .../FunctionRollbackDeploymentResponse.kt | 1011 +++++++ .../gitlink/GitLinkDeployNowParams.kt | 234 ++ .../gitlink/GitLinkDeployNowResponse.kt | 179 ++ .../functions/gitlink/GitLinkLinkParams.kt | 698 +++++ .../functions/gitlink/GitLinkLinkResponse.kt | 1532 ++++++++++ .../gitlink/GitLinkRetrieveParams.kt | 194 ++ .../gitlink/GitLinkRetrieveResponse.kt | 1532 ++++++++++ .../functions/gitlink/GitLinkUnlinkParams.kt | 232 ++ .../functions/gitlink/GitLinkUpdateParams.kt | 540 ++++ .../gitlink/GitLinkUpdateResponse.kt | 1532 ++++++++++ .../functions/triggers/TriggerCreateParams.kt | 652 +++++ .../triggers/TriggerCreateResponse.kt | 832 ++++++ .../functions/triggers/TriggerDeleteParams.kt | 229 ++ .../functions/triggers/TriggerListParams.kt | 190 ++ .../functions/triggers/TriggerListResponse.kt | 761 +++++ .../functions/triggers/TriggerUpdateParams.kt | 438 +++ .../triggers/TriggerUpdateResponse.kt | 212 ++ .../IntrospectValidateEmailParams.kt | 509 ++++ .../IntrospectValidateEmailResponse.kt | 1222 ++++++++ .../messages/MessageListAttachmentsParams.kt | 201 ++ .../MessageListAttachmentsResponse.kt | 681 +++++ .../DocumentRetrieveDocumentParams.kt | 230 ++ .../DocumentRetrieveDocumentResponse.kt | 186 ++ .../documents/DocumentUpdateDocumentParams.kt | 506 ++++ .../DocumentUpdateDocumentResponse.kt | 185 ++ .../agent/tools/ToolListTestRunsParams.kt | 245 ++ .../agent/tools/ToolListTestRunsResponse.kt | 819 ++++++ .../webhook/WebhookRotateSecretParams.kt | 263 ++ .../senders/telegram/TelegramConnectParams.kt | 448 +++ .../telegram/TelegramConnectResponse.kt | 422 +++ .../telegram/TelegramDisconnectParams.kt | 230 ++ .../models/templates/TemplateSyncParams.kt | 423 +++ .../models/templates/TemplateSyncResponse.kt | 409 +++ .../api/models/urls/UrlEscalateParams.kt | 447 +++ .../api/models/urls/UrlEscalateResponse.kt | 213 ++ .../api/services/async/AgentServiceAsync.kt | 466 ++++ .../services/async/AgentServiceAsyncImpl.kt | 351 +++ .../async/AgentTemplateServiceAsync.kt | 176 ++ .../async/AgentTemplateServiceAsyncImpl.kt | 128 + .../api/services/async/CallServiceAsync.kt | 284 ++ .../services/async/CallServiceAsyncImpl.kt | 221 ++ .../async/ConversationServiceAsync.kt | 346 +++ .../async/ConversationServiceAsyncImpl.kt | 232 ++ .../services/async/EmailDomainServiceAsync.kt | 351 +++ .../async/EmailDomainServiceAsyncImpl.kt | 248 ++ .../services/async/FunctionServiceAsync.kt | 213 ++ .../async/FunctionServiceAsyncImpl.kt | 148 + .../services/async/IntrospectServiceAsync.kt | 60 + .../async/IntrospectServiceAsyncImpl.kt | 40 + .../api/services/async/MessageServiceAsync.kt | 89 + .../services/async/MessageServiceAsyncImpl.kt | 42 + .../api/services/async/SenderServiceAsync.kt | 5 + .../services/async/SenderServiceAsyncImpl.kt | 12 + .../services/async/TemplateServiceAsync.kt | 64 + .../async/TemplateServiceAsyncImpl.kt | 40 + .../api/services/async/UrlServiceAsync.kt | 57 + .../api/services/async/UrlServiceAsyncImpl.kt | 43 + .../async/agents/SenderServiceAsync.kt | 153 + .../async/agents/SenderServiceAsyncImpl.kt | 133 + .../async/functions/GitLinkServiceAsync.kt | 430 +++ .../functions/GitLinkServiceAsyncImpl.kt | 255 ++ .../async/functions/TriggerServiceAsync.kt | 310 +++ .../functions/TriggerServiceAsyncImpl.kt | 212 ++ .../async/senders/TelegramServiceAsync.kt | 170 ++ .../async/senders/TelegramServiceAsyncImpl.kt | 127 + .../async/senders/agent/ToolServiceAsync.kt | 66 + .../senders/agent/ToolServiceAsyncImpl.kt | 62 + .../knowledgebases/DocumentServiceAsync.kt | 120 + .../DocumentServiceAsyncImpl.kt | 103 + .../agent/tools/WebhookServiceAsync.kt | 101 + .../agent/tools/WebhookServiceAsyncImpl.kt | 100 + .../api/services/blocking/AgentService.kt | 449 +++ .../api/services/blocking/AgentServiceImpl.kt | 320 +++ .../services/blocking/AgentTemplateService.kt | 177 ++ .../blocking/AgentTemplateServiceImpl.kt | 121 + .../api/services/blocking/CallService.kt | 276 ++ .../api/services/blocking/CallServiceImpl.kt | 203 ++ .../services/blocking/ConversationService.kt | 348 +++ .../blocking/ConversationServiceImpl.kt | 217 ++ .../services/blocking/EmailDomainService.kt | 343 +++ .../blocking/EmailDomainServiceImpl.kt | 230 ++ .../api/services/blocking/FunctionService.kt | 218 ++ .../services/blocking/FunctionServiceImpl.kt | 139 + .../services/blocking/IntrospectService.kt | 61 + .../blocking/IntrospectServiceImpl.kt | 37 + .../api/services/blocking/MessageService.kt | 90 + .../services/blocking/MessageServiceImpl.kt | 39 + .../api/services/blocking/SenderService.kt | 5 + .../services/blocking/SenderServiceImpl.kt | 12 + .../api/services/blocking/TemplateService.kt | 63 + .../services/blocking/TemplateServiceImpl.kt | 37 + .../api/services/blocking/UrlService.kt | 57 + .../api/services/blocking/UrlServiceImpl.kt | 40 + .../services/blocking/agents/SenderService.kt | 146 + .../blocking/agents/SenderServiceImpl.kt | 124 + .../blocking/functions/GitLinkService.kt | 414 +++ .../blocking/functions/GitLinkServiceImpl.kt | 237 ++ .../blocking/functions/TriggerService.kt | 295 ++ .../blocking/functions/TriggerServiceImpl.kt | 197 ++ .../blocking/senders/TelegramService.kt | 165 ++ .../blocking/senders/TelegramServiceImpl.kt | 118 + .../blocking/senders/agent/ToolService.kt | 66 + .../blocking/senders/agent/ToolServiceImpl.kt | 59 + .../agent/knowledgebases/DocumentService.kt | 122 + .../knowledgebases/DocumentServiceImpl.kt | 97 + .../senders/agent/tools/WebhookService.kt | 97 + .../senders/agent/tools/WebhookServiceImpl.kt | 96 + .../models/agents/AgentCreateParamsTest.kt | 161 ++ .../models/agents/AgentCreateResponseTest.kt | 214 ++ .../models/agents/AgentDeleteParamsTest.kt | 23 + .../agents/AgentListPageResponseTest.kt | 217 ++ .../api/models/agents/AgentListParamsTest.kt | 34 + .../agents/AgentListVoicesParamsTest.kt | 33 + .../agents/AgentListVoicesResponseTest.kt | 63 + .../models/agents/AgentRetrieveParamsTest.kt | 23 + .../agents/AgentRetrieveResponseTest.kt | 214 ++ .../api/models/agents/AgentTestParamsTest.kt | 82 + .../models/agents/AgentTestResponseTest.kt | 82 + .../models/agents/AgentUpdateParamsTest.kt | 167 ++ .../models/agents/AgentUpdateResponseTest.kt | 214 ++ .../agents/senders/SenderConnectParamsTest.kt | 32 + .../senders/SenderConnectResponseTest.kt | 214 ++ .../senders/SenderDisconnectParamsTest.kt | 25 + .../AgentTemplateListParamsTest.kt | 13 + .../AgentTemplateListResponseTest.kt | 66 + .../AgentTemplateRetrieveParamsTest.kt | 23 + .../AgentTemplateRetrieveResponseTest.kt | 119 + .../api/models/calls/CallCreateParamsTest.kt | 66 + .../models/calls/CallCreateResponseTest.kt | 131 + .../api/models/calls/CallHangupParamsTest.kt | 23 + .../models/calls/CallHangupResponseTest.kt | 131 + .../models/calls/CallListPageResponseTest.kt | 134 + .../api/models/calls/CallListParamsTest.kt | 52 + .../api/models/calls/CallListResponseTest.kt | 125 + .../models/calls/CallRetrieveParamsTest.kt | 23 + .../models/calls/CallRetrieveResponseTest.kt | 131 + ...onversationListMessagesPageResponseTest.kt | 365 +++ .../ConversationListMessagesParamsTest.kt | 54 + .../ConversationListPageResponseTest.kt | 152 + .../ConversationListParamsTest.kt | 55 + .../ConversationListResponseTest.kt | 140 + .../ConversationMarkAsReadParamsTest.kt | 23 + .../ConversationMarkAsReadResponseTest.kt | 161 ++ .../ConversationRetrieveParamsTest.kt | 23 + .../ConversationRetrieveResponseTest.kt | 158 ++ .../EmailDomainCreateParamsTest.kt | 23 + .../EmailDomainCreateResponseTest.kt | 90 + .../EmailDomainDeleteParamsTest.kt | 23 + .../emaildomains/EmailDomainListParamsTest.kt | 13 + .../EmailDomainListResponseTest.kt | 90 + .../EmailDomainRetrieveParamsTest.kt | 23 + .../EmailDomainRetrieveResponseTest.kt | 90 + .../EmailDomainVerifyParamsTest.kt | 23 + .../EmailDomainVerifyResponseTest.kt | 90 + .../FunctionListDeploymentsParamsTest.kt | 43 + .../FunctionListDeploymentsResponseTest.kt | 74 + .../FunctionListEventTypesParamsTest.kt | 13 + .../FunctionListEventTypesResponseTest.kt | 40 + .../FunctionRollbackDeploymentParamsTest.kt | 43 + .../FunctionRollbackDeploymentResponseTest.kt | 88 + .../gitlink/GitLinkDeployNowParamsTest.kt | 23 + .../gitlink/GitLinkDeployNowResponseTest.kt | 32 + .../gitlink/GitLinkLinkParamsTest.kt | 71 + .../gitlink/GitLinkLinkResponseTest.kt | 103 + .../gitlink/GitLinkRetrieveParamsTest.kt | 23 + .../gitlink/GitLinkRetrieveResponseTest.kt | 103 + .../gitlink/GitLinkUnlinkParamsTest.kt | 23 + .../gitlink/GitLinkUpdateParamsTest.kt | 52 + .../gitlink/GitLinkUpdateResponseTest.kt | 103 + .../triggers/TriggerCreateParamsTest.kt | 65 + .../triggers/TriggerCreateResponseTest.kt | 85 + .../triggers/TriggerDeleteParamsTest.kt | 23 + .../triggers/TriggerListParamsTest.kt | 23 + .../triggers/TriggerListResponseTest.kt | 79 + .../triggers/TriggerUpdateParamsTest.kt | 32 + .../triggers/TriggerUpdateResponseTest.kt | 33 + .../IntrospectValidateEmailParamsTest.kt | 42 + .../IntrospectValidateEmailResponseTest.kt | 89 + .../MessageListAttachmentsParamsTest.kt | 23 + .../MessageListAttachmentsResponseTest.kt | 74 + .../DocumentRetrieveDocumentParamsTest.kt | 34 + .../DocumentRetrieveDocumentResponseTest.kt | 75 + .../DocumentUpdateDocumentParamsTest.kt | 65 + .../DocumentUpdateDocumentResponseTest.kt | 75 + .../agent/tools/ToolListTestRunsParamsTest.kt | 48 + .../tools/ToolListTestRunsResponseTest.kt | 89 + .../webhook/WebhookRotateSecretParamsTest.kt | 25 + .../telegram/TelegramConnectParamsTest.kt | 34 + .../telegram/TelegramConnectResponseTest.kt | 57 + .../telegram/TelegramDisconnectParamsTest.kt | 23 + .../templates/TemplateSyncParamsTest.kt | 30 + .../templates/TemplateSyncResponseTest.kt | 53 + .../api/models/urls/UrlEscalateParamsTest.kt | 44 + .../models/urls/UrlEscalateResponseTest.kt | 73 + .../services/async/AgentServiceAsyncTest.kt | 205 ++ .../async/AgentTemplateServiceAsyncTest.kt | 34 + .../services/async/CallServiceAsyncTest.kt | 74 + .../async/ConversationServiceAsyncTest.kt | 58 + .../async/EmailDomainServiceAsyncTest.kt | 73 + .../async/FunctionServiceAsyncTest.kt | 47 + .../async/IntrospectServiceAsyncTest.kt | 20 + .../services/async/MessageServiceAsyncTest.kt | 12 + .../async/TemplateServiceAsyncTest.kt | 14 + .../api/services/async/UrlServiceAsyncTest.kt | 19 + .../async/agents/SenderServiceAsyncTest.kt | 41 + .../functions/GitLinkServiceAsyncTest.kt | 89 + .../functions/TriggerServiceAsyncTest.kt | 70 + .../async/senders/TelegramServiceAsyncTest.kt | 37 + .../senders/agent/ToolServiceAsyncTest.kt | 20 + .../DocumentServiceAsyncTest.kt | 42 + .../agent/tools/WebhookServiceAsyncTest.kt | 26 + .../api/services/blocking/AgentServiceTest.kt | 197 ++ .../blocking/AgentTemplateServiceTest.kt | 32 + .../api/services/blocking/CallServiceTest.kt | 70 + .../blocking/ConversationServiceTest.kt | 54 + .../blocking/EmailDomainServiceTest.kt | 67 + .../services/blocking/FunctionServiceTest.kt | 44 + .../blocking/IntrospectServiceTest.kt | 19 + .../services/blocking/MessageServiceTest.kt | 11 + .../services/blocking/TemplateServiceTest.kt | 13 + .../api/services/blocking/UrlServiceTest.kt | 18 + .../blocking/agents/SenderServiceTest.kt | 37 + .../blocking/functions/GitLinkServiceTest.kt | 83 + .../blocking/functions/TriggerServiceTest.kt | 65 + .../blocking/senders/TelegramServiceTest.kt | 34 + .../blocking/senders/agent/ToolServiceTest.kt | 19 + .../knowledgebases/DocumentServiceTest.kt | 40 + .../senders/agent/tools/WebhookServiceTest.kt | 25 + .../api/proguard/ProGuardCompatibilityTest.kt | 5 + 294 files changed, 76106 insertions(+), 3 deletions(-) create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentCreateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentDeleteParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPage.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListPageResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentListVoicesResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentRetrieveResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentTestResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/AgentUpdateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderConnectResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agents/senders/SenderDisconnectParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallCreateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallCreateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallHangupParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallHangupResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallListPage.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallListPageAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallListPageResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallListParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallListResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallRetrieveParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/calls/CallRetrieveResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListMessagesPage.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListMessagesPageAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListMessagesPageResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListMessagesParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListPage.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListPageAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListPageResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationListResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationMarkAsReadParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationMarkAsReadResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationRetrieveParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/conversations/ConversationRetrieveResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainCreateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainCreateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainDeleteParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainListParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainListResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainRetrieveParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainRetrieveResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainVerifyParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/emaildomains/EmailDomainVerifyResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionListDeploymentsParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionListDeploymentsResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionListEventTypesParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionListEventTypesResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionRollbackDeploymentParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/FunctionRollbackDeploymentResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkDeployNowParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkDeployNowResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkLinkParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkLinkResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkRetrieveParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkRetrieveResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkUnlinkParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkUpdateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkUpdateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerCreateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerCreateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerDeleteParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerListParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerListResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerUpdateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/functions/triggers/TriggerUpdateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/introspect/IntrospectValidateEmailParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/introspect/IntrospectValidateEmailResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/messages/MessageListAttachmentsParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/messages/MessageListAttachmentsResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentRetrieveDocumentParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentRetrieveDocumentResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentUpdateDocumentParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentUpdateDocumentResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/tools/ToolListTestRunsParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/tools/ToolListTestRunsResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/agent/tools/webhook/WebhookRotateSecretParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/telegram/TelegramConnectParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/telegram/TelegramConnectResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/senders/telegram/TelegramDisconnectParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/templates/TemplateSyncParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/templates/TemplateSyncResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/urls/UrlEscalateParams.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/models/urls/UrlEscalateResponse.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/AgentServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/AgentServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/AgentTemplateServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/AgentTemplateServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/CallServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/CallServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/ConversationServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/ConversationServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/EmailDomainServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/EmailDomainServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/agents/SenderServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/agents/SenderServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/functions/GitLinkServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/functions/GitLinkServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/functions/TriggerServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/functions/TriggerServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/senders/TelegramServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/senders/TelegramServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/senders/agent/tools/WebhookServiceAsync.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/async/senders/agent/tools/WebhookServiceAsyncImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/AgentService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/AgentServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/AgentTemplateService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/AgentTemplateServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/CallService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/CallServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/ConversationService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/ConversationServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/EmailDomainService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/EmailDomainServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/agents/SenderService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/agents/SenderServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/functions/GitLinkService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/functions/GitLinkServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/functions/TriggerService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/functions/TriggerServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/senders/TelegramService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/senders/TelegramServiceImpl.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/senders/agent/tools/WebhookService.kt create mode 100644 zavudev-java-core/src/main/kotlin/com/zavudev/api/services/blocking/senders/agent/tools/WebhookServiceImpl.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentCreateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentCreateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentDeleteParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentListPageResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentListParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentListVoicesParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentListVoicesResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentRetrieveParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentRetrieveResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentTestParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentTestResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentUpdateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/AgentUpdateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/senders/SenderConnectParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/senders/SenderConnectResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agents/senders/SenderDisconnectParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateListResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/agenttemplates/AgentTemplateRetrieveResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallCreateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallCreateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallHangupParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallHangupResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallListPageResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallListParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallListResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallRetrieveParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/calls/CallRetrieveResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationListMessagesPageResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationListMessagesParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationListPageResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationListParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationListResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationMarkAsReadParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationMarkAsReadResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationRetrieveParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/conversations/ConversationRetrieveResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainCreateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainCreateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainDeleteParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainListParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainListResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainRetrieveParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainRetrieveResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainVerifyParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/emaildomains/EmailDomainVerifyResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionListDeploymentsParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionListDeploymentsResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionListEventTypesParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionListEventTypesResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionRollbackDeploymentParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/FunctionRollbackDeploymentResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkDeployNowParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkDeployNowResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkLinkParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkLinkResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkRetrieveParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkRetrieveResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkUnlinkParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkUpdateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/gitlink/GitLinkUpdateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerCreateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerCreateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerDeleteParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerListParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerListResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerUpdateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/functions/triggers/TriggerUpdateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/introspect/IntrospectValidateEmailParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/introspect/IntrospectValidateEmailResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageListAttachmentsParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/messages/MessageListAttachmentsResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentRetrieveDocumentParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentRetrieveDocumentResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentUpdateDocumentParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/knowledgebases/documents/DocumentUpdateDocumentResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/tools/ToolListTestRunsParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/tools/ToolListTestRunsResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/agent/tools/webhook/WebhookRotateSecretParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/telegram/TelegramConnectParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/telegram/TelegramConnectResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/senders/telegram/TelegramDisconnectParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/templates/TemplateSyncParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/templates/TemplateSyncResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/urls/UrlEscalateParamsTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/models/urls/UrlEscalateResponseTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/AgentServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/AgentTemplateServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/CallServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/ConversationServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/EmailDomainServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/agents/SenderServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/functions/GitLinkServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/functions/TriggerServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/senders/TelegramServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/async/senders/agent/tools/WebhookServiceAsyncTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/AgentServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/AgentTemplateServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/CallServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/ConversationServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/EmailDomainServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/agents/SenderServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/functions/GitLinkServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/functions/TriggerServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/senders/TelegramServiceTest.kt create mode 100644 zavudev-java-core/src/test/kotlin/com/zavudev/api/services/blocking/senders/agent/tools/WebhookServiceTest.kt diff --git a/.stats.yml b/.stats.yml index ec5b810..906e6fe 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-9acbefe4fc4908c698c1165bed491d415687f0092e9df6ffb968f92e43b11961.yml +configured_endpoints: 184 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zavu/zavudev-ba782c22cc1b237327afbf2aeffb453185cec9513d918b5a0fdc7e7233320c9b.yml openapi_spec_hash: 410cb45b6fa3a8a1f3da3aba50accbdc -config_hash: 7fca08d9dae18513f5d7451cea11e34c +config_hash: 261e1b852ca7f8364e4a283a3edd350a 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/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